表單
編輯器
富文字編輯器的外框:工具列、文件內容及兩者的狀態。
本頁內容
編輯器是富文字欄位的外框:由輸入欄位的凹槽、平鋪在凹槽頂端的工具列,以及其下方的文件組成。編輯本身(文件模型、選取範圍、復原紀錄與按鍵操作)則交給 Tiptap 或 ProseMirror 這類編輯引擎處理;引擎會讓 editor-document 變成可編輯,並在它渲染的區塊上寫入編輯器的類別。富文字說明如何在其中使用 Tiptap。
編輯器
<div class="field w-full max-w(560) mx-auto"> <span id="notes-label">Release notes</span> <div class="editor" style="--editor-rows: 5"> <div class="toolbar editor-toolbar" role="toolbar" aria-label="Formatting"> <button type="button" class="btn btn-quiet btn-sm btn-square" aria-label="Bold" aria-pressed="true"> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M4.6667 3H8.3333C12.3333 3 12.3333 7.6667 8.3333 7.6667H4.6667M4.6667 3V13H9C13.3333 13 13.3333 7.6667 9 7.6667" /> </svg> </button> <button type="button" class="btn btn-quiet btn-sm btn-square" aria-label="Italic" aria-pressed="false"> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M6.6667 3L12.6667 3" /><path d="M3.3333 13L9.3333 13" /><path d="M9.6667 3L6.3333 13" stroke-linecap="butt" /> </svg> </button> <span class="toolbar-separator" role="separator" aria-orientation="vertical"></span> <button type="button" class="btn btn-quiet btn-sm btn-square" aria-label="Bulleted list" aria-pressed="false"> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <circle cx="3" cy="4" r="0.5" fill="currentColor" stroke="none" /><path d="M6 4L13.5 4" /><circle cx="3" cy="8" r="0.5" fill="currentColor" stroke="none" /><path d="M6 8L13.5 8" /><circle cx="3" cy="12" r="0.5" fill="currentColor" stroke="none" /><path d="M6 12L13.5 12" /> </svg> </button> <button type="button" class="btn btn-quiet btn-sm btn-square" aria-label="Link" aria-pressed="false"> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M9 4.3333L10 3.3333C11.0125 2.3208 12.6541 2.3208 13.6667 3.3333C14.6792 4.3459 14.6792 5.9875 13.6667 7L11.6667 9C10.6541 10.0125 9.0125 10.0125 8 9" /><path d="M9 4.3333L10 3.3333C11.0125 2.3208 12.6541 2.3208 13.6667 3.3333C14.6792 4.3459 14.6792 5.9875 13.6667 7L11.6667 9C10.6541 10.0125 9.0125 10.0125 8 9" transform="rotate(180 8 8)" /> </svg> </button> </div> <div class="editor-document" role="textbox" aria-multiline="true" aria-labelledby="notes-label" contenteditable="true"> <h2 class="editor-heading">Version 0.4</h2> <p class="editor-paragraph"> Category colors arrive: <strong>twenty-three palettes</strong>, each with a surface, a text, a line and a mark. </p> </div> </div></div>import BoldIcon from '@master/icons-react/native/16/soft/bold'import ItalicIcon from '@master/icons-react/native/16/soft/italic'import ListIcon from '@master/icons-react/native/16/soft/list'import LinkIcon from '@master/icons-react/native/16/soft/link'<div className="field w-full max-w(560) mx-auto"> <span id="notes-label">Release notes</span> <div className="editor" style={{ '--editor-rows': '5' } as React.CSSProperties}> <div className="toolbar editor-toolbar" role="toolbar" aria-label="Formatting"> <button type="button" className="btn btn-quiet btn-sm btn-square" aria-label="Bold" aria-pressed="true"> <BoldIcon className="icon" /> </button> <button type="button" className="btn btn-quiet btn-sm btn-square" aria-label="Italic" aria-pressed="false"> <ItalicIcon className="icon" /> </button> <span className="toolbar-separator" role="separator" aria-orientation="vertical"></span> <button type="button" className="btn btn-quiet btn-sm btn-square" aria-label="Bulleted list" aria-pressed="false"> <ListIcon className="icon" /> </button> <button type="button" className="btn btn-quiet btn-sm btn-square" aria-label="Link" aria-pressed="false"> <LinkIcon className="icon" /> </button> </div> <div className="editor-document" role="textbox" aria-multiline="true" aria-labelledby="notes-label" contentEditable="true"> <h2 className="editor-heading">Version 0.4</h2> <p className="editor-paragraph"> Category colors arrive: <strong>twenty-three palettes</strong>, each with a surface, a text, a line and a mark. </p> </div> </div></div><script> import BoldIcon from '@master/icons-svelte/native/16/soft/bold' import ItalicIcon from '@master/icons-svelte/native/16/soft/italic' import ListIcon from '@master/icons-svelte/native/16/soft/list' import LinkIcon from '@master/icons-svelte/native/16/soft/link'</script><div class="field w-full max-w(560) mx-auto"> <span id="notes-label">Release notes</span> <div class="editor" style="--editor-rows: 5"> <div class="toolbar editor-toolbar" role="toolbar" aria-label="Formatting"> <button type="button" class="btn btn-quiet btn-sm btn-square" aria-label="Bold" aria-pressed="true"> <BoldIcon class="icon" /> </button> <button type="button" class="btn btn-quiet btn-sm btn-square" aria-label="Italic" aria-pressed="false"> <ItalicIcon class="icon" /> </button> <span class="toolbar-separator" role="separator" aria-orientation="vertical"></span> <button type="button" class="btn btn-quiet btn-sm btn-square" aria-label="Bulleted list" aria-pressed="false"> <ListIcon class="icon" /> </button> <button type="button" class="btn btn-quiet btn-sm btn-square" aria-label="Link" aria-pressed="false"> <LinkIcon class="icon" /> </button> </div> <div class="editor-document" role="textbox" aria-multiline="true" aria-labelledby="notes-label" contenteditable="true"> <h2 class="editor-heading">Version 0.4</h2> <p class="editor-paragraph"> Category colors arrive: <strong>twenty-three palettes</strong>, each with a surface, a text, a line and a mark. </p> </div> </div></div><script setup>import BoldIcon from '@master/icons-vue/native/16/soft/bold'import ItalicIcon from '@master/icons-vue/native/16/soft/italic'import ListIcon from '@master/icons-vue/native/16/soft/list'import LinkIcon from '@master/icons-vue/native/16/soft/link'</script><template> <div class="field w-full max-w(560) mx-auto"> <span id="notes-label">Release notes</span> <div class="editor" style="--editor-rows: 5"> <div class="toolbar editor-toolbar" role="toolbar" aria-label="Formatting"> <button type="button" class="btn btn-quiet btn-sm btn-square" aria-label="Bold" aria-pressed="true"> <BoldIcon class="icon" /> </button> <button type="button" class="btn btn-quiet btn-sm btn-square" aria-label="Italic" aria-pressed="false"> <ItalicIcon class="icon" /> </button> <span class="toolbar-separator" role="separator" aria-orientation="vertical"></span> <button type="button" class="btn btn-quiet btn-sm btn-square" aria-label="Bulleted list" aria-pressed="false"> <ListIcon class="icon" /> </button> <button type="button" class="btn btn-quiet btn-sm btn-square" aria-label="Link" aria-pressed="false"> <LinkIcon class="icon" /> </button> </div> <div class="editor-document" role="textbox" aria-multiline="true" aria-labelledby="notes-label" contenteditable="true"> <h2 class="editor-heading">Version 0.4</h2> <p class="editor-paragraph"> Category colors arrive: <strong>twenty-three palettes</strong>, each with a surface, a text, a line and a mark. </p> </div> </div> </div></template>沒有引擎時,這個預覽中的文件就是瀏覽器原生的 contenteditable:可以輸入文字,但無法建立結構,工具列也不會有任何作用。
#外框
- 它是一個欄位。 凹槽、懸停效果、焦點光暈、錯誤狀態的邊緣和停用時的墨色都與輸入欄位相同,因此富文字欄位看起來和周圍的欄位一致。讓外框浮起的是文件的焦點,因此在工具列中移動時,外框不會浮起。
- 工具列是一條橫帶。 在工具列上加上
editor-toolbar,它就會平鋪在凹槽頂端,向內縮排一個內距,讓它的圓角嵌在凹槽的圓角之內,下方則有一條細線。編輯器較窄時工具列會換行。工具列行為讓它只占一個 Tab 停駐點,並以方向鍵操作。 - 文件會隨內容長高。 空白時高度為
--editor-rows行(預設六行),最多長到--editor-max-rows行(十八行),之後就在外框內捲動。
#文件內容
樣式表從不直接選取元素:引擎會在每個區塊上寫入類別,只有這些類別會套用樣式,而且只在編輯器內有效。它不是用於整個頁面的排版樣式。
文件內容
<div class="editor w-full max-w(560) mx-auto"> <div class="editor-document" role="textbox" aria-multiline="true" aria-label="Document" contenteditable="true"> <h2 class="editor-heading">A heading</h2> <p class="editor-paragraph"> A paragraph with <a class="editor-link" href="#content">a link</a>, <em>emphasis</em> and <code class="code">inline code</code>. </p> <h3 class="editor-subheading">A subheading</h3> <ul class="editor-list"> <li class="editor-item"> <p class="editor-paragraph">A list with bullets</p> </li> <li class="editor-item"> <p class="editor-paragraph">Its markers in the muted ink</p> </li> </ul> <ol class="editor-list editor-list-numbered"> <li class="editor-item"> <p class="editor-paragraph">A list with numbers</p> </li> <li class="editor-item"> <p class="editor-paragraph">On an ordered list</p> </li> </ol> <blockquote class="editor-quote"> <p class="editor-paragraph">A quotation, a step quieter.</p> </blockquote> <hr class="editor-rule"> <p class="editor-paragraph">And a paragraph after a rule.</p> </div></div><div className="editor w-full max-w(560) mx-auto"> <div className="editor-document" role="textbox" aria-multiline="true" aria-label="Document" contentEditable="true"> <h2 className="editor-heading">A heading</h2> <p className="editor-paragraph"> A paragraph with <a className="editor-link" href="#content">a link</a>, <em>emphasis</em> and <code className="code">inline code</code>. </p> <h3 className="editor-subheading">A subheading</h3> <ul className="editor-list"> <li className="editor-item"> <p className="editor-paragraph">A list with bullets</p> </li> <li className="editor-item"> <p className="editor-paragraph">Its markers in the muted ink</p> </li> </ul> <ol className="editor-list editor-list-numbered"> <li className="editor-item"> <p className="editor-paragraph">A list with numbers</p> </li> <li className="editor-item"> <p className="editor-paragraph">On an ordered list</p> </li> </ol> <blockquote className="editor-quote"> <p className="editor-paragraph">A quotation, a step quieter.</p> </blockquote> <hr className="editor-rule" /> <p className="editor-paragraph">And a paragraph after a rule.</p> </div></div><div class="editor w-full max-w(560) mx-auto"> <div class="editor-document" role="textbox" aria-multiline="true" aria-label="Document" contenteditable="true"> <h2 class="editor-heading">A heading</h2> <p class="editor-paragraph"> A paragraph with <a class="editor-link" href="#content">a link</a>, <em>emphasis</em> and <code class="code">inline code</code>. </p> <h3 class="editor-subheading">A subheading</h3> <ul class="editor-list"> <li class="editor-item"> <p class="editor-paragraph">A list with bullets</p> </li> <li class="editor-item"> <p class="editor-paragraph">Its markers in the muted ink</p> </li> </ul> <ol class="editor-list editor-list-numbered"> <li class="editor-item"> <p class="editor-paragraph">A list with numbers</p> </li> <li class="editor-item"> <p class="editor-paragraph">On an ordered list</p> </li> </ol> <blockquote class="editor-quote"> <p class="editor-paragraph">A quotation, a step quieter.</p> </blockquote> <hr class="editor-rule"> <p class="editor-paragraph">And a paragraph after a rule.</p> </div></div><template> <div class="editor w-full max-w(560) mx-auto"> <div class="editor-document" role="textbox" aria-multiline="true" aria-label="Document" contenteditable="true"> <h2 class="editor-heading">A heading</h2> <p class="editor-paragraph"> A paragraph with <a class="editor-link" href="#content">a link</a>, <em>emphasis</em> and <code class="code">inline code</code>. </p> <h3 class="editor-subheading">A subheading</h3> <ul class="editor-list"> <li class="editor-item"> <p class="editor-paragraph">A list with bullets</p> </li> <li class="editor-item"> <p class="editor-paragraph">Its markers in the muted ink</p> </li> </ul> <ol class="editor-list editor-list-numbered"> <li class="editor-item"> <p class="editor-paragraph">A list with numbers</p> </li> <li class="editor-item"> <p class="editor-paragraph">On an ordered list</p> </li> </ol> <blockquote class="editor-quote"> <p class="editor-paragraph">A quotation, a step quieter.</p> </blockquote> <hr class="editor-rule"> <p class="editor-paragraph">And a paragraph after a rule.</p> </div> </div></template>#狀態
每種狀態都是引擎維護在其元素上的屬性,或頁面設定在外框上的屬性:文件取得焦點時,外框會浮起。aria-invalid="true" 會顯示錯誤狀態的外框。aria-readonly="true" 會讓外框平貼,並隱藏文字插入游標;在外框上設定 aria-disabled="true" 則會讓它變成平貼的凹槽,並使用停用時的墨色。無效的文件會顯示欄位的 field-error。請在停用編輯器時一併停用工具列的控制項,並告知引擎文件不可編輯。
狀態
<div class="grid gap-lg w-full max-w(560) mx-auto"> <div class="field"> <span id="state-invalid">Summary</span> <div class="editor" style="--editor-rows: 2"> <div class="editor-document" role="textbox" aria-multiline="true" aria-labelledby="state-invalid" aria-describedby="state-invalid-error" aria-invalid="true" contenteditable="true"></div> </div> <p class="field-error" id="state-invalid-error"> Write at least a sentence before you publish. </p> </div> <div class="field"> <span id="state-readonly">Published notes</span> <div class="editor" style="--editor-rows: 2"> <div class="editor-document" role="textbox" aria-multiline="true" aria-labelledby="state-readonly" aria-readonly="true" contenteditable="false" tabindex="0"> <p class="editor-paragraph"> Version 0.3 shipped tags, editable values and sortable lists. </p> </div> </div> </div> <div class="field"> <span id="state-disabled">Draft</span> <div class="editor" style="--editor-rows: 2" aria-disabled="true"> <div class="toolbar editor-toolbar" role="toolbar" aria-label="Formatting"> <button type="button" class="btn btn-quiet btn-sm btn-square" aria-label="Bold" aria-pressed="false" disabled> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M4.6667 3H8.3333C12.3333 3 12.3333 7.6667 8.3333 7.6667H4.6667M4.6667 3V13H9C13.3333 13 13.3333 7.6667 9 7.6667" /> </svg> </button> <button type="button" class="btn btn-quiet btn-sm btn-square" aria-label="Italic" aria-pressed="false" disabled> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M6.6667 3L12.6667 3" /><path d="M3.3333 13L9.3333 13" /><path d="M9.6667 3L6.3333 13" stroke-linecap="butt" /> </svg> </button> <span class="toolbar-separator" role="separator" aria-orientation="vertical"></span> <button type="button" class="btn btn-quiet btn-sm btn-square" aria-label="Bulleted list" aria-pressed="false" disabled> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <circle cx="3" cy="4" r="0.5" fill="currentColor" stroke="none" /><path d="M6 4L13.5 4" /><circle cx="3" cy="8" r="0.5" fill="currentColor" stroke="none" /><path d="M6 8L13.5 8" /><circle cx="3" cy="12" r="0.5" fill="currentColor" stroke="none" /><path d="M6 12L13.5 12" /> </svg> </button> <button type="button" class="btn btn-quiet btn-sm btn-square" aria-label="Link" aria-pressed="false" disabled> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M9 4.3333L10 3.3333C11.0125 2.3208 12.6541 2.3208 13.6667 3.3333C14.6792 4.3459 14.6792 5.9875 13.6667 7L11.6667 9C10.6541 10.0125 9.0125 10.0125 8 9" /><path d="M9 4.3333L10 3.3333C11.0125 2.3208 12.6541 2.3208 13.6667 3.3333C14.6792 4.3459 14.6792 5.9875 13.6667 7L11.6667 9C10.6541 10.0125 9.0125 10.0125 8 9" transform="rotate(180 8 8)" /> </svg> </button> </div> <div class="editor-document" role="textbox" aria-multiline="true" aria-labelledby="state-disabled" aria-disabled="true" contenteditable="false"> <p class="editor-paragraph">Locked while the release is reviewed.</p> </div> </div> </div></div>import BoldIcon from '@master/icons-react/native/16/soft/bold'import ItalicIcon from '@master/icons-react/native/16/soft/italic'import ListIcon from '@master/icons-react/native/16/soft/list'import LinkIcon from '@master/icons-react/native/16/soft/link'<div className="grid gap-lg w-full max-w(560) mx-auto"> <div className="field"> <span id="state-invalid">Summary</span> <div className="editor" style={{ '--editor-rows': '2' } as React.CSSProperties}> <div className="editor-document" role="textbox" aria-multiline="true" aria-labelledby="state-invalid" aria-describedby="state-invalid-error" aria-invalid="true" contentEditable="true"></div> </div> <p className="field-error" id="state-invalid-error"> Write at least a sentence before you publish. </p> </div> <div className="field"> <span id="state-readonly">Published notes</span> <div className="editor" style={{ '--editor-rows': '2' } as React.CSSProperties}> <div className="editor-document" role="textbox" aria-multiline="true" aria-labelledby="state-readonly" aria-readonly="true" contentEditable="false" tabIndex={0}> <p className="editor-paragraph"> Version 0.3 shipped tags, editable values and sortable lists. </p> </div> </div> </div> <div className="field"> <span id="state-disabled">Draft</span> <div className="editor" style={{ '--editor-rows': '2' } as React.CSSProperties} aria-disabled="true"> <div className="toolbar editor-toolbar" role="toolbar" aria-label="Formatting"> <button type="button" className="btn btn-quiet btn-sm btn-square" aria-label="Bold" aria-pressed="false" disabled> <BoldIcon className="icon" /> </button> <button type="button" className="btn btn-quiet btn-sm btn-square" aria-label="Italic" aria-pressed="false" disabled> <ItalicIcon className="icon" /> </button> <span className="toolbar-separator" role="separator" aria-orientation="vertical"></span> <button type="button" className="btn btn-quiet btn-sm btn-square" aria-label="Bulleted list" aria-pressed="false" disabled> <ListIcon className="icon" /> </button> <button type="button" className="btn btn-quiet btn-sm btn-square" aria-label="Link" aria-pressed="false" disabled> <LinkIcon className="icon" /> </button> </div> <div className="editor-document" role="textbox" aria-multiline="true" aria-labelledby="state-disabled" aria-disabled="true" contentEditable="false"> <p className="editor-paragraph">Locked while the release is reviewed.</p> </div> </div> </div></div><script> import BoldIcon from '@master/icons-svelte/native/16/soft/bold' import ItalicIcon from '@master/icons-svelte/native/16/soft/italic' import ListIcon from '@master/icons-svelte/native/16/soft/list' import LinkIcon from '@master/icons-svelte/native/16/soft/link'</script><div class="grid gap-lg w-full max-w(560) mx-auto"> <div class="field"> <span id="state-invalid">Summary</span> <div class="editor" style="--editor-rows: 2"> <div class="editor-document" role="textbox" aria-multiline="true" aria-labelledby="state-invalid" aria-describedby="state-invalid-error" aria-invalid="true" contenteditable="true"></div> </div> <p class="field-error" id="state-invalid-error"> Write at least a sentence before you publish. </p> </div> <div class="field"> <span id="state-readonly">Published notes</span> <div class="editor" style="--editor-rows: 2"> <div class="editor-document" role="textbox" aria-multiline="true" aria-labelledby="state-readonly" aria-readonly="true" contenteditable="false" tabindex="0"> <p class="editor-paragraph"> Version 0.3 shipped tags, editable values and sortable lists. </p> </div> </div> </div> <div class="field"> <span id="state-disabled">Draft</span> <div class="editor" style="--editor-rows: 2" aria-disabled="true"> <div class="toolbar editor-toolbar" role="toolbar" aria-label="Formatting"> <button type="button" class="btn btn-quiet btn-sm btn-square" aria-label="Bold" aria-pressed="false" disabled> <BoldIcon class="icon" /> </button> <button type="button" class="btn btn-quiet btn-sm btn-square" aria-label="Italic" aria-pressed="false" disabled> <ItalicIcon class="icon" /> </button> <span class="toolbar-separator" role="separator" aria-orientation="vertical"></span> <button type="button" class="btn btn-quiet btn-sm btn-square" aria-label="Bulleted list" aria-pressed="false" disabled> <ListIcon class="icon" /> </button> <button type="button" class="btn btn-quiet btn-sm btn-square" aria-label="Link" aria-pressed="false" disabled> <LinkIcon class="icon" /> </button> </div> <div class="editor-document" role="textbox" aria-multiline="true" aria-labelledby="state-disabled" aria-disabled="true" contenteditable="false"> <p class="editor-paragraph">Locked while the release is reviewed.</p> </div> </div> </div></div><script setup>import BoldIcon from '@master/icons-vue/native/16/soft/bold'import ItalicIcon from '@master/icons-vue/native/16/soft/italic'import ListIcon from '@master/icons-vue/native/16/soft/list'import LinkIcon from '@master/icons-vue/native/16/soft/link'</script><template> <div class="grid gap-lg w-full max-w(560) mx-auto"> <div class="field"> <span id="state-invalid">Summary</span> <div class="editor" style="--editor-rows: 2"> <div class="editor-document" role="textbox" aria-multiline="true" aria-labelledby="state-invalid" aria-describedby="state-invalid-error" aria-invalid="true" contenteditable="true"></div> </div> <p class="field-error" id="state-invalid-error"> Write at least a sentence before you publish. </p> </div> <div class="field"> <span id="state-readonly">Published notes</span> <div class="editor" style="--editor-rows: 2"> <div class="editor-document" role="textbox" aria-multiline="true" aria-labelledby="state-readonly" aria-readonly="true" contenteditable="false" tabindex="0"> <p class="editor-paragraph"> Version 0.3 shipped tags, editable values and sortable lists. </p> </div> </div> </div> <div class="field"> <span id="state-disabled">Draft</span> <div class="editor" style="--editor-rows: 2" aria-disabled="true"> <div class="toolbar editor-toolbar" role="toolbar" aria-label="Formatting"> <button type="button" class="btn btn-quiet btn-sm btn-square" aria-label="Bold" aria-pressed="false" disabled> <BoldIcon class="icon" /> </button> <button type="button" class="btn btn-quiet btn-sm btn-square" aria-label="Italic" aria-pressed="false" disabled> <ItalicIcon class="icon" /> </button> <span class="toolbar-separator" role="separator" aria-orientation="vertical"></span> <button type="button" class="btn btn-quiet btn-sm btn-square" aria-label="Bulleted list" aria-pressed="false" disabled> <ListIcon class="icon" /> </button> <button type="button" class="btn btn-quiet btn-sm btn-square" aria-label="Link" aria-pressed="false" disabled> <LinkIcon class="icon" /> </button> </div> <div class="editor-document" role="textbox" aria-multiline="true" aria-labelledby="state-disabled" aria-disabled="true" contenteditable="false"> <p class="editor-paragraph">Locked while the release is reviewed.</p> </div> </div> </div> </div></template>#無障礙
- 文件是帶有
aria-multiline="true"的role="textbox",透過aria-labelledby以欄位的標籤命名,並透過aria-describedby以提示和錯誤訊息描述。<label for>無法為非表單控制項的元素命名。 - 工具列只占一個 Tab 停駐點,需要命名,並以
aria-controls指向文件。請為每個圖示按鈕命名,以aria-pressed標示切換按鈕,並在aria-keyshortcuts中寫出引擎所處理的快捷鍵。 - 執行工具列指令後,焦點會回到文件中讀者正在書寫的位置。
- 不要自行在文件上加入按鍵處理程式:輸入法在組字時會使用 Enter 和方向鍵,而引擎知道何時正在組字。
- 在強制色彩模式下,外框會以欄位的顏色繪製輪廓,取得焦點時則使用醒目提示色。
#類別
| 類別 | 說明 |
|---|---|
editor | 外框:容納工具列橫帶和文件的欄位凹槽,在文件取得焦點時浮起 |
editor-toolbar | 加在外框頂端的工具列上:平鋪並向內縮排一個內距,下方有一條細線;編輯器較窄時會換行 |
editor-document | 由引擎設為可編輯的元素:高度從 --editor-rows 行長到 --editor-max-rows 行,之後就會捲動。請以 aria-labelledby 為它命名,並以欄位的提示描述它 |
editor-paragraph | 文件中的段落 |
editor-heading | 文件中的標題,用於 h2 或引擎輸出的層級 |
editor-subheading | 比 editor-heading 低一層的標題 |
editor-list | 帶有項目符號的清單,符號使用淡墨色;項目中的巢狀清單使用空心圓 |
editor-list-numbered | 以數字取代項目符號,用於 ol搭配 editor-list 使用 |
editor-item | 清單中的項目 |
editor-quote | 用於 blockquote 的引文樣式,在起始側加上分隔線,文字使用低一階的前景色。 |
editor-link | 文件中的連結,以該行的墨色加上底線 |
editor-rule | 文件各部分之間的水平分隔線 |
#自訂屬性
| 屬性 | 預設值 | 說明 |
|---|---|---|
--editor-rows | 6 | 文件空白時顯示的行數 |
--editor-max-rows | 18 | 開始捲動前最多長到的行數 |
#相關內容
- 輸入欄位採內凹樣式的文字欄位,支援標籤、提示、錯誤訊息與群組。
- 工具列小型凸起表面,容納一排低調的控制項。
- 訊息編輯器用來撰寫訊息或提示詞,上方是會自動增高的欄位,下方是一排工具。
- 程式碼以等寬字型呈現原樣文字,可放在行內或獨立成區塊。