Skip to content

Commit

Permalink
make IME input use Shadow DOM, relates to #34
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneswilm committed May 25, 2015
1 parent e0635a6 commit f2e0ac2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 46 deletions.
37 changes: 14 additions & 23 deletions contentEditableTyping.html
Original file line number Diff line number Diff line change
Expand Up @@ -235,33 +235,24 @@ <h4>Caret movement at the start of a <a>CE Typing
<section>
<h2>Text Node Editing</h2>

<p>The only type of change of content within a <a>CE Typing Node</a>
that is triggered directly by the browser is in all cases contained to
the change of the contents of a single text node. Such a change may
cause the movement of the caret as specified below.</p>
<p>When the user indicates that new content should be added to the <a>CE Typing Node</a>
in which the caret is currently place, no content is actually added,
but a corresponding `beforeInput` event is triggered.</p>

<section>
<h3>Adding of a character by means of a keypress on the
keyboard</h3>

<p>If a caret is currently present, and a character is entered via
a keyboard, a beforeInput event is triggered with attributes `data` to the character, `inputType` to `replaceText` and targetRange to the active `document.getSelection().getRangeAt(0);``.
Unless the event is canceled, the character is added to the <a>CE Typing Node</a> in
which the caret is currently placed, and the caret is placed beyond
the newly added character.</p>

<p>An input event is triggered on the <a>CE Typing Node</a>.</p>
<h3>Adding characters by means of composition/IME</h3>

<p>If a caret is present, and composition of a character through IME is initiated,
composition visually is shown inline at the location of the caret.
The composition takes place within the Shadow DOM, using the <a>CE
Typing Node</a> as a shadow root, with no changes occuring at the DOM level.
When the composition of the character has finished, a beforeInput event is triggered
as if the character had been entered via the keyboard.</p>
<p>If the caret is in <a>overwrite</a>-mode at the time the character composition is
initiated, and the caret is not placed behind the last character within a
<a>CE Typing Node</a>, the character following the caret is hidden during composition.</p>
</section>

<section>
<h3>Adding a character by means of composition/IME</h3>

<p>If a caret is currently present, and composition of a character through IME or alike is initiated,
composition visually takes place inline. However, the inline composition takes place within the Shadow DOM with no changes occuring in the DOM and only when composition has finished,
the final character is inserted into the <a>CE Typing Node</a> as if it had been entered via the keyboard.</p>
</section>


<section>
<h3>Removal of content</h3>

Expand Down
24 changes: 1 addition & 23 deletions input-events.html
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ <h4>Input Event Order</h4>
</tr>
<tr>
<th>Default action</th>
<td>Update the DOM according to the <a href="#default-action-for-beforeinput">algorithms below</a>.</td>
<td>None</td>
</tr>
<tr>
<th>Context<br/>(trusted events)</th>
Expand Down Expand Up @@ -378,28 +378,6 @@ <h4>Input Events During Composition</h4>
event will still fire).</p>

</section> <!-- events-composition-event-input-events -->

<section>
<h2>Default action for beforeInput</h2>
<p>The default action of a given beforeinput event in an element with a given value of contentEditable is given below. Note that if the value of contentEditable is false,
there should be no beforeInput event at all, so there this algorithm does not need to include that possibility.
</p>
<p>
<ol><li>If the value of contentEditable is "true" or "plaintext-only", the behavior is undefined. Abort these steps.
</li><li>If the value of cotentEditable is "typing", the default behavior shall be as follows:
<ol><li>If the inputType="replaceText", perform the following steps:
<ol><li>Let targetStartContainer be targetRange.startContainer
</li><li>If targetStartContainer is not a text node, abort these steps.
</li><li>If targetRange.endContainer is not equal to targetStartContainer, abort these steps.
</li><li>Remove the text in targetRange from the document and collapse targetRange
</li><li>Insert data as plain text at the location of targetRange in the document
</li></ol>
</li></ol>
</li><li>If the inputType is any other value, there is no default behavior. Abort these steps.
</li></ol>
</li></ol>
</p>
</section>
<section>
<h2>Acknowledgements</h2>
</section>
Expand Down

0 comments on commit f2e0ac2

Please sign in to comment.