{"version":3,"sources":["webpack:///./node_modules/@ckeditor/ckeditor5-typing/src/typing.js","webpack:///./node_modules/@ckeditor/ckeditor5-typing/src/twostepcaretmovement.js"],"names":["Typing","Input","Delete","Plugin","TwoStepCaretMovement","editor","_this","Object","D_Projects_UA_repo_Source_Client_UA_User_Web_node_modules_babel_runtime_helpers_esm_classCallCheck_js__WEBPACK_IMPORTED_MODULE_9__","this","_super","call","attributes","Set","_overrideUid","_this2","model","view","editing","locale","modelSelection","document","selection","listenTo","evt","data","isCollapsed","shiftKey","altKey","ctrlKey","arrowRightPressed","keyCode","keyCodes","arrowright","arrowLeftPressed","arrowleft","contentDirection","contentLanguageDirection","isMovementHandled","_handleForwardMovement","_handleBackwardMovement","stop","context","priority","_isNextGravityRestorationSkipped","_isGravityOverridden","directChange","isBetweenDifferentAttributes","getFirstPosition","_restoreGravity","attribute","add","position","isAtStart","hasAnyAttribute","preventCaretMovement","_overrideGravity","setSelectionAttributesFromTheNodeBefore","isStepAfterAnyAttributeBoundary","isAtEnd","change","writer","overrideSelectionGravity","_this3","restoreSelectionGravity","_step","_iterator","_createForOfIteratorHelper","s","n","done","observedAttribute","value","hasAttribute","err","e","f","nodeBefore","setSelectionAttribute","getAttributes","removeSelectionAttribute","preventDefault","positionBefore","getShiftedBy","_step2","nodeAfter","_iterator2","attrBefore","getAttribute","undefined","attrAfter"],"mappings":";;;;OAqBqBA,kKACpB,WACC,OAASC,OAAOC,gCAMjB,WACC,MAAO,gBAT2BC;;;;OCmFfC,6CAWpB,SAAAA,EAAaC,GAAS,IAAAC,EAAA,OAAAC,OAAAC,EAAA,KAAAD,CAAAE,KAAAL,GACrBE,EAAAI,EAAAC,KAAAF,KAAOJ,GAQPC,EAAKM,WAAa,IAAIC,IAStBP,EAAKQ,aAAe,KAlBCR,6CAwBtB,WAAO,IAAAS,EAAAN,KACAJ,EAASI,KAAKJ,OACdW,EAAQX,EAAOW,MACfC,EAAOZ,EAAOa,QAAQD,KACtBE,EAASd,EAAOc,OA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A1ByB,WAAYQ,EAAcjC,EAAdiC,UADyCC,EAAAnB,EAE5BvD,GAF4B,IAE7D,IAAA0E,EAAAlB,MAAAgB,EAAAE,EAAAjB,KAAAC,MAA8C,KAAlCC,EAAkCa,EAAAZ,MACvCe,EAAaV,EAAaA,EAAWW,aAAcjB,QAAsBkB,EACzEC,EAAYL,EAAYA,EAAUG,aAAcjB,QAAsBkB,EAE5E,GAAKC,IAAcH,EAClB,OAAO,GAPoD,MAAAb,GAAAY,EAAAX,EAAAD,GAAA,QAAAY,EAAAV,IAU7D,OAAO","file":"js/chunk-4b08224b.a6657d1f.js","sourcesContent":["/**\n * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/**\n * @module typing/typing\n */\n\nimport Plugin from '@ckeditor/ckeditor5-core/src/plugin';\nimport Input from './input';\nimport Delete from './delete';\n\n/**\n * The typing feature. It handles typing.\n *\n * This is a \"glue\" plugin which loads the {@link module:typing/input~Input} and {@link module:typing/delete~Delete}\n * plugins.\n *\n * @extends module:core/plugin~Plugin\n */\nexport default class Typing extends Plugin {\n\tstatic get requires() {\n\t\treturn [ Input, Delete ];\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tstatic get pluginName() {\n\t\treturn 'Typing';\n\t}\n}\n\n/**\n * The configuration of the typing features. Used by the features from the `@ckeditor/ckeditor5-typing` package.\n *\n * Read more in {@link module:typing/typing~TypingConfig}.\n *\n * @member {module:typing/typing~TypingConfig} module:core/editor/editorconfig~EditorConfig#typing\n */\n\n/**\n * The configuration of the typing features. Used by the typing features in `@ckeditor/ckeditor5-typing` package.\n *\n *\t\tClassicEditor\n *\t\t\t.create( editorElement, {\n * \t\t\t\ttyping: ... // Typing feature options.\n *\t\t\t} )\n *\t\t\t.then( ... )\n *\t\t\t.catch( ... );\n *\n * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.\n *\n * @interface TypingConfig\n */\n\n/**\n * The granularity of undo/redo for typing and deleting. The value `20` means (more or less) that a new undo step\n * is created every 20 characters are inserted or deleted.\n *\n * @member {Number} [module:typing/typing~TypingConfig#undoStep=20]\n */\n","/**\n * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/**\n * @module typing/twostepcaretmovement\n */\n\nimport Plugin from '@ckeditor/ckeditor5-core/src/plugin';\n\nimport { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard';\n\n/**\n * This plugin enables the two-step caret (phantom) movement behavior for\n * {@link module:typing/twostepcaretmovement~TwoStepCaretMovement#registerAttribute registered attributes}\n * on arrow right () and left () key press.\n *\n * Thanks to this (phantom) caret movement the user is able to type before/after as well as at the\n * beginning/end of an attribute.\n *\n * **Note:** This plugin support right–to–left (Arabic, Hebrew, etc.) content by mirroring its behavior\n * but for the sake of simplicity examples showcase only left–to–right use–cases.\n *\n * # Forward movement\n *\n * ## \"Entering\" an attribute:\n *\n * When this plugin is enabled and registered for the `a` attribute and the selection is right before it\n * (at the attribute boundary), pressing the right arrow key will not move the selection but update its\n * attributes accordingly:\n *\n * * When enabled:\n *\n * \t\tfoo{}<$text a=\"true\">bar\n *\n * \n *\n * \t\tfoo<$text a=\"true\">{}bar\n *\n * * When disabled:\n *\n * \t\tfoo{}<$text a=\"true\">bar\n *\n * \n *\n * \t\tfoo<$text a=\"true\">b{}ar\n *\n *\n * ## \"Leaving\" an attribute:\n *\n * * When enabled:\n *\n * \t\t<$text a=\"true\">bar{}baz\n *\n * \n *\n * \t\t<$text a=\"true\">bar{}baz\n *\n * * When disabled:\n *\n * \t\t<$text a=\"true\">bar{}baz\n *\n * \n *\n * \t\t<$text a=\"true\">barb{}az\n *\n * # Backward movement\n *\n * * When enabled:\n *\n * \t\t<$text a=\"true\">bar{}baz\n *\n * \n *\n * \t\t<$text a=\"true\">bar{}baz\n *\n * * When disabled:\n *\n * \t\t<$text a=\"true\">bar{}baz\n *\n * \n *\n * \t\t<$text a=\"true\">ba{}rb{}az\n *\n * # Multiple attributes\n *\n * * When enabled and many attributes starts or ends at the same position:\n *\n * \t\t<$text a=\"true\" b=\"true\">bar{}baz\n *\n * \n *\n * \t\t<$text a=\"true\" b=\"true\">bar{}baz\n *\n * * When enabled and one procedes another:\n *\n * \t\t<$text a=\"true\">bar<$text b=\"true\">{}bar\n *\n * \n *\n * \t\t<$text a=\"true\">bar{}<$text b=\"true\">bar\n *\n */\nexport default class TwoStepCaretMovement extends Plugin {\n\t/**\n\t * @inheritDoc\n\t */\n\tstatic get pluginName() {\n\t\treturn 'TwoStepCaretMovement';\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tconstructor( editor ) {\n\t\tsuper( editor );\n\n\t\t/**\n\t\t * A set of attributes to handle.\n\t\t *\n\t\t * @protected\n\t\t * @property {module:typing/twostepcaretmovement~TwoStepCaretMovement}\n\t\t */\n\t\tthis.attributes = new Set();\n\n\t\t/**\n\t\t * The current UID of the overridden gravity, as returned by\n\t\t * {@link module:engine/model/writer~Writer#overrideSelectionGravity}.\n\t\t *\n\t\t * @private\n\t\t * @member {String}\n\t\t */\n\t\tthis._overrideUid = null;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tinit() {\n\t\tconst editor = this.editor;\n\t\tconst model = editor.model;\n\t\tconst view = editor.editing.view;\n\t\tconst locale = editor.locale;\n\n\t\tconst modelSelection = model.document.selection;\n\n\t\t// Listen to keyboard events and handle the caret movement according to the 2-step caret logic.\n\t\tthis.listenTo( view.document, 'arrowKey', ( evt, data ) => {\n\t\t\t// This implementation works only for collapsed selection.\n\t\t\tif ( !modelSelection.isCollapsed ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// When user tries to expand the selection or jump over the whole word or to the beginning/end then\n\t\t\t// two-steps movement is not necessary.\n\t\t\tif ( data.shiftKey || data.altKey || data.ctrlKey ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst arrowRightPressed = data.keyCode == keyCodes.arrowright;\n\t\t\tconst arrowLeftPressed = data.keyCode == keyCodes.arrowleft;\n\n\t\t\t// When neither left or right arrow has been pressed then do noting.\n\t\t\tif ( !arrowRightPressed && !arrowLeftPressed ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst contentDirection = locale.contentLanguageDirection;\n\t\t\tlet isMovementHandled = false;\n\n\t\t\tif ( ( contentDirection === 'ltr' && arrowRightPressed ) || ( contentDirection === 'rtl' && arrowLeftPressed ) ) {\n\t\t\t\tisMovementHandled = this._handleForwardMovement( data );\n\t\t\t} else {\n\t\t\t\tisMovementHandled = this._handleBackwardMovement( data );\n\t\t\t}\n\n\t\t\t// Stop the keydown event if the two-step caret movement handled it. Avoid collisions\n\t\t\t// with other features which may also take over the caret movement (e.g. Widget).\n\t\t\tif ( isMovementHandled === true ) {\n\t\t\t\tevt.stop();\n\t\t\t}\n\t\t}, { context: '$text', priority: 'highest' } );\n\n\t\t/**\n\t\t * A flag indicating that the automatic gravity restoration should not happen upon the next\n\t\t * gravity restoration.\n\t\t * {@link module:engine/model/selection~Selection#event:change:range} event.\n\t\t *\n\t\t * @private\n\t\t * @member {String}\n\t\t */\n\t\tthis._isNextGravityRestorationSkipped = false;\n\n\t\t// The automatic gravity restoration logic.\n\t\tthis.listenTo( modelSelection, 'change:range', ( evt, data ) => {\n\t\t\t// Skipping the automatic restoration is needed if the selection should change\n\t\t\t// but the gravity must remain overridden afterwards. See the #handleBackwardMovement\n\t\t\t// to learn more.\n\t\t\tif ( this._isNextGravityRestorationSkipped ) {\n\t\t\t\tthis._isNextGravityRestorationSkipped = false;\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Skip automatic restore when the gravity is not overridden — simply, there's nothing to restore\n\t\t\t// at this moment.\n\t\t\tif ( !this._isGravityOverridden ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Skip automatic restore when the change is indirect AND the selection is at the attribute boundary.\n\t\t\t// It means that e.g. if the change was external (collaboration) and the user had their\n\t\t\t// selection around the link, its gravity should remain intact in this change:range event.\n\t\t\tif ( !data.directChange && isBetweenDifferentAttributes( modelSelection.getFirstPosition(), this.attributes ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis._restoreGravity();\n\t\t} );\n\t}\n\n\t/**\n\t * Registers a given attribute for the two-step caret movement.\n\t *\n\t * @param {String} attribute Name of the attribute to handle.\n\t */\n\tregisterAttribute( attribute ) {\n\t\tthis.attributes.add( attribute );\n\t}\n\n\t/**\n\t * Updates the document selection and the view according to the two–step caret movement state\n\t * when moving **forwards**. Executed upon `keypress` in the {@link module:engine/view/view~View}.\n\t *\n\t * @private\n\t * @param {module:engine/view/observer/domeventdata~DomEventData} data Data of the key press.\n\t * @returns {Boolean} `true` when the handler prevented caret movement\n\t */\n\t_handleForwardMovement( data ) {\n\t\tconst attributes = this.attributes;\n\t\tconst model = this.editor.model;\n\t\tconst selection = model.document.selection;\n\t\tconst position = selection.getFirstPosition();\n\t\t// DON'T ENGAGE 2-SCM if gravity is already overridden. It means that we just entered\n\t\t//\n\t\t// \t\tfoo<$text attribute>{}barbaz\n\t\t//\n\t\t// or left the attribute\n\t\t//\n\t\t// \t\tfoo<$text attribute>bar{}baz\n\t\t//\n\t\t// and the gravity will be restored automatically.\n\t\tif ( this._isGravityOverridden ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// DON'T ENGAGE 2-SCM when the selection is at the beginning of the block AND already has the\n\t\t// attribute:\n\t\t// * when the selection was initially set there using the mouse,\n\t\t// * when the editor has just started\n\t\t//\n\t\t//\t\t<$text attribute>{}barbaz\n\t\t//\n\t\tif ( position.isAtStart && hasAnyAttribute( selection, attributes ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// ENGAGE 2-SCM When at least one of the observed attributes changes its value (incl. starts, ends).\n\t\t//\n\t\t//\t\tfoo<$text attribute>bar{}baz\n\t\t//\t\tfoo<$text attribute>bar{}<$text otherAttribute>baz\n\t\t//\t\tfoo<$text attribute=1>bar{}<$text attribute=2>baz\n\t\t//\t\tfoo{}<$text attribute>barbaz\n\t\t//\n\t\tif ( isBetweenDifferentAttributes( position, attributes ) ) {\n\t\t\tpreventCaretMovement( data );\n\t\t\tthis._overrideGravity();\n\t\t\treturn true;\n\t\t}\n\t}\n\n\t/**\n\t * Updates the document selection and the view according to the two–step caret movement state\n\t * when moving **backwards**. Executed upon `keypress` in the {@link module:engine/view/view~View}.\n\t *\n\t * @private\n\t * @param {module:engine/view/observer/domeventdata~DomEventData} data Data of the key press.\n\t * @returns {Boolean} `true` when the handler prevented caret movement\n\t */\n\t_handleBackwardMovement( data ) {\n\t\tconst attributes = this.attributes;\n\t\tconst model = this.editor.model;\n\t\tconst selection = model.document.selection;\n\t\tconst position = selection.getFirstPosition();\n\n\t\t// When the gravity is already overridden (by this plugin), it means we are on the two-step position.\n\t\t// Prevent the movement, restore the gravity and update selection attributes.\n\t\t//\n\t\t//\t\tfoo<$text attribute=1>bar<$text attribute=2>{}baz\n\t\t//\t\tfoo<$text attribute>bar<$text otherAttribute>{}baz\n\t\t//\t\tfoo<$text attribute>{}barbaz\n\t\t//\t\tfoo<$text attribute>bar{}baz\n\t\t//\n\t\tif ( this._isGravityOverridden ) {\n\t\t\tpreventCaretMovement( data );\n\t\t\tthis._restoreGravity();\n\t\t\tsetSelectionAttributesFromTheNodeBefore( model, attributes, position );\n\n\t\t\treturn true;\n\t\t} else {\n\t\t\t// REMOVE SELECTION ATTRIBUTE when restoring gravity towards a non-existent content at the\n\t\t\t// beginning of the block.\n\t\t\t//\n\t\t\t// \t\t{}<$text attribute>bar\n\t\t\t//\n\t\t\tif ( position.isAtStart ) {\n\t\t\t\tif ( hasAnyAttribute( selection, attributes ) ) {\n\t\t\t\t\tpreventCaretMovement( data );\n\t\t\t\t\tsetSelectionAttributesFromTheNodeBefore( model, attributes, position );\n\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// When we are moving from natural gravity, to the position of the 2SCM, we need to override the gravity,\n\t\t\t// and make sure it won't be restored. Unless it's at the end of the block and an observed attribute.\n\t\t\t// We need to check if the caret is a one position before the attribute boundary:\n\t\t\t//\n\t\t\t//\t\tfoo<$text attribute=1>bar<$text attribute=2>b{}az\n\t\t\t//\t\tfoo<$text attribute>bar<$text otherAttribute>b{}az\n\t\t\t//\t\tfoo<$text attribute>b{}arbaz\n\t\t\t//\t\tfoo<$text attribute>barb{}az\n\t\t\t//\n\t\t\tif ( isStepAfterAnyAttributeBoundary( position, attributes ) ) {\n\t\t\t\t// ENGAGE 2-SCM if the selection has no attribute. This may happen when the user\n\t\t\t\t// left the attribute using a FORWARD 2-SCM.\n\t\t\t\t//\n\t\t\t\t// \t\t<$text attribute>bar{}\n\t\t\t\t//\n\t\t\t\tif (\n\t\t\t\t\tposition.isAtEnd &&\n\t\t\t\t\t!hasAnyAttribute( selection, attributes ) &&\n\t\t\t\t\tisBetweenDifferentAttributes( position, attributes )\n\t\t\t\t) {\n\t\t\t\t\tpreventCaretMovement( data );\n\t\t\t\t\tsetSelectionAttributesFromTheNodeBefore( model, attributes, position );\n\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\t// Skip the automatic gravity restore upon the next selection#change:range event.\n\t\t\t\t// If not skipped, it would automatically restore the gravity, which should remain\n\t\t\t\t// overridden.\n\t\t\t\tthis._isNextGravityRestorationSkipped = true;\n\t\t\t\tthis._overrideGravity();\n\n\t\t\t\t// Don't return \"true\" here because we didn't call _preventCaretMovement.\n\t\t\t\t// Returning here will destabilize the filler logic, which also listens to\n\t\t\t\t// keydown (and the event would be stopped).\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * `true` when the gravity is overridden for the plugin.\n\t *\n\t * @readonly\n\t * @private\n\t * @type {Boolean}\n\t */\n\tget _isGravityOverridden() {\n\t\treturn !!this._overrideUid;\n\t}\n\n\t/**\n\t * Overrides the gravity using the {@link module:engine/model/writer~Writer model writer}\n\t * and stores the information about this fact in the {@link #_overrideUid}.\n\t *\n\t * A shorthand for {@link module:engine/model/writer~Writer#overrideSelectionGravity}.\n\t *\n\t * @private\n\t */\n\t_overrideGravity() {\n\t\tthis._overrideUid = this.editor.model.change( writer => {\n\t\t\treturn writer.overrideSelectionGravity();\n\t\t} );\n\t}\n\n\t/**\n\t * Restores the gravity using the {@link module:engine/model/writer~Writer model writer}.\n\t *\n\t * A shorthand for {@link module:engine/model/writer~Writer#restoreSelectionGravity}.\n\t *\n\t * @private\n\t */\n\t_restoreGravity() {\n\t\tthis.editor.model.change( writer => {\n\t\t\twriter.restoreSelectionGravity( this._overrideUid );\n\t\t\tthis._overrideUid = null;\n\t\t} );\n\t}\n}\n\n// Checks whether the selection has any of given attributes.\n//\n// @param {module:engine/model/documentselection~DocumentSelection} selection\n// @param {Iterable.} attributes\nfunction hasAnyAttribute( selection, attributes ) {\n\tfor ( const observedAttribute of attributes ) {\n\t\tif ( selection.hasAttribute( observedAttribute ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n// Applies the given attributes to the current selection using using the\n// values from the node before the current position. Uses\n// the {@link module:engine/model/writer~Writer model writer}.\n//\n// @param {module:engine/model/model~Model}\n// @param {Iterable.} attributess\n// @param {module:engine/model/position~Position} position\nfunction setSelectionAttributesFromTheNodeBefore( model, attributes, position ) {\n\tconst nodeBefore = position.nodeBefore;\n\tmodel.change( writer => {\n\t\tif ( nodeBefore ) {\n\t\t\twriter.setSelectionAttribute( nodeBefore.getAttributes() );\n\t\t} else {\n\t\t\twriter.removeSelectionAttribute( attributes );\n\t\t}\n\t} );\n}\n\n// Prevents the caret movement in the view by calling `preventDefault` on the event data.\n//\n// @alias data.preventDefault\nfunction preventCaretMovement( data ) {\n\tdata.preventDefault();\n}\n\n// Checks whether the step before `isBetweenDifferentAttributes()`.\n//\n// @param {module:engine/model/position~Position} position\n// @param {String} attribute\nfunction isStepAfterAnyAttributeBoundary( position, attributes ) {\n\tconst positionBefore = position.getShiftedBy( -1 );\n\treturn isBetweenDifferentAttributes( positionBefore, attributes );\n}\n\n// Checks whether the given position is between different values of given attributes.\n//\n// @param {module:engine/model/position~Position} position\n// @param {Iterable.} attributes\nfunction isBetweenDifferentAttributes( position, attributes ) {\n\tconst { nodeBefore, nodeAfter } = position;\n\tfor ( const observedAttribute of attributes ) {\n\t\tconst attrBefore = nodeBefore ? nodeBefore.getAttribute( observedAttribute ) : undefined;\n\t\tconst attrAfter = nodeAfter ? nodeAfter.getAttribute( observedAttribute ) : undefined;\n\n\t\tif ( attrAfter !== attrBefore ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n"],"sourceRoot":""}