Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7396980
ve.ce.LinearTabKeyDownHandler.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
ve.ce.LinearTabKeyDownHandler.js
View Options
/*!
* VisualEditor ContentEditable linear escape key down handler
*
* @copyright See AUTHORS.txt
*/
/* istanbul ignore next */
/**
* Tab key down handler for linear selections.
*
* @class
* @extends ve.ce.KeyDownHandler
*
* @constructor
*/
ve
.
ce
.
LinearTabKeyDownHandler
=
function
VeCeLinearTabKeyDownHandler
()
{
// Parent constructor - never called because class is fully static
// ve.ui.LinearTabKeyDownHandler.super.apply( this, arguments );
};
/* Inheritance */
OO
.
inheritClass
(
ve
.
ce
.
LinearTabKeyDownHandler
,
ve
.
ce
.
KeyDownHandler
);
/* Static properties */
ve
.
ce
.
LinearTabKeyDownHandler
.
static
.
name
=
'linearTab'
;
ve
.
ce
.
LinearTabKeyDownHandler
.
static
.
keys
=
[
OO
.
ui
.
Keys
.
TAB
];
ve
.
ce
.
LinearTabKeyDownHandler
.
static
.
supportedSelections
=
[
'linear'
];
/* Static methods */
/**
* Handle tab key down events with a linear selection while table editing.
*
* @inheritdoc
*/
ve
.
ce
.
LinearTabKeyDownHandler
.
static
.
execute
=
function
(
surface
,
e
)
{
const
activeTableNode
=
surface
.
getActiveNode
()
&&
surface
.
getActiveNode
().
findParent
(
ve
.
ce
.
TableNode
),
activeTableCaptionNode
=
surface
.
getActiveNode
()
&&
surface
.
getActiveNode
().
findParent
(
ve
.
ce
.
TableCaptionNode
),
documentModel
=
surface
.
getModel
().
getDocument
();
// Check we have an active table node
if
(
activeTableNode
)
{
if
(
e
.
ctrlKey
||
e
.
altKey
||
e
.
metaKey
)
{
// Support: Firefox
// In Firefox, ctrl-tab to switch browser-tabs still triggers the
// keydown event.
return
;
}
if
(
activeTableNode
.
editingFragment
)
{
// we are inside a cell (editingFragment), and not just a caption
e
.
preventDefault
();
e
.
stopPropagation
();
activeTableNode
.
setEditing
(
false
);
// If this was a merged cell, we're going to have unexpected behavior when the selection moves,
// so preemptively collapse to the top-left point of the merged cell.
surface
.
getModel
().
setSelection
(
surface
.
getModel
().
getSelection
().
collapseToStart
()
);
ve
.
ce
.
TableArrowKeyDownHandler
.
static
.
moveTableSelection
(
surface
,
0
,
// Rows
e
.
shiftKey
?
-
1
:
1
,
// Columns
false
,
// Logical direction, not visual
false
,
// Don't expand the current selection,
true
// Wrap to next/previous row
);
if
(
surface
.
getModel
().
getSelection
()
instanceof
ve
.
dm
.
TableSelection
)
{
// Might have moved off the table and into the caption
activeTableNode
.
setEditing
(
true
);
}
return
true
;
}
else
if
(
activeTableCaptionNode
)
{
// We're in a table caption
e
.
preventDefault
();
e
.
stopPropagation
();
if
(
e
.
shiftKey
)
{
// back out of the table
surface
.
getModel
().
setSelection
(
new
ve
.
dm
.
LinearSelection
(
documentModel
.
getRelativeRange
(
activeTableNode
.
getRange
(),
-
1
)
)
);
}
else
{
// move to the first cell
surface
.
getModel
().
setSelection
(
new
ve
.
dm
.
TableSelection
(
activeTableNode
.
getOuterRange
(),
0
,
0
)
);
}
return
true
;
}
}
return
false
;
};
/* Registration */
ve
.
ce
.
keyDownHandlerFactory
.
register
(
ve
.
ce
.
LinearTabKeyDownHandler
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 21, 14:26 (4 h, 11 m ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
11/22/276017488833eddab398e1bc366e
Default Alt Text
ve.ce.LinearTabKeyDownHandler.js (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment