1. 序論
この文書は、 `UI-EVENTS$r にて述べられれた 2 つの~event — `input$et, `beforeinput$et `UI-EVENTS$r — に対する[ 編集に関係する追加 ]を述べる。 これらの~eventの目標は、 次を許容することにある ⇒ 編集-時の既定の挙動を — 編集が生じる前と後の両者について — 作者が理解して上書きする ◎ This document describes editing related additions to 2 events - input and beforeinput which are described in the UI events spec [UI-EVENTS]. The goal of these events is to allow authors to understand and/or override default edit behavior both before and after editing occurs.
2. 適合性
【 この節を成す内容は、 `~W3C日本語訳 共通~page@~W3Ccommon#w3c-conformance$に移譲。 】
3. 定義
- `意図nを表出する@ ( `express an intention^en ) ◎ express intention
- 利用者は、[ ~keyboard, ~IME, ~speech ]などに類する~methodにより[ 特定の編集~演算を実行する意図n ]を表出できる。 特定の入力~動作は、[ ~platformに特有な規約に従う意図n ]に対応付けられる。 ◎ A user can express an intention to execute a specific editing operation by means of keyboard, IME, speech, or similar method. Specific input actions are mapped to intentions following platform-specific conventions.
- `~kill-buffer@ ( `kill buffer^en ) ◎ kill buffer
- この定義は規範的ではない。 ◎ This definition is not normative.
- `~kill-buffer$は、[ ~clipboardとは別々な,~memory内に格納された~richtext内容 ]である — それは、[ 特定の削除~commandを利用して削除された内容を一時的に保持する ]ことを許容する。 利用者は、[ ~kill-bufferを引き出す( `yank^en する)意図nを指示する ]ことにより,現在の選択を~kill-bufferの内容で置換できる。 ◎ A kill buffer is a in-memory store of richtext content that is separate from the clipboard which allows for the temporal storage of content that was deleted using specific deletion commands. The user can replace the current selection with the content held in the kill buffer by indicating an intention to yank the kill buffer.
- `内容編集可能@ な要素( `contenteditable^en )
- `contenteditable$a 内容~属性に基づいて,利用者が内容を編集できるとされる要素。
- 【 この用語 — 原文では、 単に[ “contenteditable 要素” あるいは “`contenteditable^c 要素” ] — は、 訳者による追加であり,その定義も訳者の推定による (なので,いくぶん曖昧な句 “編集できる” で表現しているが、 より厳密には “`isContentEditable@~HTMLinteraction#dom-iscontenteditable$m ~IDL属性が ~T を返す要素” のような定義が意図されているかもしれない)。 】
4. ~~解決される問題
◎非規範的~browser~codeの上層に ~webに基づく~text~editorを作成するためには、 他にも相当量の~JSを要する — なぜなら: ◎ Creating a webbased texteditor requires a considerable amount of JavaScript on top of the browser code, among other things because:
- すべての~browserが編集~演算を同じ仕方で取扱うわけではない。 ◎ Browsers do not handle all editing operations the same way.
- 編集~演算によっては、 ~browserによる取扱いに~bugが多い。 ◎ Browsers are often buggy in the way they handle certain editing operations.
- 編集~演算によっては、 個々の~siteごとに,その取扱いに~custom選好があり得る。 ◎ Individual sites may have custom preferences for how they want to handle certain editing operations.
- ~browserにおける[ 高~levelな~text編集~特能 ]の開発は、 `Extensible Web Manifesto@https://extensiblewebmanifesto.org/$cite に画策された原則に従っていない — これらの特能の開発は、 ~web開発者~communityの必要性と常に協調しているわけではない。 ◎ The development of high-level text editing features in browsers has not followed the principles laid out in the Extensible Web Manifesto in that development of these features has not always been in coordination with the needs of the web developer community.
この仕様は、[ 次の両者について,~web開発者にとって単純な仕方を供する ]ことにより,問題の~~緩和を探求する:
- [ ~text編集に関係する すべての利用者~入力 ]に対する~browserによる取扱いを `beforeinput$et ~eventを通して上書きする。
- [ 利用者~入力に因り,~DOM内の何が変更されたか ]を `input$et ~eventを通して監視する。
5. 利用事例
◎非規範的次を可能にする~JS~text~editorを作成する: ◎ ↓
- 利用者が~boldとして~markした~textを[ `<b>^e ~tagに代えて `<strong>^e ~tag ]を利用して~markする — ~browserに組込みの[ ~textを~boldとして~markするような仕方【?】 ]を利用して, および既存の~browserすべてに~accessする必要なく【?】。 ◎ Creating a JavaScript text editor in which the <strong>-tag is used instead of the <b>-tag to mark text that the user marks as bold, using any browser-builtin way to mark a text as bold, without having access to all existing browsers.
- 背後の~data~modelに対し作業して,~JSが[ 編集により変化した~textを~DOM内に具現化すること ]を~careする。 ◎ Creating a JavaScript text editor which works with a data model in the background where JavaScript takes care of rendering changes to the edited text to the DOM.
- ~richtext編集を一部に限り許容する (例えば、 ~boldは許容するが,~italicは許容しない)。 ◎ Creating a JavaScript editor which only allows a subset of richtext editing (for example: bold is allowed, but italic not).
- 共同作業可能である — [ 特定の意図nを様々な仕方で表出している,様々な~browser ]を利用している各~利用者の意図nに基づいて, ~JSを利用して変更を~DOM内に具現化するような。 ◎ Creating a collaborative editor in which JavaScript is used to render changes to the DOM, based on user intentions with users using different browsers with different ways of expressing specific intentions.
- 利用者~accessに関して,様々な~optionを備える — 例えば、 ある利用者に可能なのは,~textを追加したり削除することに限られ、 別の利用者に可能なのは,ある種の整形を追加したり除去することに限られる,など。 ◎ Creating a JavaScript editor with different user access options, where some users only can add or delete text and other users only can add or remove certain types of formatting.
6. 入力~event型
入力~eventは、 利用者が~markupを編集するよう試みる前( `beforeinput$et ~event )と試みた後( `input$et ~event)に送信される。 これには、 内容の[ 挿入や削除/整形の変更 ]も含まれる。 ◎ Input events are sent before (beforeinput event) and after (input event) a user attempts to edit the markup. This includes insertion and deletion of content, and formatting changes.
入力~eventは、 `編集中の~host$として動作する要素に向けて`配送-$される。 そのような要素には、 次が挙げられる ⇒# `contenteditable$a 属性が設定されているもの, `textarea$e 要素, ~text入力を許容する `input$e 要素 ◎ Input events are dispatched on elements that act as editing hosts, including elements with the contenteditable attribute set, textarea elements, and input elements that permit text input.
6.1. ~interface `InputEvent^I
partial interface `InputEvent$I {
readonly attribute `DataTransfer$I? `dataTransfer$m;
sequence<`StaticRange$I> `getTargetRanges()$m;
};
partial dictionary `InputEventInit$I {
`DataTransfer$I? `dataTransfer@mb = null;
sequence<`StaticRange$I> `targetRanges@mb = [];
};
`InputEventInit$I の: ◎ ↓
- [ `inputType$mb / `dataTransfer$mb ]~memberは、 `InputEvent$I ~objの対応する属性を初期化する。 ◎ The attributes inputType and dataTransfer of InputEventInit initialize the corresponding attributes of the InputEvent object.
- `targetRanges$mb ~memberは、 `InputEvent$I ~objの `getTargetRanges()$m ~methodが返す`~target範囲~群$を初期化する。 ◎ The targetRanges attribute of InputEventInit initializes the target ranges of the InputEvent object, which getTargetRanges() returns.
6.1.1. 概観
◎非規範的次の表tに,[ `data$m 属性や `dataTransfer$m 属性が返す値/ `getTargetRanges()$m ~methodが返す連列 ]が[ `編集中の~host$, `inputType$m ]に基づいて いつ[ ~NULL / 空 ]になるかを要約する。 ◎ The following table provides a summary of when the data and dataTransfer attributes contain contents and when they are null as well as when the getTargetRanges() method returns an empty or non-empty Array, based on the inputType.
| `編集中の~host$ | `inputType$m | `data$m | `dataTransfer$m | `getTargetRanges()$m |
|---|---|---|---|---|
| `内容編集可能$ | `insertText^l, `insertCompositionText^l, `formatSetBlockTextDirection^l, `formatSetInlineTextDirection^l, `formatBackColor^l, `formatFontColor^l, `formatFontName^l, `insertLink^l | 非~NULL | ~NULL | 空でない |
| `内容編集可能$ | `insertFromPaste^l, `insertFromPasteAsQuotation^l, `insertFromDrop^l, `insertReplacementText^l, `insertFromYank^l | ~NULL | 非~NULL | 空でない |
| ~text入力 | `insertText^l, `insertCompositionText^l, `insertFromPaste^l, `insertFromPasteAsQuotation^l, `insertFromDrop^l, `insertReplacementText^l, `insertFromYank^l, `formatSetBlockTextDirection^l, `formatSetInlineTextDirection^l, `formatBackColor^l, `formatFontColor^l, `formatFontName^l, `insertLink^l | 非~NULL | ~NULL | 空 |
| すべて | `historyUndo^l, `historyRedo^l | ~NULL | ~NULL | 空 |
| `内容編集可能$ | 残りすべて | ~NULL | ~NULL | 空でない |
| ~text入力 | 残りすべて | ~NULL | ~NULL | 空 |
6.1.2. 各種 属性
`~UA$は、 ~eventを初期化する際には, 次に挙げる属性を以下のとおり拡充するモノトスル: ◎ ↓
- `inputType$m
- `beforeinput$et ~eventの取消~可否は,以下に与える `inputType$m 用の値に依存する — 値が `insertCompositionText^l に初期化される場合は、 取消せない( `cancelable$m は ~F になる)。 ◎ The cancelability of the beforeinput event depends on the inputType.
-
この属性は、 次の表tの 2, 3, 4 列目に挙げる[ 利用者が`表出した意図n$, ~IME組成の間に編集が生じるかどうか, 選択の状態 ]に応じて,表tの 1 列目に挙げる値に初期化するモノトスル: ◎ The inputType to be picked depends on the user's expression of intention, whether or not the editing takes place during an IME composition and the state of the selection. ◎ This specification defines the inputType values as the values in the inputType column of the following table.
【 原文の表tには `beforeinput$et ~eventの取消~可否の列もあるが、 この訳ではその列を省略して,上の記述に集約している。 】
編集? 列における[ 空欄 / `あり^i ]は、 ~IME組成の間に編集は[ 生じない/生じる ]ことを表す。
選択~状態 列における[ `畳^i / `非畳^i ]は、 選択は[ 畳まれている/畳まれていない ]ことを表す。 空欄は、 選択~状態を問わないことを表す。
`inputType$m 利用者が`表出した意図n$ ◎ User's expression of intention 編集? ◎ Part of IME composition 選択~状態 ◎ State of selection `insertText^l 打込まれた素な~textを挿入する ◎ insert typed plain text `insertReplacementText^l [ ~spell-checker, 自動訂正, 書法の示唆 ]などに類する~methodにより,既存の内容[ に何かを挿入する/を置換する ] ◎ insert or replace existing content by means of a spell checker, auto-correct, writing suggestions or similar `insertLineBreak^l 改行を挿入する ◎ insert a line break `insertParagraph^l 段落~分断を挿入する ◎ insert a paragraph break `insertOrderedList^l 番号付き~listを挿入する ◎ insert a numbered list `insertUnorderedList^l 番号無し~listを挿入する ◎ insert a bulleted list `insertHorizontalRule^l 水平罫線を挿入する ◎ insert a horizontal rule `insertFromYank^l `~kill-buffer$に格納されている内容で,現在の選択を置換する ◎ replace the current selection with content stored in a kill buffer `insertFromDrop^l ~dropにより,内容を挿入する ◎ insert content by means of drop `insertFromPaste^l ~clipboardから内容を~pasteする/ ~clientが供した画像~libraryから画像を~pasteする ◎ paste content from clipboard or paste image from client provided image library `insertFromPasteAsQuotation^l ~clipboardから内容を引用文として~pasteする ◎ paste content from the clipboard as a quotation `insertTranspose^l 手入力された最後の 2 個の`書記素~cluster$を入替える ◎ transpose the last two grapheme cluster. that were entered `insertCompositionText^l 現在の組成~文字列を置換する ◎ replace the current composition string `あり^i `insertLink^l ~linkを挿入する ◎ insert a link `deleteWordBackward^l ~caret位置の直前にある単語を削除する ◎ delete a word directly before the caret position `畳^i `deleteWordForward^l ~caret位置の直後にある単語を削除する ◎ delete a word directly after the caret position `畳^i `deleteSoftLineBackward^l ~caret位置からその前にある最も近い視覚的な改行までを削除する ◎ delete from the caret to the nearest visual line break before the caret position `畳^i `deleteSoftLineForward^l ~caret位置からその後にある最も近い視覚的な改行までを削除する ◎ delete from the caret to the nearest visual line break after the caret position `畳^i `deleteEntireSoftLine^l [ ~caret位置の前にある最も近い視覚的な改行 ]から[ ~caret位置の後にある最も近い視覚的な改行 ]までを削除する ◎ delete from the nearest visual line break before the caret position to the nearest visual line break after the caret position `畳^i `deleteHardLineBackward^l ~caret位置からその前にある最も近い[ 塊~要素または `br$e 要素 ]の始まりまでを削除する ◎ delete from the caret to the nearest beginning of a block element or br element before the caret position `畳^i `deleteHardLineForward^l ~caret位置からその後にある最も近い[ 塊~要素または `br$e 要素 ]の終わりまでを削除する ◎ delete from the caret to the nearest end of a block element or br element after the caret position `畳^i `deleteByDrag^l ~dragにより,~DOMから内容を除去する ◎ remove content from the DOM by means of drag `deleteByCut^l ~cutの一部として,現在の選択を除去する ◎ remove the current selection as part of a cut `deleteContent^l 他の `inputType$m 値が受持たない意図nの下で、 削除の方向を指定せずに,選択を削除する ◎ delete the selection without specifying the direction of the deletion and this intention is not covered by another inputType `非畳^i `deleteContentBackward^l 次に挙げるいずれか: - 他の `inputType$m 値が受持たない意図nの下で、 ~caret位置の直前にある内容を削除する
- 選択を[ 削除~後には,その始端に畳まれる ]よう削除する
`deleteContentForward^l 次に挙げるいずれか: - 他の `inputType$m 値が受持たない意図nの下で、 ~caret位置の直後にある内容を削除する
- 選択を[ 削除~後には,その終端へ畳まれる ]よう削除する
`historyUndo^l 最後の編集~動作を~undoする ◎ undo the last editing action `historyRedo^l 最後に~undoされた編集~動作を~redoする ◎ to redo the last undone editing action `formatBold^l ~bold~textを起する ◎ initiate bold text `formatItalic^l ~italic~textを起する ◎ initiate italic text `formatUnderline^l ~underline~textを起する ◎ initiate underline text `formatStrikeThrough^l ~stricken~textを起する ◎ initiate stricken through text `formatSuperscript^l ~superscript~textを起する ◎ initiate superscript text `formatSubscript^l ~subscript~textを起する ◎ initiate subscript text `formatJustifyFull^l 現在の選択を両端揃えにする ◎ make the current selection fully justified `formatJustifyCenter^l 現在の選択を中央に寄せる ◎ center align the current selection `formatJustifyRight^l 現在の選択を右端に寄せる ◎ right align the current selection `formatJustifyLeft^l 現在の選択を左端に寄せる ◎ left align the current selection `formatIndent^l 現在の選択の字下げを増やす ◎ indent the current selection `formatOutdent^l 現在の選択の字下げを減らす ◎ outdent the current selection `formatRemove^l 現在の選択からすべての整形情報を除去する ◎ remove all formatting from the current selection `formatSetBlockTextDirection^l ~text塊~方向を設定する ◎ set the text block direction `formatSetInlineTextDirection^l ~text行内~方向を設定する ◎ set the text inline direction `formatBackColor^l 背景~色を変更する ◎ change the background color `formatFontColor^l ~font色を変更する ◎ change the font color `formatFontName^l `font-family^p を変更する ◎ change the font-family - 注記: 他の仕様は、 この定義を拡げてもヨイ。 ◎ Note ◎ Other specifications may expand on this definition.
- 注記: 実装は、 上に挙げられた `inputType$m 値~すべてを~supportするとは限らない。 ~UA【!所与の~browser】は[ ~DOMを変化させ得る,ある編集~演算 ]を~supportする場合には、 対応する[ `beforeinput$et, `input$et ]~eventを`配送-$するモノトスル。 ◎ Note ◎ The existence of the above mentioned inputTypes does not mean that any given implementation will support all of these. But if a given browser supports an editing operation which potentially leads to a change of the DOM, it MUST dispatch the corresponding beforeinput and input events.
-
注記: 選択が畳まれている場合、 利用者が次に挙げる意図nを示したときにも, `deleteContentBackward^l が利用される:
- ~text~nodeの中で~textを削除する
- より複階的な要素を削除する
- ~caretが~text~nodeの始端にある場合に段落を併合する
同じ文言は、 “始端” を “終端” に読み替える下で, `deleteContentForward^l にも該当する。
◎ Note ◎ If the selection is collapsed, "deleteContentBackward" will be used both when the user asks for text deletion within a text node, and when the user shows the intention to deletion of more complex elements or merge paragraphs if the caret is at the start of a text node. ◎ Note ◎ If the selection is collapsed, "deleteContentForward" will be used both when the user asks for text deletion within a text node, and when the user shows the intention to deletion of more complex elements or merge paragraphs if the caret is at the end of a text node. - `data$m
-
この属性は、 文書に追加されるものに関係する~plaintext~data情報を保持する。 次の表tの 1, 2 列目に挙げる [ `inputType$m の値, `編集中の~host$ ]に応じて,表tの 3 列目に挙げる文字列~値になる: ◎ data holds information plaintext data related to what is to be added to the document.
`inputType$m `編集中の~host$ `data$m `insertText^l, `insertCompositionText^l 任意 挿入されようとしている~text ◎ the plain text string to be inserted `insertFromPaste^l, `insertFromPasteAsQuotation^l, `insertFromDrop^l, `insertTranspose^l, `insertReplacementText^l, `insertFromYank^l `input$e / `textarea$e 挿入されようとしている~text ◎ the plain text string to be inserted `formatSetInlineTextDirection^l, `formatSetBlockTextDirection^l 任意 次に挙げるいずれか ⇒ `ltr^l / `rtl^l / `auto^l / `null^l `formatBackColor^l, `formatFontColor^l 任意 次の結果 ⇒ `~CSS成分~値を直列化する$( 提された色 ) `CSSOM$r ◎ a string containing a serialized CSS component value [CSSOM] of the proposed color `formatFontName^l 任意 `font-family^p ~prop用の値として提された値 ◎ the proposed value of the font-family CSS property `insertLink^l 任意 ~link用に提された~URL ◎ the url of the proposed link その他 ◎ All remaining 任意 ~NULL - `dataTransfer@m
- 関連な[ ~richtext/~plaintext ]~data — 文書から取り出される, あるいは文書に追加されることになるそれ — についての情報が在るならば、 それを `DataTransfer$I ~obj `HTML$r 内に保持する。 ◎ dataTransfer holds information about richtext and plaintext data that is to be taken from or added to the document in a DataTransfer object if there is relevant data.
-
その値は、[ ~AND↓ が満たされるならば `DataTransfer$I ~obj/ ~ELSE_ ~NULL ]になる:
- `編集中の~host$は`内容編集可能$である
- `inputType$m ~IN { `insertFromPaste^l, `insertFromPasteAsQuotation^l, `insertFromDrop^l, `insertTranspose^l, `insertReplacementText^l, `insertFromYank^l }
`DataTransfer$I ~objになる場合、 その`~drag~data~store$は `読専~mode$i になり, その`~item~list$ddSは[ 追加される内容に応じて,次に挙げるものからなる ]よう拡充される `HTML$r : ◎ The DataTransfer object's drag data store is in read-only mode. [HTML]\
-
~fileである場合 ⇒ 次を伴う 1 個の~item ⇒# `型~文字列$dI ~SET 当の~fileの`~MIME型$ `種類$dI ~SET `File^i `実際の~data$dI ~SET 当の~fileに対応する `File$I ~obj【の`~byte列~data$】 ◎ If the pasted content is a file, the DataTransfer object's drag data store item list contains one entry with the drag data item type string being the file's mime type, whose kind is File, and whose data is a File object corresponding to the pasted file. [HTML]
【 例えば,一度に複数個の~fileが~pasteされた場合、 `~item~list$ddSは複数個の~itemからなりそうにも思われるが, ~fileごとに別々な~eventが発火されるのかもしれない(はっきりしない)。 】
-
~textである場合 ⇒ 次を伴う 2 個の~item ⇒# 1 個目の~itemの`実際の~data$dI ~SET 追加される内容の~HTML~表現, 2 個目の~itemの`実際の~data$dI ~SET 追加される内容の素な~text表現, どちらも,その`型~文字列$dI ~SET `text/html^l, どちらも,その`種類$dI ~SET `Text^i【! “Plain Unicode string” から改称された】
追加される内容としては、 例えば,次が挙げられる ⇒# ~clipboard内にあるもの / `~kill-buffer$内にあるもの / ~pasteされたもの / ~dropされたもの
◎ The DataTransfer object's drag data store item list contains one entry with the drag data item type string "text/html", whose kind is Plain Unicode string, and whose data is a HTML representation of the content that is in the clipboard, or in the kill buffer, to be dropped or otherwise the content that is to be added. [HTML] ◎ The DataTransfer object's drag data store item list contains one entry with the drag data item type string "text/plain", whose kind is Plain Unicode string, and whose data is a plain text representation of the content that is to be pasted, dropped or otherwise added. [HTML] - ~linkである場合 ⇒ 次を伴う 1 個の~item ⇒# `型~文字列$dI ~SET `text/uri-list^l `種類$dI ~SET `Text^i `実際の~data$dI ~SET 当の~linkを表現する素な~text ◎ If the content to be pasted is a link, the DataTransfer object's drag data store item list contains one entry with the drag data item type string "text/uri-list", whose kind is Plain Unicode string, and whose data is a plain text representation of the link that is dropped or otherwise added. [HTML] ◎ ↑↑All remaining | Any | null
6.1.3. ~method
各 `InputEvent$I ~objには、 `~target範囲~群@ が結付けられる — それは、 `StaticRange$I たちが成す連列である。 ◎ Each InputEvent object has associated target ranges, which is a sequence of StaticRanges.\
`InputEvent$I ~objが作成されたときは、 その`~target範囲~群$を以下に従って設定するモノトスル: ◎ When an InputEvent object is created, its target ranges are set to ◎ ↓↓ the value of the targetRanges attribute of the InputEventInit dictionary, or to an empty sequence if that attribute was not given.
- 当の~objは`~UA$が`配送-$する`~trusted$な~eventである場合 ◎ A user agent MUST set the target ranges of a trusted InputEvent that it dispatches as follows:
-
当の`編集中の~host$に応じて: ◎ ↓
- `内容編集可能$な~nodeであるならば ⇒ [ 当の~eventが取消されなかった場合に改変されることになる内容 ]を表現するもの ◎ If the editing host is a contenteditable node, the target ranges MUST represent the content that the event will modify if it is not canceled.
- `~EditContextの編集中の~host$であるならば ⇒ [ `~UA$が当の~eventにより影響されるものと見做す内容 ]を表現するもの ◎ Otherwise, if the editing host is an EditContext editing host, the target ranges MUST represent the content that the user agent assumes to be affected by the event.
- 他の場合 ⇒ 空な連列 ◎ Otherwise, the target ranges MUST be empty.
- この場合,`~target範囲~群$が受持つ`符号位置$たちは、 `~UA$が通常に置換することになるものに限るモノトスル — それらが`書記素~cluster$の一部しか成さない場合【下の注記を見よ】でも。 ◎ The target ranges of an InputEvent dispatched by a user agent MUST cover only the code points that the user agent would normally replace, even if they are only part of a grapheme cluster.
- 当の~objは合成な~event【`~trusted$でない,~scriptにより作成されたもの】である場合 ◎ When an InputEvent object is created by script, its target ranges are\
- 【~event構築子に渡された】 `InputEventInit$I 辞書を成す `targetRanges$mb ~memberの値 (指定されなかった場合の既定~値は,空な連列) ◎ the ones the creating script set through the targetRanges attribute of the InputEventInit dictionary.\
- この場合,`~UA$は、 当の~eventの`~target範囲~群$を[ 改めない/[ `編集中の~host$/ `inputType$m の値/~DOMの状態 ]から導出しない ]モノトスル — 当の~eventが`編集中の~host$へ向けて配送される場合でも, 当の~eventの `inputType$m が[ 当の~eventが`~trusted$であったなら、 `~UA$が当の~event用に`~target範囲~群$を算出することになる値 ]をとる場合でも。 ◎ A user agent MUST NOT alter them, and MUST NOT derive them from the editing host, the inputType or the state of the DOM. In particular, the target ranges of an InputEvent that is not trusted are an empty sequence if the creating script did not set them, even if the event is dispatched on an editing host and has an inputType for which a user agent would otherwise compute target ranges.
- 注記: `InputEvent$I を既知な`~target範囲~群$で作成-可能であることは、[ `~UA$が利用者-~gestureへ対応付ける仕方を有さない入力~意図nを表出する ]ことを~editorに許容する。 例えば,ある~editorの~UIに “後方へ単語を削除する” ~buttonが在るならば、 当の~editorは, `beforeinput$et ~eventを — ~event~handlerが,それに対し`~trusted$な~eventに対するときと同じに動作できるよう — その `inputType$m には `deleteWordBackward^l を, その `~target範囲~群$には自身が~caretより前にある単語~用に算出したものを 設定した上で配送できる。 ◎ Note This note is not normative. Being able to create an InputEvent with known target ranges allows an editor to express an input intention that the user agent doesn't have a way of mapping to a user gesture. For example, an editor whose UI has a “delete word backward” button can dispatch a beforeinput event with an inputType of "deleteWordBackward" and the target ranges it computed for the word before the caret, so that event handlers can act on it just as they would act on a trusted event.
注記: ~scriptや~platformに依存して, ~text~node内を後方や前方へ削除したとき(選択は畳まれているとする)、 書記素~cluster全体に影響する場合も, それを成す一部の符号位置たちに限り影響する場合もある。 例えば, “café” を包含している~text~node内で後方へ削除すると、 ~scriptや~platformに依存して, 文字 “é” 全体を除去することもアクセント符( `acute accent^en, "´" )だけを除去することもある。 ◎ Note This note is not normative. Depending on the script and the platform, deleting backward or forward in a text node with a collapsed selection may affect one or multiple code points or an entire grapheme cluster. For example, deleting backward in a text node containing “café” may remove either the acute accent or the entire “é” character, depending on the script and the platform.
`~UA$が`~trusted$な~eventとして`配送-$する `InputEvent$I ~objの `getTargetRanges()$m は、 ~OR↓ が満たされる場合には,空な連列を返す:
- 当の~eventの `inputType$m ~IN { `historyUndo^l, `historyRedo^l }
- `編集中の~host$は`内容編集可能$でない
6.2. 各種~eventの定義
◎イ型 `beforeinput@et ◎界面 `InputEvent$I ◎同期 あり ◎浮上 する ◎標的 `編集中の~host$である任意の要素 ◎ Any Element that is an editing host. ◎既定動作当の`編集中の~host$ %~host, この~eventの `inputType$m %型 に応じて: ◎ ↓
- [ %~host の `contentEditable$m ~EQ `typing^l ]~AND[ %型 ~EQ `insertCompositionText^l ]ならば ⇒ “~DOMを更新する” ◎ For contentEditable=typing editing hosts for inputType "insertCompositionText": 'Update the DOM'.
- [ %~host の `contentEditable$m ~EQ `true^l ]ならば、 %型 を問わず ⇒ “~DOMを更新する” ◎ For contentEditable="true" editing hosts for all inputTypes: 'Update the DOM'.
- [ %~host は`~EditContextの編集中の~host$である ]~AND[ %型 は`~EditContextが取扱う入力~型@~EDITCONTEXT#dfn-editcontext-handled-inputtype$である ]ならば ⇒ `~EditContext用の入力を取扱う@~EDITCONTEXT#dfn-handle-input-for-editcontext$( %~host ) ◎ For EditContext editing hosts for EditContext-handled inputTypes: Handle input for EditContext given the editing host element.
- 他の場合 ⇒ なし ◎ None otherwise.
- `data$m
- 要素に追加された~dataを包含している文字列。 適用されない場合は ~NULL になる。 ◎ InputEvent.data: the string containing the data that was added to the element, which MAY be null if it doesn't apply.
- `dataTransfer$m
- 要素[ に追加された/から削除された ]~richtextを包含している文字列。 適用されない場合は ~NULL になる。 ◎ InputEvent.dataTransfer: richtext data added or removed from element, which MAY be null if it doesn't apply.
- `getTargetRanges()$m
- 取消されなかった場合に、 ~DOMに対する変更により影響されることになる `StaticRange$I たちが成す配列を返す。 ◎ InputEvent.getTargetRanges(): returns an array of StaticRanges which will be affected by the change to the DOM if it is not canceled.
`~UA$は、 利用者が`内容編集可能$な要素にて入力を試みたときに,この~eventを`配送-$するモノトスル。 これは、 `~UA$が~DOMを更新することを意味するとは限らない。 ◎ A user agent MUST dispatch this event when the user has attempted to input in a contenteditable element. It does not necessarily mean the user agent will then update the DOM.
`~UA$は、 ~system~eventなど,利用者により試みられた入力~以外に因る~eventに対しては、 この~eventを`配送-$しないモノトスル。 ◎ A user agent MUST NOT dispatch this event due to events that are not caused by attempted user input, such as system events.
これは、[ ~scriptが `beforeinput$et ~eventを`配送-$すること ]を防止するものではない。 そのような~eventは,`~trusted$でないので、 その`~target範囲~群$は,当の `InputEvent$I ~objの作成-時に設定されたものになり、 `getTargetRanges()$m は,それを返す。 ◎ This does not prevent a script from dispatching a beforeinput event. Such an event is not trusted, so its target ranges are the ones that were set when the InputEvent object was created, and getTargetRanges() returns them.
注記: 第三者-主体による~browser拡張 — 綴り検査器や文法~検査器など — は、 合成な `beforeinput$et ~event(その `isTrusted$m 属性は ~F をとる)を配送することにより, 編集-可能な要素を成す内容を改変し得る — `~UA$は、 そのような改変に対し~eventを`配送-$しないので。 作者には,そのような拡張と互換であり続けるためには、 これら合成な `beforeinput$et ~eventを~listenして,[ その `inputType$m が次に挙げるいずれかであるならば, 対応する~trustedな~eventと同じ仕方で取扱う ]ことを勧める ⇒# `insertReplacementText^l / `insertFromPaste^l / `deleteContent^l / `deleteContentBackward^l / `deleteContentForward^l ◎ Note This note is not normative. ◎ Third-party browser extensions, such as spelling or grammar checkers, may modify the contents of editable elements by dispatching synthetic beforeinput events (events whose isTrusted attribute is false), as the user agent does not dispatch events for such modifications. To remain compatible with such extensions, JavaScript developers are advised to listen for these synthetic beforeinput events and to handle those whose inputType is "insertReplacementText", "insertFromPaste", "deleteContent", "deleteContentBackward" or "deleteContentForward" in the same way as the corresponding trusted events.
このことは、 `~EditContextの編集中の~host$を利用する~editorにも適用される — `inputType$m が削除~型の値 [ `deleteContent^l / `deleteContentBackward^l / `deleteContentForward^l ]をとるときの取扱いは,そこでは通例的には必要ないが,それでも、[ `~UA$は,それらを~EditContextを通して取扱う ]ので[ ~editorは,[ 拡張により配送された合成な `beforeinput$et ~eventのうち, その `inputType$m がこれらをとるもの ]を取扱うべき ]である。 同様に,第三者-主体による拡張が~paste演算と同じ仕方で内容を挿入する所では、[ 合成な `beforeinput^et ~eventのうち, その `inputType$m は `insertFromPaste^l をとるもの ]を~listenする方が, 合成な `paste$et ~event `CLIPBOARD-APIS$r を~listenするよりも好ましい — `paste^et ~eventは、 ~target範囲を運ばないので。 ◎ This applies also to editors that use an EditContext editing host: even though handling of the deletion inputTypes "deleteContent", "deleteContentBackward" and "deleteContentForward" is usually not needed there, as the user agent handles them through the EditContext, editors should still handle synthetic beforeinput events of these inputTypes dispatched by extensions. Likewise, where a third-party extension inserts content the way a paste operation would, listening for the synthetic beforeinput event with inputType "insertFromPaste" is preferable to listening for a synthetic paste [CLIPBOARD-APIS] event, as paste events do not carry target ranges.
- `data$m
- 要素に追加された~dataを包含している文字列。 適用されない場合は ~NULL になる。 ◎ InputEvent.data: the string containing the data that was added to the element, which MAY be null if it doesn't apply.
- `dataTransfer$m
- 要素[ に追加された/から削除された ]~richtextを包含している文字列。 適用されない場合は ~NULL になる。 ◎ InputEvent.dataTransfer: richtext data added or removed from element, which MAY be null if it doesn't apply.
- `getTargetRanges()$m
- ~DOMに対する変更により影響された `StaticRange$I たちが成す連列を返す。 ◎ InputEvent.getTargetRanges(): returns an array of StaticRanges which were affected by the change to the DOM.
`~UA$は、 次に従うモノトスル: ◎ ↓
- 利用者が[ ~browserが取扱った文書~内容 ]を変更する意図nを表出したことに因り,~DOMを更新したならば、 その直後に,この~eventを`配送-$する。 ◎ A user agent MUST dispatch this event immediately after the DOM has been updated due to user expressed intention to change the document contents which the browser has handled.\
-
[ 次に挙げるいずれかにより,~DOMに対する変更を為さなかった場合 ]には、 この~eventを`配送-$しない:
- 当の`編集中の~host$は、 `~EditContextの編集中の~host$である (それは、 自動的な~DOM変更を行わない)
- ~DOM変更は必要ないものと結論した
~scriptにより作成された `InputEvent$I は、 その~event型が `input$et であっても, その`~target範囲~群$は[ `beforeinput$et ~eventと同じく `InputEventInit$I 辞書に与えられた ]それになり、 `getTargetRanges()$m は,それを返す。 ◎ As for the beforeinput event, an InputEvent of type input that is created by script has the target ranges given in the InputEventInit dictionary, and getTargetRanges() returns them.
7. ~IME組成の間における入力~event順序
【 この節に利用される[ 組成~session( `composition session^en ), `~text組成~system$( `text composition system^en ), 作動中な~text一節( `active text passage^en ), ~target範囲( `target range^en ) ]は、 用語として~mark-upされているが,それらの定義を指す参照は与えられていない。 】
組成~session【!組成】 【 `UI-EVENTS$r `§ 組成~event@~UIEVENTS#events-compositionevents$】 の開始~時には、 `compositionstart$et ~eventが配送される。 ◎ The start of a composition is marked by dispatching a compositionstart event.
組成~sessionの間, ~text組成~systemが作動中な~text一節 【~IMEにより編集されている~text】 を更新するときは、 `compositionupdate$et ~eventが配送される。 ◎ During a composition session, whenever a text composition system updates its active text passage, a compositionupdate event is dispatched.
各 `compositionupdate$et ~eventの後には、 順に,[ `beforeinput$et, `input$et ]~eventが配送される — どちらの~eventも: ◎ After each compositionupdate event, a pair of beforeinput and input events are dispatched. The beforeinput and input events:
- 取消-可能でない ◎ Are not cancellable
- `inputType$m は `insertCompositionText^l に設定される ◎ Have an inputType set to "insertCompositionText"
- `data$m 属性は、 `compositionupdate^et ~eventのそれに等しい。 ◎ Have a data attribute equal to that of the compositionupdate event
- 組成にて作動中な~text一節を囲む~target範囲を伴う 【おそらく, `getTargetRanges()$m の結果を与えるための。】 ◎ Have a targetRange that surrounds the active text passage of the composition
作動中な~text一節の~DOM内容が更新されるのは、 `beforeinput$et ~eventが配送された後, かつ `input$et ~eventが配送される前になる。 ◎ The DOM contents of the active text passage are updated after the beforeinput event is dispatched and before the input event is dispatched.
組成~sessionの終了~時には、 `compositionend^et ~eventが配送される。 ◎ The end of a composition session is marked by dispatching a compositionend event.
8. `insertFromPaste^l を 利用しているときの~event順序
`insertFromPaste^l を伴う `beforeinput$et ~eventを配送するときは、 その前に `paste$et ~event `CLIPBOARD-APIS$r を配送するモノトスル。 ◎ When an "insertFromPaste" beforeinput event is dispatched, it MUST be preceded by a paste [CLIPBOARD-APIS] event.
~security/~privacyの考慮点
◎非規範的既存の~event — `keydown$et や `keypress$et `UI-EVENTS$r など — を通して すでに可用な指紋収集~技法 `fingerprinting-guidance$r を超えるような、 この特能による[ ~security/~privacy ]に対する影響iとして既知なものは無い。 ◎ There are no known security or privacy impacts of this feature beyond fingerprinting [fingerprinting-guidance] techniques that already are available through existing events, such as the keydown and keypress [UI-EVENTS] events.
この特能が既存の~eventを置換したなら、 そのような指紋収集~技法を衰退へ至らせ得る — この特能は、 利用者が`表出した意図n$を記録するが, そのために利用された特定0の~hardware種別は記録しないので。 ◎ If this feature replaces existing events, it MAY lead to a decline in available fingerprinting [fingerprinting-guidance] techniques, as users' intentions are recorded, and not the particular type of hardware they used to express this intention.