{"version":3,"sources":["webpack:///./node_modules/@ckeditor/ckeditor5-clipboard/src/clipboard.js","webpack:///./node_modules/@ckeditor/ckeditor5-clipboard/src/datatransfer.js","webpack:///./node_modules/@ckeditor/ckeditor5-clipboard/src/clipboardobserver.js","webpack:///./node_modules/@ckeditor/ckeditor5-clipboard/src/clipboardpipeline.js"],"names":["Clipboard","ClipboardPipeline","DragDrop","PastePlainText","Plugin","DataTransfer","nativeDataTransfer","Object","classCallCheck","this","files","getFiles","_native","types","type","getData","data","setData","effectAllowed","value","dropEffect","mozUserCancelled","Array","from","items","length","filter","item","kind","map","getAsFile","ClipboardObserver","view","_this","_super","call","viewDocument","document","handleInput","evt","preventDefault","targetRanges","dropRange","eventInfo","EventInfo","fire","dataTransfer","method","name","target","stop","called","stopPropagation","domEventType","listenTo","priority","domEvent","evtData","clipboardData","getDropViewRange","DomEventObserver","domRange","domDoc","ownerDocument","x","clientX","y","clientY","caretRangeFromPoint","rangeParent","createRange","setStart","rangeOffset","collapse","domConverter","domRangeToView","editor","editing","addObserver","_setupPasteDrop","_setupCopyCut","model","isReadOnly","content","normalizeClipboardHtml","plainTextToHtml","htmlProcessor","toView","scrollToTheSelection","isEmpty","dataController","modelFragment","toModel","childCount","change","resultRange","insertContent","_this2","modelDocument","onCopyCut","getSelectedContent","selection","toData","viewToPlainText","deleteContent"],"mappings":";;;;OA2BqBA,oKAIpB,WACC,MAAO,kCAMR,WACC,OAASC,OAAmBC,OAAUC,eAZDC,yLCflBC,kCACpB,SAAAA,EAAaC,GAAqBC,OAAAC,EAAA,KAAAD,CAAAE,KAAAJ,GAOjCI,KAAKC,MAAQC,EAAUL,GAQvBG,KAAKG,QAAUN,4CAQhB,WACC,OAAOG,KAAKG,QAAQC,6BAWrB,SAASC,GACR,OAAOL,KAAKG,QAAQG,QAASD,0BAS9B,SAASA,EAAME,GACdP,KAAKG,QAAQK,QAASH,EAAME,8BAY7B,WACC,OAAOP,KAAKG,QAAQM,mBALrB,SAAmBC,GAClBV,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ChDA,EAAKmE,QAAQM,UAClBzE,EAAK8B,aAAa7B,QAAS,YAAagF,EAAKrB,OAAO5D,KAAKsE,cAAcgB,OAAQtF,EAAKmE,UACpFnE,EAAK8B,aAAa7B,QAAS,aAAcsF,eAAiBvF,EAAKmE,WAG5C,OAAfnE,EAAK+B,QACT6B,EAAOK,MAAMuB,cAAeN,EAAcG,aAEvC9C,SAAU,kCAlJhB,WACC,MAAO,2BALsCnD","file":"js/chunk-179a1018.4ad1179f.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 clipboard/clipboard\n */\n\nimport Plugin from '@ckeditor/ckeditor5-core/src/plugin';\n\nimport ClipboardPipeline from './clipboardpipeline';\nimport DragDrop from './dragdrop';\nimport PastePlainText from './pasteplaintext';\n\n/**\n * The clipboard feature.\n *\n * Read more about the clipboard integration in the {@glink framework/guides/deep-dive/clipboard clipboard deep dive guide}.\n *\n * This is a \"glue\" plugin which loads the following plugins:\n * * {@link module:clipboard/clipboardpipeline~ClipboardPipeline}\n * * {@link module:clipboard/dragdrop~DragDrop}\n * * {@link module:clipboard/pasteplaintext~PastePlainText}\n *\n * @extends module:core/plugin~Plugin\n */\nexport default class Clipboard extends Plugin {\n\t/**\n\t * @inheritDoc\n\t */\n\tstatic get pluginName() {\n\t\treturn 'Clipboard';\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tstatic get requires() {\n\t\treturn [ ClipboardPipeline, DragDrop, PastePlainText ];\n\t}\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 clipboard/datatransfer\n */\n\n/**\n * A facade over the native [`DataTransfer`](https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer) object.\n */\nexport default class DataTransfer {\n\tconstructor( nativeDataTransfer ) {\n\t\t/**\n\t\t * The array of files created from the native `DataTransfer#files` or `DataTransfer#items`.\n\t\t *\n\t\t * @readonly\n\t\t * @member {Array.} #files\n\t\t */\n\t\tthis.files = getFiles( nativeDataTransfer );\n\n\t\t/**\n\t\t * The native DataTransfer object.\n\t\t *\n\t\t * @private\n\t\t * @member {DataTransfer} #_native\n\t\t */\n\t\tthis._native = nativeDataTransfer;\n\t}\n\n\t/**\n\t * Returns an array of available native content types.\n\t *\n\t * @returns {Array.}\n\t */\n\tget types() {\n\t\treturn this._native.types;\n\t}\n\n\t/**\n\t * Gets the data from the data transfer by its MIME type.\n\t *\n\t *\t\tdataTransfer.getData( 'text/plain' );\n\t *\n\t * @param {String} type The MIME type. E.g. `text/html` or `text/plain`.\n\t * @returns {String}\n\t */\n\tgetData( type ) {\n\t\treturn this._native.getData( type );\n\t}\n\n\t/**\n\t * Sets the data in the data transfer.\n\t *\n\t * @param {String} type The MIME type. E.g. `text/html` or `text/plain`.\n\t * @param {String} data\n\t */\n\tsetData( type, data ) {\n\t\tthis._native.setData( type, data );\n\t}\n\n\t/**\n\t * The effect that is allowed for a drag operation.\n\t *\n\t * @param {String} value\n\t */\n\tset effectAllowed( value ) {\n\t\tthis._native.effectAllowed = value;\n\t}\n\n\tget effectAllowed() {\n\t\treturn this._native.effectAllowed;\n\t}\n\n\t/**\n\t * The actual drop effect.\n\t *\n\t * @param {String} value\n\t */\n\tset dropEffect( value ) {\n\t\tthis._native.dropEffect = value;\n\t}\n\n\tget dropEffect() {\n\t\treturn this._native.dropEffect;\n\t}\n\n\t/**\n\t * Whether the dragging operation was canceled.\n\t *\n\t * @returns {Boolean}\n\t */\n\tget isCanceled() {\n\t\treturn this._native.dropEffect == 'none' || !!this._native.mozUserCancelled;\n\t}\n}\n\nfunction getFiles( nativeDataTransfer ) {\n\t// DataTransfer.files and items are array-like and might not have an iterable interface.\n\tconst files = Array.from( nativeDataTransfer.files || [] );\n\tconst items = Array.from( nativeDataTransfer.items || [] );\n\n\tif ( files.length ) {\n\t\treturn files;\n\t}\n\n\t// Chrome has empty DataTransfer.files, but allows getting files through the items interface.\n\treturn items\n\t\t.filter( item => item.kind === 'file' )\n\t\t.map( item => item.getAsFile() );\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 clipboard/clipboardobserver\n */\n\nimport DomEventObserver from '@ckeditor/ckeditor5-engine/src/view/observer/domeventobserver';\nimport EventInfo from '@ckeditor/ckeditor5-utils/src/eventinfo';\nimport DataTransfer from './datatransfer';\n\n/**\n * Clipboard events observer.\n *\n * Fires the following events:\n *\n * * {@link module:engine/view/document~Document#event:clipboardInput},\n * * {@link module:engine/view/document~Document#event:paste},\n * * {@link module:engine/view/document~Document#event:copy},\n * * {@link module:engine/view/document~Document#event:cut},\n * * {@link module:engine/view/document~Document#event:drop},\n * * {@link module:engine/view/document~Document#event:dragover},\n * * {@link module:engine/view/document~Document#event:dragging},\n * * {@link module:engine/view/document~Document#event:dragstart},\n * * {@link module:engine/view/document~Document#event:dragend},\n * * {@link module:engine/view/document~Document#event:dragenter},\n * * {@link module:engine/view/document~Document#event:dragleave}.\n *\n * **Note**: This observer is not available by default (ckeditor5-engine does not add it on its own).\n * To make it available, it needs to be added to {@link module:engine/view/document~Document} by using\n * the {@link module:engine/view/view~View#addObserver `View#addObserver()`} method. Alternatively, you can load the\n * {@link module:clipboard/clipboard~Clipboard} plugin which adds this observer automatically (because it uses it).\n *\n * @extends module:engine/view/observer/domeventobserver~DomEventObserver\n */\nexport default class ClipboardObserver extends DomEventObserver {\n\tconstructor( view ) {\n\t\tsuper( view );\n\n\t\tconst viewDocument = this.document;\n\n\t\tthis.domEventType = [ 'paste', 'copy', 'cut', 'drop', 'dragover', 'dragstart', 'dragend', 'dragenter', 'dragleave' ];\n\n\t\tthis.listenTo( viewDocument, 'paste', handleInput( 'clipboardInput' ), { priority: 'low' } );\n\t\tthis.listenTo( viewDocument, 'drop', handleInput( 'clipboardInput' ), { priority: 'low' } );\n\t\tthis.listenTo( viewDocument, 'dragover', handleInput( 'dragging' ), { priority: 'low' } );\n\n\t\tfunction handleInput( type ) {\n\t\t\treturn ( evt, data ) => {\n\t\t\t\tdata.preventDefault();\n\n\t\t\t\tconst targetRanges = data.dropRange ? [ data.dropRange ] : null;\n\t\t\t\tconst eventInfo = new EventInfo( viewDocument, type );\n\n\t\t\t\tviewDocument.fire( eventInfo, {\n\t\t\t\t\tdataTransfer: data.dataTransfer,\n\t\t\t\t\tmethod: evt.name,\n\t\t\t\t\ttargetRanges,\n\t\t\t\t\ttarget: data.target\n\t\t\t\t} );\n\n\t\t\t\t// If CKEditor handled the input, do not bubble the original event any further.\n\t\t\t\t// This helps external integrations recognize that fact and act accordingly.\n\t\t\t\t// https://github.com/ckeditor/ckeditor5-upload/issues/92\n\t\t\t\tif ( eventInfo.stop.called ) {\n\t\t\t\t\tdata.stopPropagation();\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t}\n\n\tonDomEvent( domEvent ) {\n\t\tconst evtData = {\n\t\t\tdataTransfer: new DataTransfer( domEvent.clipboardData ? domEvent.clipboardData : domEvent.dataTransfer )\n\t\t};\n\n\t\tif ( domEvent.type == 'drop' || domEvent.type == 'dragover' ) {\n\t\t\tevtData.dropRange = getDropViewRange( this.view, domEvent );\n\t\t}\n\n\t\tthis.fire( domEvent.type, domEvent, evtData );\n\t}\n}\n\nfunction getDropViewRange( view, domEvent ) {\n\tconst domDoc = domEvent.target.ownerDocument;\n\tconst x = domEvent.clientX;\n\tconst y = domEvent.clientY;\n\tlet domRange;\n\n\t// Webkit & Blink.\n\tif ( domDoc.caretRangeFromPoint && domDoc.caretRangeFromPoint( x, y ) ) {\n\t\tdomRange = domDoc.caretRangeFromPoint( x, y );\n\t}\n\t// FF.\n\telse if ( domEvent.rangeParent ) {\n\t\tdomRange = domDoc.createRange();\n\t\tdomRange.setStart( domEvent.rangeParent, domEvent.rangeOffset );\n\t\tdomRange.collapse( true );\n\t}\n\n\tif ( domRange ) {\n\t\treturn view.domConverter.domRangeToView( domRange );\n\t}\n\n\treturn null;\n}\n\n/**\n * Fired as a continuation of the {@link #event:paste} and {@link #event:drop} events.\n *\n * It is a part of the {@glink framework/guides/deep-dive/clipboard#input-pipeline clipboard input pipeline}.\n *\n * This event carries a `dataTransfer` object which comes from the clipboard and whose content should be processed\n * and inserted into the editor.\n *\n * **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}\n * needs to be added to the {@link module:engine/view/document~Document} by using the {@link module:engine/view/view~View#addObserver}\n * method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,\n * the observer must be added manually.\n *\n * @see module:clipboard/clipboardobserver~ClipboardObserver\n * @see module:clipboard/clipboard~Clipboard\n * @event module:engine/view/document~Document#event:clipboardInput\n * @param {Object} data The event data.\n * @param {module:clipboard/datatransfer~DataTransfer} data.dataTransfer The data transfer instance.\n * @param {'paste'|'drop'} method Whether the event was triggered by a paste or drop operation.\n * @param {module:engine/view/element~Element} target The tree view element representing the target.\n * @param {Array.} data.targetRanges Ranges which are the target of the operation\n * (usually – into which the content should be inserted).\n * If the clipboard input was triggered by a paste operation, this property is not set. If by a drop operation,\n * then it is the drop position (which can be different than the selection at the moment of drop).\n */\n\n/**\n * Fired when the user drags the content over one of the editing roots of the editor.\n *\n * Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.\n *\n * **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}\n * needs to be added to the {@link module:engine/view/document~Document} by using the {@link module:engine/view/view~View#addObserver}\n * method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,\n * the observer must be added manually.\n *\n * @see module:engine/view/document~Document#event:clipboardInput\n * @event module:engine/view/document~Document#event:dragover\n * @param {module:clipboard/clipboardobserver~ClipboardEventData} data The event data.\n */\n\n/**\n * Fired when the user dropped the content into one of the editing roots of the editor.\n *\n * Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.\n *\n * **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}\n * needs to be added to the {@link module:engine/view/document~Document} by using the {@link module:engine/view/view~View#addObserver}\n * method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,\n * the observer must be added manually.\n *\n * @see module:engine/view/document~Document#event:clipboardInput\n * @event module:engine/view/document~Document#event:drop\n * @param {module:clipboard/clipboardobserver~ClipboardEventData} data The event data.\n * @param {module:engine/view/range~Range} dropRange The position into which the content is dropped.\n */\n\n/**\n * Fired when the user pasted the content into one of the editing roots of the editor.\n *\n * Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.\n *\n * **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}\n * needs to be added to the {@link module:engine/view/document~Document} by using the {@link module:engine/view/view~View#addObserver}\n * method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,\n * the observer must be added manually.\n *\n * @see module:engine/view/document~Document#event:clipboardInput\n * @event module:engine/view/document~Document#event:paste\n * @param {module:clipboard/clipboardobserver~ClipboardEventData} data The event data.\n */\n\n/**\n * Fired when the user copied the content from one of the editing roots of the editor.\n *\n * Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.\n *\n * **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}\n * needs to be added to the {@link module:engine/view/document~Document} by using the {@link module:engine/view/view~View#addObserver}\n * method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,\n * the observer must be added manually.\n *\n * @see module:clipboard/clipboardobserver~ClipboardObserver\n * @event module:engine/view/document~Document#event:copy\n * @param {module:clipboard/clipboardobserver~ClipboardEventData} data The event data.\n */\n\n/**\n * Fired when the user cut the content from one of the editing roots of the editor.\n *\n * Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.\n *\n * **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}\n * needs to be added to the {@link module:engine/view/document~Document} by using the {@link module:engine/view/view~View#addObserver}\n * method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,\n * the observer must be added manually.\n *\n * @see module:clipboard/clipboardobserver~ClipboardObserver\n * @event module:engine/view/document~Document#event:cut\n * @param {module:clipboard/clipboardobserver~ClipboardEventData} data The event data.\n */\n\n/**\n * The value of the {@link module:engine/view/document~Document#event:paste},\n * {@link module:engine/view/document~Document#event:copy} and {@link module:engine/view/document~Document#event:cut} events.\n *\n * In order to access the clipboard data, use the `dataTransfer` property.\n *\n * @class module:clipboard/clipboardobserver~ClipboardEventData\n * @extends module:engine/view/observer/domeventdata~DomEventData\n */\n\n/**\n * The data transfer instance.\n *\n * @readonly\n * @member {module:clipboard/datatransfer~DataTransfer} module:clipboard/clipboardobserver~ClipboardEventData#dataTransfer\n */\n\n/**\n * Fired as a continuation of the {@link #event:dragover} event.\n *\n * It is a part of the {@glink framework/guides/deep-dive/clipboard#input-pipeline clipboard input pipeline}.\n *\n * This event carries a `dataTransfer` object which comes from the clipboard and whose content should be processed\n * and inserted into the editor.\n *\n * **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}\n * needs to be added to the {@link module:engine/view/document~Document} by using the {@link module:engine/view/view~View#addObserver}\n * method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,\n * the observer must be added manually.\n *\n * @see module:clipboard/clipboardobserver~ClipboardObserver\n * @see module:clipboard/clipboard~Clipboard\n * @event module:engine/view/document~Document#event:dragging\n * @param {Object} data The event data.\n * @param {module:clipboard/datatransfer~DataTransfer} data.dataTransfer The data transfer instance.\n * @param {module:engine/view/element~Element} target The tree view element representing the target.\n * @param {Array.} data.targetRanges Ranges which are the target of the operation\n * (usually – into which the content should be inserted).\n * It is the drop position (which can be different than the selection at the moment of drop).\n */\n\n/**\n * Fired when the user starts dragging the content in one of the editing roots of the editor.\n *\n * Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.\n *\n * **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}\n * needs to be added to the {@link module:engine/view/document~Document} by using the {@link module:engine/view/view~View#addObserver}\n * method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,\n * the observer must be added manually.\n *\n * @see module:engine/view/document~Document#event:clipboardInput\n * @event module:engine/view/document~Document#event:dragstart\n * @param {module:clipboard/clipboardobserver~ClipboardEventData} data The event data.\n */\n\n/**\n * Fired when the user ended dragging the content.\n *\n * Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.\n *\n * **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}\n * needs to be added to the {@link module:engine/view/document~Document} by using the {@link module:engine/view/view~View#addObserver}\n * method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,\n * the observer must be added manually.\n *\n * @see module:engine/view/document~Document#event:clipboardInput\n * @event module:engine/view/document~Document#event:dragend\n * @param {module:clipboard/clipboardobserver~ClipboardEventData} data The event data.\n */\n\n/**\n * Fired when the user drags the content into one of the editing roots of the editor.\n *\n * Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.\n *\n * **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}\n * needs to be added to the {@link module:engine/view/document~Document} by using the {@link module:engine/view/view~View#addObserver}\n * method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,\n * the observer must be added manually.\n *\n * @see module:engine/view/document~Document#event:clipboardInput\n * @event module:engine/view/document~Document#event:dragenter\n * @param {module:clipboard/clipboardobserver~ClipboardEventData} data The event data.\n */\n\n/**\n * Fired when the user drags the content out of one of the editing roots of the editor.\n *\n * Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.\n *\n * **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}\n * needs to be added to the {@link module:engine/view/document~Document} by using the {@link module:engine/view/view~View#addObserver}\n * method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,\n * the observer must be added manually.\n *\n * @see module:engine/view/document~Document#event:clipboardInput\n * @event module:engine/view/document~Document#event:dragleave\n * @param {module:clipboard/clipboardobserver~ClipboardEventData} data The event data.\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 clipboard/clipboardpipeline\n */\n\nimport Plugin from '@ckeditor/ckeditor5-core/src/plugin';\nimport EventInfo from '@ckeditor/ckeditor5-utils/src/eventinfo';\n\nimport ClipboardObserver from './clipboardobserver';\n\nimport plainTextToHtml from './utils/plaintexttohtml';\nimport normalizeClipboardHtml from './utils/normalizeclipboarddata';\nimport viewToPlainText from './utils/viewtoplaintext.js';\n\n// Input pipeline events overview:\n//\n// ┌──────────────────────┐ ┌──────────────────────┐\n// │ view.Document │ │ view.Document │\n// │ paste │ │ drop │\n// └───────────┬──────────┘ └───────────┬──────────┘\n// │ │\n// └────────────────┌────────────────┘\n// │\n// ┌─────────V────────┐\n// │ view.Document │ Retrieves text/html or text/plain from data.dataTransfer\n// │ clipboardInput │ and processes it to view.DocumentFragment.\n// └─────────┬────────┘\n// │\n// ┌───────────V───────────┐\n// │ ClipboardPipeline │ Converts view.DocumentFragment to model.DocumentFragment.\n// │ inputTransformation │\n// └───────────┬───────────┘\n// │\n// ┌──────────V──────────┐\n// │ ClipboardPipeline │ Calls model.insertContent().\n// │ contentInsertion │\n// └─────────────────────┘\n//\n//\n// Output pipeline events overview:\n//\n// ┌──────────────────────┐ ┌──────────────────────┐\n// │ view.Document │ │ view.Document │ Retrieves the selected model.DocumentFragment\n// │ copy │ │ cut │ and converts it to view.DocumentFragment.\n// └───────────┬──────────┘ └───────────┬──────────┘\n// │ │\n// └────────────────┌────────────────┘\n// │\n// ┌─────────V────────┐\n// │ view.Document │ Processes view.DocumentFragment to text/html and text/plain\n// │ clipboardOutput │ and stores the results in data.dataTransfer.\n// └──────────────────┘\n//\n\n/**\n * The clipboard pipeline feature. It is responsible for intercepting the `paste` and `drop` events and\n * passing the pasted content through a series of events in order to insert it into the editor's content.\n * It also handles the `cut` and `copy` events to fill the native clipboard with the serialized editor's data.\n *\n * # Input pipeline\n *\n * The behavior of the default handlers (all at a `low` priority):\n *\n * ## Event: `paste` or `drop`\n *\n * 1. Translates the event data.\n * 2. Fires the {@link module:engine/view/document~Document#event:clipboardInput `view.Document#clipboardInput`} event.\n *\n * ## Event: `view.Document#clipboardInput`\n *\n * 1. If the `data.content` event field is already set (by some listener on a higher priority), it takes this content and fires the event\n * from the last point.\n * 2. Otherwise, it retrieves `text/html` or `text/plain` from `data.dataTransfer`.\n * 3. Normalizes the raw data by applying simple filters on string data.\n * 4. Processes the raw data to {@link module:engine/view/documentfragment~DocumentFragment `view.DocumentFragment`} with the\n * {@link module:engine/controller/datacontroller~DataController#htmlProcessor `DataController#htmlProcessor`}.\n * 5. Fires the {@link module:clipboard/clipboardpipeline~ClipboardPipeline#event:inputTransformation\n * `ClipboardPipeline#inputTransformation`} event with the view document fragment in the `data.content` event field.\n *\n * ## Event: `ClipboardPipeline#inputTransformation`\n *\n * 1. Converts {@link module:engine/view/documentfragment~DocumentFragment `view.DocumentFragment`} from the `data.content` field to\n * {@link module:engine/model/documentfragment~DocumentFragment `model.DocumentFragment`}.\n * 2. Fires the {@link module:clipboard/clipboardpipeline~ClipboardPipeline#event:contentInsertion `ClipboardPipeline#contentInsertion`}\n * event with the model document fragment in the `data.content` event field.\n * **Note**: The `ClipboardPipeline#contentInsertion` event is fired within a model change block to allow other handlers\n * to run in the same block without post-fixers called in between (i.e., the selection post-fixer).\n *\n * ## Event: `ClipboardPipeline#contentInsertion`\n *\n * 1. Calls {@link module:engine/model/model~Model#insertContent `model.insertContent()`} to insert `data.content`\n * at the current selection position.\n *\n * # Output pipeline\n *\n * The behavior of the default handlers (all at a `low` priority):\n *\n * ## Event: `copy`, `cut` or `dragstart`\n *\n * 1. Retrieves the selected {@link module:engine/model/documentfragment~DocumentFragment `model.DocumentFragment`} by calling\n * {@link module:engine/model/model~Model#getSelectedContent `model#getSelectedContent()`}.\n * 2. Converts the model document fragment to {@link module:engine/view/documentfragment~DocumentFragment `view.DocumentFragment`}.\n * 3. Fires the {@link module:engine/view/document~Document#event:clipboardOutput `view.Document#clipboardOutput`} event\n * with the view document fragment in the `data.content` event field.\n *\n * ## Event: `view.Document#clipboardOutput`\n *\n * 1. Processes `data.content` to HTML and plain text with the\n * {@link module:engine/controller/datacontroller~DataController#htmlProcessor `DataController#htmlProcessor`}.\n * 2. Updates the `data.dataTransfer` data for `text/html` and `text/plain` with the processed data.\n * 3. For the `cut` method, calls {@link module:engine/model/model~Model#deleteContent `model.deleteContent()`}\n * on the current selection.\n *\n * Read more about the clipboard integration in the {@glink framework/guides/deep-dive/clipboard clipboard deep dive guide}.\n *\n * @extends module:core/plugin~Plugin\n */\nexport default class ClipboardPipeline extends Plugin {\n\t/**\n\t * @inheritDoc\n\t */\n\tstatic get pluginName() {\n\t\treturn 'ClipboardPipeline';\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tinit() {\n\t\tconst editor = this.editor;\n\t\tconst view = editor.editing.view;\n\n\t\tview.addObserver( ClipboardObserver );\n\n\t\tthis._setupPasteDrop();\n\t\tthis._setupCopyCut();\n\t}\n\n\t/**\n\t * The clipboard paste pipeline.\n\t *\n\t * @private\n\t */\n\t_setupPasteDrop() {\n\t\tconst editor = this.editor;\n\t\tconst model = editor.model;\n\t\tconst view = editor.editing.view;\n\t\tconst viewDocument = view.document;\n\n\t\t// Pasting and dropping is disabled when editor is in the read-only mode.\n\t\t// See: https://github.com/ckeditor/ckeditor5-clipboard/issues/26.\n\t\tthis.listenTo( viewDocument, 'clipboardInput', evt => {\n\t\t\tif ( editor.isReadOnly ) {\n\t\t\t\tevt.stop();\n\t\t\t}\n\t\t}, { priority: 'highest' } );\n\n\t\tthis.listenTo( viewDocument, 'clipboardInput', ( evt, data ) => {\n\t\t\tconst dataTransfer = data.dataTransfer;\n\t\t\tlet content = data.content || '';\n\n\t\t\t// Some feature could already inject content in the higher priority event handler (i.e., codeBlock).\n\t\t\tif ( !content ) {\n\t\t\t\tif ( dataTransfer.getData( 'text/html' ) ) {\n\t\t\t\t\tcontent = normalizeClipboardHtml( dataTransfer.getData( 'text/html' ) );\n\t\t\t\t} else if ( dataTransfer.getData( 'text/plain' ) ) {\n\t\t\t\t\tcontent = plainTextToHtml( dataTransfer.getData( 'text/plain' ) );\n\t\t\t\t}\n\n\t\t\t\tcontent = this.editor.data.htmlProcessor.toView( content );\n\t\t\t}\n\n\t\t\tconst eventInfo = new EventInfo( this, 'inputTransformation' );\n\n\t\t\tthis.fire( eventInfo, {\n\t\t\t\tcontent,\n\t\t\t\tdataTransfer,\n\t\t\t\ttargetRanges: data.targetRanges,\n\t\t\t\tmethod: data.method\n\t\t\t} );\n\n\t\t\t// If CKEditor handled the input, do not bubble the original event any further.\n\t\t\t// This helps external integrations recognize this fact and act accordingly.\n\t\t\t// https://github.com/ckeditor/ckeditor5-upload/issues/92\n\t\t\tif ( eventInfo.stop.called ) {\n\t\t\t\tevt.stop();\n\t\t\t}\n\n\t\t\tview.scrollToTheSelection();\n\t\t}, { priority: 'low' } );\n\n\t\tthis.listenTo( this, 'inputTransformation', ( evt, data ) => {\n\t\t\tif ( data.content.isEmpty ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst dataController = this.editor.data;\n\n\t\t\t// Convert the pasted content into a model document fragment.\n\t\t\t// The conversion is contextual, but in this case an \"all allowed\" context is needed\n\t\t\t// and for that we use the $clipboardHolder item.\n\t\t\tconst modelFragment = dataController.toModel( data.content, '$clipboardHolder' );\n\n\t\t\tif ( modelFragment.childCount == 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tevt.stop();\n\n\t\t\t// Fire content insertion event in a single change block to allow other handlers to run in the same block\n\t\t\t// without post-fixers called in between (i.e., the selection post-fixer).\n\t\t\tmodel.change( () => {\n\t\t\t\tthis.fire( 'contentInsertion', {\n\t\t\t\t\tcontent: modelFragment,\n\t\t\t\t\tmethod: data.method,\n\t\t\t\t\tdataTransfer: data.dataTransfer,\n\t\t\t\t\ttargetRanges: data.targetRanges\n\t\t\t\t} );\n\t\t\t} );\n\t\t}, { priority: 'low' } );\n\n\t\tthis.listenTo( this, 'contentInsertion', ( evt, data ) => {\n\t\t\tdata.resultRange = model.insertContent( data.content );\n\t\t}, { priority: 'low' } );\n\t}\n\n\t/**\n\t * The clipboard copy/cut pipeline.\n\t *\n\t * @private\n\t */\n\t_setupCopyCut() {\n\t\tconst editor = this.editor;\n\t\tconst modelDocument = editor.model.document;\n\t\tconst view = editor.editing.view;\n\t\tconst viewDocument = view.document;\n\n\t\tfunction onCopyCut( evt, data ) {\n\t\t\tconst dataTransfer = data.dataTransfer;\n\n\t\t\tdata.preventDefault();\n\n\t\t\tconst content = editor.data.toView( editor.model.getSelectedContent( modelDocument.selection ) );\n\n\t\t\tviewDocument.fire( 'clipboardOutput', { dataTransfer, content, method: evt.name } );\n\t\t}\n\n\t\tthis.listenTo( viewDocument, 'copy', onCopyCut, { priority: 'low' } );\n\t\tthis.listenTo( viewDocument, 'cut', ( evt, data ) => {\n\t\t\t// Cutting is disabled when editor is in the read-only mode.\n\t\t\t// See: https://github.com/ckeditor/ckeditor5-clipboard/issues/26.\n\t\t\tif ( editor.isReadOnly ) {\n\t\t\t\tdata.preventDefault();\n\t\t\t} else {\n\t\t\t\tonCopyCut( evt, data );\n\t\t\t}\n\t\t}, { priority: 'low' } );\n\n\t\tthis.listenTo( viewDocument, 'clipboardOutput', ( evt, data ) => {\n\t\t\tif ( !data.content.isEmpty ) {\n\t\t\t\tdata.dataTransfer.setData( 'text/html', this.editor.data.htmlProcessor.toData( data.content ) );\n\t\t\t\tdata.dataTransfer.setData( 'text/plain', viewToPlainText( data.content ) );\n\t\t\t}\n\n\t\t\tif ( data.method == 'cut' ) {\n\t\t\t\teditor.model.deleteContent( modelDocument.selection );\n\t\t\t}\n\t\t}, { priority: 'low' } );\n\t}\n}\n\n/**\n * Fired with the `content`, `dataTransfer`, `method`, and `targetRanges` properties:\n *\n * * The `content` which comes from the clipboard (it was pasted or dropped) should be processed in order to be inserted into the editor.\n * * The `dataTransfer` object is available in case the transformation functions need access to the raw clipboard data.\n * * The `method` indicates the original DOM event (for example `'drop'` or `'paste'`).\n * * The `targetRanges` property is an array of view ranges (it is available only for `'drop'`).\n *\n * It is a part of the {@glink framework/guides/deep-dive/clipboard#input-pipeline clipboard input pipeline}.\n *\n * **Note**: You should not stop this event if you want to change the input data. You should modify the `content` property instead.\n *\n * @see module:clipboard/clipboardobserver~ClipboardObserver\n * @see module:clipboard/clipboardpipeline~ClipboardPipeline\n * @event module:clipboard/clipboardpipeline~ClipboardPipeline#event:inputTransformation\n * @param {Object} data The event data.\n * @param {module:engine/view/documentfragment~DocumentFragment} data.content The event data. The content to be inserted into the editor.\n * It can be modified by event listeners. Read more about the clipboard pipelines in\n * the {@glink framework/guides/deep-dive/clipboard clipboard deep dive guide}.\n * @param {module:clipboard/datatransfer~DataTransfer} data.dataTransfer The data transfer instance.\n * @param {'paste'|'drop'} data.method Whether the event was triggered by a paste or drop operation.\n * @param {Array.} data.targetRanges The target drop ranges.\n */\n\n/**\n * Fired with the `content`, `dataTransfer`, `method`, and `targetRanges` properties:\n *\n * * The `content` which comes from the clipboard (was pasted or dropped) should be processed in order to be inserted into the editor.\n * * The `dataTransfer` object is available in case the transformation functions need access to the raw clipboard data.\n * * The `method` indicates the original DOM event (for example `'drop'` or `'paste'`).\n * * The `targetRanges` property is an array of view ranges (it is available only for `'drop'`).\n *\n * Event handlers can modify the content according to the final insertion position.\n *\n * It is a part of the {@glink framework/guides/deep-dive/clipboard#input-pipeline clipboard input pipeline}.\n *\n * **Note**: You should not stop this event if you want to change the input data. You should modify the `content` property instead.\n *\n * @see module:clipboard/clipboardobserver~ClipboardObserver\n * @see module:clipboard/clipboardpipeline~ClipboardPipeline\n * @see module:clipboard/clipboardpipeline~ClipboardPipeline#event:inputTransformation\n * @event module:clipboard/clipboardpipeline~ClipboardPipeline#event:contentInsertion\n * @param {Object} data The event data.\n * @param {module:engine/model/documentfragment~DocumentFragment} data.content The event data. The content to be inserted into the editor.\n * Read more about the clipboard pipelines in the {@glink framework/guides/deep-dive/clipboard clipboard deep dive guide}.\n * @param {module:clipboard/datatransfer~DataTransfer} data.dataTransfer The data transfer instance.\n * @param {'paste'|'drop'} data.method Whether the event was triggered by a paste or drop operation.\n * @param {Array.} data.targetRanges The target drop ranges.\n * @param {module:engine/model/range~Range} data.resultRange The result of the `model.insertContent()` call\n * (inserted by the event handler at a low priority).\n */\n\n/**\n * Fired on {@link module:engine/view/document~Document#event:copy} and {@link module:engine/view/document~Document#event:cut}\n * with a copy of the selected content. The content can be processed before it ends up in the clipboard.\n *\n * It is a part of the {@glink framework/guides/deep-dive/clipboard#output-pipeline clipboard output pipeline}.\n *\n * @see module:clipboard/clipboardobserver~ClipboardObserver\n * @see module:clipboard/clipboardpipeline~ClipboardPipeline\n * @event module:engine/view/document~Document#event:clipboardOutput\n * @param {module:clipboard/clipboardpipeline~ClipboardOutputEventData} data The event data.\n */\n\n/**\n * The value of the {@link module:engine/view/document~Document#event:clipboardOutput} event.\n *\n * @class module:clipboard/clipboardpipeline~ClipboardOutputEventData\n */\n\n/**\n * The data transfer instance.\n *\n * @readonly\n * @member {module:clipboard/datatransfer~DataTransfer} module:clipboard/clipboardpipeline~ClipboardOutputEventData#dataTransfer\n */\n\n/**\n * Content to be put into the clipboard. It can be modified by the event listeners.\n * Read more about the clipboard pipelines in the {@glink framework/guides/deep-dive/clipboard clipboard deep dive guide}.\n *\n * @member {module:engine/view/documentfragment~DocumentFragment} module:clipboard/clipboardpipeline~ClipboardOutputEventData#content\n */\n\n/**\n * Whether the event was triggered by a copy or cut operation.\n *\n * @member {'copy'|'cut'} module:clipboard/clipboardpipeline~ClipboardOutputEventData#method\n */\n"],"sourceRoot":""}