Accessibility/EditorBehaviourOnUserInput: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
 
(160 intermediate revisions by 3 users not shown)
Line 1: Line 1:
=Summary=
=Summary=


The article is aimed to propose editor behaviour on user input when control elements are contained in editable area. The start point of this proposal is the assumption that control elements inside of editable area should have normal behaviour as if they weren't inside the editable area. In other words, they should be operable with mouse and keyboard as usual. The point doesn't contradict with HTML 5 specification. However the specification doesn't address editable area behaviour in question. That was a reason to start the proposal.
==What this is all about==


The start point can be found not to be suitable for certain amount of web applications, for example, if a web application wants to provide the ability to edit control element content in WYSIWYG mode like to edit the button's label. This ability complicates requirements to the editor behaviour and therefore it is dropped from the initial consideration. This proposal is intended to provide sort of default behaviour and doesn't pretend to define unique one for all possible cases. Web application might want to change the behaviour somehow to meet their specific needs.
This article proposes a model for how a user edits and navigates within an editable area that might contain any kind of web page content like rich text, form controls, etc. It is based on the [[Accessibility/RichContentKeyboardBehaviour|keyboard navigation proposal]] and refines statements specific for page editing.


The most widespread use case of control elements inside of editable area is applications used to create design of web pages, i.e. used to build forms and web pages with form elements. The chosen start point shouldn't contradict with ideas of these applications. It allows to make these application to work in WYSIWYG mode, i.e. the user can always see how his page works without the usage of page preview modes. The main requirement of these application is an ability to drag'n'drop control elements within editable area, selection and clipboard operation with control elements. The proposed behaviour should allow this operation to be performed easy and additionally should make control elements operable.
The problem we want to address here is: there is no specification which defines the user interaction when form controls and other special elements of web page (referred as [[Accessibility/RichContentKeyboardBehaviour#Terminology|rich elements]]) are presented inside an editable area. Currently browser implementations vary and none are perfect; editable text mixed with rich elements is not fully accessible by keyboard and mouse.


The start point is major requirement because
The most widespread use case is applications used to design and create web pages, i.e. used to build forms and web pages with form elements. Some of these applications want to deal with stubs instead of real form elements, so that the form elements aren't interactive and are merely used to designate the location of specific form element within the page. Other applications might want to be WYSIWYG applications and provide interactive form elements so that the user always see how his page mock-up works.
# it allows to create WYSIWYG application to build forms
# it allows to use unformalized forms where the user can get advantages of work with controls and can edit the form on its demand the same time
# it allows AT users to work with controls as usually


The main goal of the proposal is to ensure control elements inside of editable area are accessible for any user and user experience to work with editable area won't be broken.
The other and more rarer case is when editable area with control elements is used as unformalized form where control elements are used to help to fill up the form however the user has an ability to remove the whole text including control elements and write his own version.


In this proposal, control elements are considered to be either HTML controls or ARIA controls. However the proposal is not restricted to HTML only, proposed ideas should work for other markup languages. Also it should be possible to spread out the rules applied to control elements on non editable areas inside of editable areas.
''Comment: I think we could ignore unformalized forms for v1.0 -- davidb''


=Suggestion=
''Comment (gaidukov): I propose to change term 'unformalized form' to "semi-structured form". There is generally accepted term "semi-structured data". Interactive approach will allow to create input forms which can generate semi-structured data. Some information about problem of input forms for semi-structured data can be found in
[http://blog.adriaandejonge.eu/2005/05/xforms-tutorial-part-1.html article "XForms tutorial part 1"]. ''


==Сontrol element is a word==
''Semi-structured data are widely used in clinical data. [http://iospress.metapress.com/content/dyp63xxvf93wje8u/fulltext.pdf The article] is described the problem of exchange and representation of clinical semi-structured data. Interactive approach allows to create input forms for convenient input of clinical documents which can be in [http://www.ncbi.nlm.nih.gov/pmc/articles/PMC1380194/ HL7 CDA R2 format].''
Control element should be treated as a special word. The boundaries of the word is the control itself, no whitespaces are used so that boundaries are virtual characters what aren't presented on the screen.
 
''Also interactive approach (semi-structured forms) can be used as input forms for [http://en.wikipedia.org/wiki/Semi-structured_interview semi-structured interview]. In forms like [http://www.scielo.org.co/img/revistas/prf/n10/n10a04a2.gif this paper form] controls (e.g. html:select or xf:select) with most common phrases can be placed into text fields. When user select a phrase from a control then the selected phrase can be coded. Coded phrases can be used for machine processing. In medicine semi-structured interviews are [http://www.sleepclinician.com/resources/ widely used].''
 
''In WinIE there is [http://msdn.microsoft.com/en-us/library/ms537833%28v=VS.85%29.aspx scriptable editing API] which support controls into contentEditable areas (e.g. oncontrolselect event). WebKit's team has [http://webkit.org/projects/editing/index.html plans] to support this API. Right now WinIE and Chrome (Safari and Opera I have not tested yet) are supported interactive approach. ''
 
''-- gaidukov''
 
The [http://www.w3.org/TR/html5/ HTML 5 specification] doesn't specifically address the issue of editable area behavior. However it's founded on the  assumption that rich elements inside an editable area should have the same behavior as they would if they weren't inside an editable area (see [http://www.w3.org/TR/html5/editing.html#user-editing-actions user editing actions] section). This seems to be confirmed by Ian Hickson on [http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2009-August/021680.html Whatwg list] and by Richard Schwerdtfeger on [http://lists.w3.org/Archives/Public/wai-xtech/2009Jul/0179.html WAI ARIA list].
 
However it ignores the case of form builder applications when they want to have stubs instead real control elements which is found unsuitable for their needs. This is a reason to propose two behavior models, allowing the user to switch between them.
 
==Interactive approach==
 
The start point of this approach is an assumption that rich elements inside an editable area should have the same behaviour as they would if they weren't inside an editable area. An editable area should thus behave similarly to regular caret navigation mode plus editing behaviour.
 
The start point allows to make form builder applications to work in WYSIWYG mode, in other words the user is able see how his page works without the usage of page preview modes. The main requirement of these applications is an ability to drag'n'drop control elements within editable area, select them and operate with them by clipboard. Therefore the proposed behaviour should allow to perform these operations easy and additionally to make these elements operable and accessible.
 
However the start point can be found not suitable for certain amount of web applications, for example, if a web application wants to provide an ability to edit control element content in WYSIWYG mode like to edit the button's label. This ability complicates requirements to the editor behaviour and therefore it is dropped from the initial consideration.
 
This proposal is intended to provide sort of default behaviour and doesn't pretend to define unique one for all possible cases. However the defined behaviour shouldn't make impossible to use the editor by these application and it is advisable for implementation the behaviour should be able to be overridden easy enough to meet their specific needs.
 
Note: while this describes a simple default behaviour, there is no reason rich elements can not be overridden with specialized navigation and editing behaviour on a case by case basis.
 
Shortly the start point allows
# to create WYSIWYG applications to build forms
# to use unformalized forms
# AT users to work with controls as usual
 
 
[gaidukov: If html editor is used stub approach for forms then interactive approach can be used as quick form preview. ]
 
==Stub approach==
All rich elements aren't focusable and included into navigation sequence. When the caret is between empty characters of the rich word or sentence then the rich element is called selected. Visually it might look a blue border around the element.
 
''Comment: I think the rich elements should be focusable but not interoperable; but I'm not sure -- davidb''
 
=Details=
==Navigation block==
Editable area is always [[Accessibility/RichContentKeyboardBehaviour#Navigation_blocks|navigation block]].


==Keyboard navigation==
==Keyboard navigation==
In the case of interactive approach if caret is inside an editable area then the editor is focused until the rich element is focused.
In the case of stub approach if caret is inside an editable area then the editor is focused.


===Navigation by words if editor is focused===
==Tab navigation==
If editor is focused, i.e. the caret position is somewhere in middle of the editable text, if the user navigates by words (ctrl + arrow key or alt + arrow depending on platform) and control element is encountered on the way then the control element should be skipped, i.e. the caret should be moved from the position before the control to the position after control, editor should stay focused.
;interactive approach:
If the editor is focused then pressing tab should insert '\t' character or its analogue or move the focus to the next element in the tab order (outside or inside an editable area) according to editor preferences or platform.


===Navigation by words if control is focused===
;stub approach:
If the control element is focused and the user navigates by words then
If the editor is focused then pressing tab should insert '\t' character or its used analogue or move the focus outside an editable area to the next tabable element depending on editor preferences or platform.
# caret position should be moved after the control element if no action can be performed on the control element on the pressed key
# otherwise the control's action should be invoked.


It's a rare case when control element has an action on the "navigate by words" keyboard combination. The example of such control is textbox containing several words. In this case the user should navigate to the last word of textbox and then leave the control, i.e. editor should take the focus and caret should be set immediately after the control.
==Keyboard interaction==


===Navigation by characters===
;interactive approach:
If the user navigates through editable area by characters and control element is encountered on the way then control should be focused. If the control element can't be focused (for example, when it's disabled) then control element is skipped from navigation sequence, i.e. editor should stay focused and caret should be moved to position after the control element.
The rich element behavior is the same on mouse input if the mouse isn't used to change the selection, i.e. if the user click on rich element and moves the mouse to extend the selection then element is not clicked, i.e. it doesn't get the focus but selected. The special case is in-text elements what aren't focused and click event handlers aren't invoked when the user clicks on.


If the control element is focused and the user navigates by characters then
;stub approach:
# editor should be focused and caret position should be set immediately after control element if no control action can be performed for the pressed key
The rich element isn't focusable or interactive.
# otherwise control action should be performed.


For example, if two buttons (HTML button) are placed after another
==Mouse selection==
When a mouse click is occurs on the rich element while the 'add-to-selection' modifier key is pressed (e.g. ctrl key) then the element is appended to the selection entirely, the element is not focused and no element's action is invoked. Note, this is applicable for in-text elements as well.


<pre>
;stub approach:
text<button>btn1</button><button>btn2</button>
The rich element isn't focusable or interactive. If the user clicks on the element then it's selected, i.e. the caret is put between empty characters.
</pre>


then right arrow key presses should traverse "text" by characters, then focus the 1st button, focus the editor and set caret position between buttons and then focus the 2nd button.
==Removing the selection from DOM==
The selection is removed from DOM by 'Del' or 'Backspace' keys (or their platform's equivalent) as usual.


===mouse interaction with control element===
If the rich element is selected then it's removed entirely along with its boundary characters. If the integral element is focused and 'Del' or 'Backspace' key is pressed and if there is no element's default action then the element is removed. Both 'Del' and 'Backspace' keys have the same meaning in this case.
Control element behaviour is the same on mouse input.


For example, if user clicks on combobox (HTML:select) then drop down list appears.
If the selected region contains part of a compound element's content but not the element itself then the selected element's content will be removed, the element is saved.


===keyboard interaction with control element===
==Drag'n'drop==
Control element behaviour is the same on keyboard input when control is focused and action can be performed. Otherwise editor rules are applied.  
An 'entirely' selected rich element is dragged from one place to another as an individual element. If one or more selected elements are part of a selected region then the region is dragged entirely along with (including) all selected elements.


For example, if textbox (HTML:input) is focused then arrow keys move through its text. If caret reaches the end of the text then editor takes the focus and caret position is set immediately after the textbox element. If listbox (HTML:select) is focused then up/down arrow keys change selected item, if the last listbox option is selected and arrow down key is pressed then editor takes the focus and caret is moved to the text or control element placed below the listbox control.
If a special content element is focused (in the case of interactive approach) then drag'n'drop operation is performed as usual. For example, if a textbox is focused and the user starts to drag some selected text from within the textbox then the text should be dragged only. As well in the case of focused compound element its selected content participates in drag'n'drop operation, not the element itself.
===tab navigation===
If control is focused then pressing tab should navigate to the next control in tab order. Next control in tab order can be placed either inside or outside of editable area.


For example, if editable area contains two buttons (HTML and ARIA buttons) and there is one button outside of editable area
Drag'n'drop operation can be performed by mouse or by keyboard. However keyboard shortcuts are under discussion still.


<pre>
==Clipboard operations==
<div contentEditable="true">
If a rich element is selected entirely then it can be copied into clipboard. Both its text representation and the element itself should be copied into clipboard as different mime types.
  Text<button>btn1</button>text<div role="button" tabindex="0">btn2</button>text
</div>
<button>btn3</button>
</pre>


and the 1st button is focused then pressing tab should move the focus to the 2nd button and then to the 3rd button.
If the rich element is focused (in the case of interactive approach) then clipboard operation works as usual.


===selection, drug'n'drop and clipboard===
If the rich element is pasted from clipboard into editable area then it is pasted as an element.
Control element should be selected entirely, its content doesn't participate in selection. Visually it might look like blue border around the control element. Control can be selected or added into selection by mouse or keyboard. If element is added into selection (for example, it is clicked when shift or ctrl key is pressed or shift + arrow keys are pressed) then element shouldn't be focused but selected.


Selected control element can be dragged from one place to another as individual element. If element is focused then drag'n'drop operation is performed as usual. For example, if textbox is focused and user starts to drag selected text of textbox then the text should be dragged only.
=Implementation notes=


If control is selected then it can be copied into clipboard. Both its text representation and control itself should be copied into clipboard as different mime types. If control element is focused then clipboard operation works as usual (if control wasn't inside of editable area).
===When no action can be performed on control===
This section is applicable to interactive approach only.


=Implementation notes=
When the rich element is focused and no action can be performed via keyboard then editor rules should be applied.


===editor rules are applied when no action can be performed on control===
The editor implementation should have the ability to check whether an action (interactivity) can be performed or not in order to accomplish this requirement. One possible approach is the element should prevent default action of an event (DOMEvent.preventDefault) if it performs an action on this event. If there is no action then the editor processes this event and performs editor's actions accordingly.
When control element is focused and no action can be performed on the pressed key then editor rules should be applied. Therefore editor should have the ability to check whether action can be performed or not to accomplish this requirement. The possible approach is control element should prevent default action of an event (nsIDOMEvent.preventDefault) if it performs an action on this event. If there is no control's action then editor processes this event and performs editor's actions accordingly.


===when is the given element a control?===
===When the element is compound===
Editor should have an ability to recognize if the given element is a control or not because it needs to skip it if it's not focusable and not allow to move caret into the content of control element. For example, if ARIA button is placed inside of editable area
The editor implementation should have the ability to recognize whether the element is rich element or not and whether the element is compound or not. This is needed to allow (or not allow) caret navigation into element's content. For example, if ARIA button is placed inside of editable area


<pre>
<pre>
Line 91: Line 120:
</pre>
</pre>


then editor should skip button from navigation sequence if user moves the caret by characters because the ARIA button is not focusable.
then editor should skip button from navigation sequence if user moves the caret by characters because the ARIA button is a control element and it's not focusable.
 
The editor implementation should have a map to accomplish this requirement, whereby the tag name can be used as a map 'key' for native markup elements, the role attribute value should be used for ARIA widgets, CSS display style should be used for any content it is applicable to.
 
''Comment: I think asking the editor to pay that kind of attention to the role attribute makes things more complicated and possibly fragile. Note DHTML widget authors are currently responsible for keyboard handling via JS. Specialize caret implementation based on role is pretty complicated. -- davidb''
 
The editor should be extensible to plug elements of markup languages not supported natively.
 
===Switching between editing modes===
The DOM document should provide an ability to switch the editing mode.
 
<pre>
document.editingMode [= value]
 
Return "interactive" if the document editing mode is interactive.
Otherwise it returns "stub". The default value is "interactive".
</pre>


Editor should have a map to know if the given element is control, so that tag name should be used as a map key for HTML, role attribute value should be used for ARIA widgets, CSS display style should be used for any content it is applicable to.
[davidb: or maybe "livecontrols" and "deadcontrols"?]

Latest revision as of 14:59, 11 June 2010

Summary

What this is all about

This article proposes a model for how a user edits and navigates within an editable area that might contain any kind of web page content like rich text, form controls, etc. It is based on the keyboard navigation proposal and refines statements specific for page editing.

The problem we want to address here is: there is no specification which defines the user interaction when form controls and other special elements of web page (referred as rich elements) are presented inside an editable area. Currently browser implementations vary and none are perfect; editable text mixed with rich elements is not fully accessible by keyboard and mouse.

The most widespread use case is applications used to design and create web pages, i.e. used to build forms and web pages with form elements. Some of these applications want to deal with stubs instead of real form elements, so that the form elements aren't interactive and are merely used to designate the location of specific form element within the page. Other applications might want to be WYSIWYG applications and provide interactive form elements so that the user always see how his page mock-up works.

The other and more rarer case is when editable area with control elements is used as unformalized form where control elements are used to help to fill up the form however the user has an ability to remove the whole text including control elements and write his own version.

Comment: I think we could ignore unformalized forms for v1.0 -- davidb

Comment (gaidukov): I propose to change term 'unformalized form' to "semi-structured form". There is generally accepted term "semi-structured data". Interactive approach will allow to create input forms which can generate semi-structured data. Some information about problem of input forms for semi-structured data can be found in article "XForms tutorial part 1".

Semi-structured data are widely used in clinical data. The article is described the problem of exchange and representation of clinical semi-structured data. Interactive approach allows to create input forms for convenient input of clinical documents which can be in HL7 CDA R2 format.

Also interactive approach (semi-structured forms) can be used as input forms for semi-structured interview. In forms like this paper form controls (e.g. html:select or xf:select) with most common phrases can be placed into text fields. When user select a phrase from a control then the selected phrase can be coded. Coded phrases can be used for machine processing. In medicine semi-structured interviews are widely used.

In WinIE there is scriptable editing API which support controls into contentEditable areas (e.g. oncontrolselect event). WebKit's team has plans to support this API. Right now WinIE and Chrome (Safari and Opera I have not tested yet) are supported interactive approach.

-- gaidukov

The HTML 5 specification doesn't specifically address the issue of editable area behavior. However it's founded on the assumption that rich elements inside an editable area should have the same behavior as they would if they weren't inside an editable area (see user editing actions section). This seems to be confirmed by Ian Hickson on Whatwg list and by Richard Schwerdtfeger on WAI ARIA list.

However it ignores the case of form builder applications when they want to have stubs instead real control elements which is found unsuitable for their needs. This is a reason to propose two behavior models, allowing the user to switch between them.

Interactive approach

The start point of this approach is an assumption that rich elements inside an editable area should have the same behaviour as they would if they weren't inside an editable area. An editable area should thus behave similarly to regular caret navigation mode plus editing behaviour.

The start point allows to make form builder applications to work in WYSIWYG mode, in other words the user is able see how his page works without the usage of page preview modes. The main requirement of these applications is an ability to drag'n'drop control elements within editable area, select them and operate with them by clipboard. Therefore the proposed behaviour should allow to perform these operations easy and additionally to make these elements operable and accessible.

However the start point can be found not suitable for certain amount of web applications, for example, if a web application wants to provide an ability to edit control element content in WYSIWYG mode like to edit the button's label. This ability complicates requirements to the editor behaviour and therefore it is dropped from the initial consideration.

This proposal is intended to provide sort of default behaviour and doesn't pretend to define unique one for all possible cases. However the defined behaviour shouldn't make impossible to use the editor by these application and it is advisable for implementation the behaviour should be able to be overridden easy enough to meet their specific needs.

Note: while this describes a simple default behaviour, there is no reason rich elements can not be overridden with specialized navigation and editing behaviour on a case by case basis.

Shortly the start point allows

  1. to create WYSIWYG applications to build forms
  2. to use unformalized forms
  3. AT users to work with controls as usual


[gaidukov: If html editor is used stub approach for forms then interactive approach can be used as quick form preview. ]

Stub approach

All rich elements aren't focusable and included into navigation sequence. When the caret is between empty characters of the rich word or sentence then the rich element is called selected. Visually it might look a blue border around the element.

Comment: I think the rich elements should be focusable but not interoperable; but I'm not sure -- davidb

Details

Navigation block

Editable area is always navigation block.

Keyboard navigation

In the case of interactive approach if caret is inside an editable area then the editor is focused until the rich element is focused.

In the case of stub approach if caret is inside an editable area then the editor is focused.

Tab navigation

interactive approach

If the editor is focused then pressing tab should insert '\t' character or its analogue or move the focus to the next element in the tab order (outside or inside an editable area) according to editor preferences or platform.

stub approach

If the editor is focused then pressing tab should insert '\t' character or its used analogue or move the focus outside an editable area to the next tabable element depending on editor preferences or platform.

Keyboard interaction

interactive approach

The rich element behavior is the same on mouse input if the mouse isn't used to change the selection, i.e. if the user click on rich element and moves the mouse to extend the selection then element is not clicked, i.e. it doesn't get the focus but selected. The special case is in-text elements what aren't focused and click event handlers aren't invoked when the user clicks on.

stub approach

The rich element isn't focusable or interactive.

Mouse selection

When a mouse click is occurs on the rich element while the 'add-to-selection' modifier key is pressed (e.g. ctrl key) then the element is appended to the selection entirely, the element is not focused and no element's action is invoked. Note, this is applicable for in-text elements as well.

stub approach

The rich element isn't focusable or interactive. If the user clicks on the element then it's selected, i.e. the caret is put between empty characters.

Removing the selection from DOM

The selection is removed from DOM by 'Del' or 'Backspace' keys (or their platform's equivalent) as usual.

If the rich element is selected then it's removed entirely along with its boundary characters. If the integral element is focused and 'Del' or 'Backspace' key is pressed and if there is no element's default action then the element is removed. Both 'Del' and 'Backspace' keys have the same meaning in this case.

If the selected region contains part of a compound element's content but not the element itself then the selected element's content will be removed, the element is saved.

Drag'n'drop

An 'entirely' selected rich element is dragged from one place to another as an individual element. If one or more selected elements are part of a selected region then the region is dragged entirely along with (including) all selected elements.

If a special content element is focused (in the case of interactive approach) then drag'n'drop operation is performed as usual. For example, if a textbox is focused and the user starts to drag some selected text from within the textbox then the text should be dragged only. As well in the case of focused compound element its selected content participates in drag'n'drop operation, not the element itself.

Drag'n'drop operation can be performed by mouse or by keyboard. However keyboard shortcuts are under discussion still.

Clipboard operations

If a rich element is selected entirely then it can be copied into clipboard. Both its text representation and the element itself should be copied into clipboard as different mime types.

If the rich element is focused (in the case of interactive approach) then clipboard operation works as usual.

If the rich element is pasted from clipboard into editable area then it is pasted as an element.

Implementation notes

When no action can be performed on control

This section is applicable to interactive approach only.

When the rich element is focused and no action can be performed via keyboard then editor rules should be applied.

The editor implementation should have the ability to check whether an action (interactivity) can be performed or not in order to accomplish this requirement. One possible approach is the element should prevent default action of an event (DOMEvent.preventDefault) if it performs an action on this event. If there is no action then the editor processes this event and performs editor's actions accordingly.

When the element is compound

The editor implementation should have the ability to recognize whether the element is rich element or not and whether the element is compound or not. This is needed to allow (or not allow) caret navigation into element's content. For example, if ARIA button is placed inside of editable area

text<div role="button">button</div>text

then editor should skip button from navigation sequence if user moves the caret by characters because the ARIA button is a control element and it's not focusable.

The editor implementation should have a map to accomplish this requirement, whereby the tag name can be used as a map 'key' for native markup elements, the role attribute value should be used for ARIA widgets, CSS display style should be used for any content it is applicable to.

Comment: I think asking the editor to pay that kind of attention to the role attribute makes things more complicated and possibly fragile. Note DHTML widget authors are currently responsible for keyboard handling via JS. Specialize caret implementation based on role is pretty complicated. -- davidb

The editor should be extensible to plug elements of markup languages not supported natively.

Switching between editing modes

The DOM document should provide an ability to switch the editing mode.

document.editingMode [= value]

Return "interactive" if the document editing mode is interactive.
Otherwise it returns "stub". The default value is "interactive".

[davidb: or maybe "livecontrols" and "deadcontrols"?]