{"version":3,"sources":["webpack:///./node_modules/@ckeditor/ckeditor5-image/src/image/converters.js","webpack:///./node_modules/@ckeditor/ckeditor5-image/src/image/imageloadobserver.js","webpack:///./node_modules/@ckeditor/ckeditor5-image/src/image/insertimagecommand.js","webpack:///./node_modules/@ckeditor/ckeditor5-image/src/image/imageediting.js","webpack:///./node_modules/@ckeditor/ckeditor5-image/src/image/imagetypecommand.js","webpack:///./node_modules/@ckeditor/ckeditor5-image/src/image/imageinlineediting.js","webpack:///./node_modules/@ckeditor/ckeditor5-font/theme/icons/font-color.svg","webpack:///./node_modules/@ckeditor/ckeditor5-font/theme/icons/font-size.svg"],"names":["downcastSrcsetAttribute","imageUtils","imageType","dispatcher","on","concat","converter","evt","data","conversionApi","consumable","consume","item","name","writer","element","mapper","toViewElement","img","findViewImgElement","attributeNewValue","srcset","attributeOldValue","removeAttribute","width","setAttribute","downcastImageAttribute","attributeKey","viewWriter","ImageLoadObserver","domRoot","_this","this","listenTo","event","domEvent","domElement","target","checkShouldIgnoreEventFromTarget","tagName","_fireEvents","useCapture","isEnabled","document","fire","Observer","InsertImageCommand","editor","Object","classCallCheck","_super","call","configImageInsertType","config","get","plugins","has","logWarning","isImageAllowed","options","_this2","sourceDefinitions","toArray","source","selection","model","selectionAttributes","fromEntries","getAttributes","forEach","sourceDefinition","index","selectedElement","getSelectedElement","src","isImage","position","createPositionAfter","insertImage","_objectSpread","Command","ImageEditing","conversion","editing","view","addObserver","for","attributeToAttribute","key","value","viewImage","getAttribute","hasAttribute","insertImageCommand","commands","add","ImageUtils","Plugin","ImageTypeCommand","modelElementName","_modelElementName","getClosestSelectedImageElement","isInlineImage","isBlockImage","oldElement","attributes","uploadId","change","markers","Array","from","filter","marker","getRange","containsItem","newElement","createSelection","_step","newElementRange","createRangeOn","_iterator","imagetypecommand_createForOfIteratorHelper","s","n","done","markerRange","range","root","rootName","getJoined","updateMarker","err","e","f","ImageInlineEditing","schema","register","isObject","isInline","allowWhere","allowAttributes","addChildCheck","context","childDefinition","endsWith","_setupConversion","_setupClipboardIntegration","t","elementToElement","modelElement","_ref","createEmptyElement","_ref2","toImageWidget","createImageViewElement","getImgViewElementMatcher","_ref3","createElement","editingView","modelRange","docFragmentChildren","content","getChildren","every","isBlockImageView","targetRanges","toModelRange","getFirstRange","determineImageTypeForInsertionAtSelection","UpcastWriter","inlineViewImages","map","blockViewImage","childCount","attribute","apply","toConsumableArray","getChild","createDocumentFragment","ClipboardPipeline","module","exports"],"mappings":"2YA2KO,SAASA,EAAyBC,EAAYC,GACpD,OAAO,SAAAC,GACNA,EAAWC,GAAX,oBAAAC,OAAoCH,GAAcI,IAGnD,SAASA,EAAWC,EAAKC,EAAMC,GAC9B,GAAMA,EAAcC,WAAWC,QAASH,EAAKI,KAAML,EAAIM,MAAvD,CAIA,IAAMC,EAASL,EAAcK,OACvBC,EAAUN,EAAcO,OAAOC,cAAeT,EAAKI,MACnDM,EAAMjB,EAAWkB,mBAAoBJ,GAE3C,GAAgC,OAA3BP,EAAKY,kBAA6B,CACtC,IAAMC,EAASb,EAAKc,kBAEfD,EAAOb,OACXM,EAAOS,gBAAiB,SAAUL,GAClCJ,EAAOS,gBAAiB,QAASL,GAE5BG,EAAOG,OACXV,EAAOS,gBAAiB,QAASL,QAG7B,CACN,IAAMG,EAASb,EAAKY,kBAEfC,EAAOb,OACXM,EAAOW,aAAc,SAAUJ,EAAOb,KAAMU,GAE5CJ,EAAOW,aAAc,QAAS,QAASP,GAElCG,EAAOG,OACXV,EAAOW,aAAc,QAASJ,EAAOG,MAAON,OAkF1C,SAASQ,EAAwBzB,EAAYC,EAAWyB,GAC9D,OAAO,SAAAxB,GACNA,EAAWC,GAAX,aAAAC,OAA6BsB,EAA7B,KAAAtB,OAA+CH,GAAcI,IAG9D,SAASA,EAAWC,EAAKC,EAAMC,GAC9B,GAAMA,EAAcC,WAAWC,QAASH,EAAKI,KAAML,EAAIM,MAAvD,CAIA,IAAMe,EAAanB,EAAcK,OAC3BC,EAAUN,EAAcO,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IvC+H,EAAmBV,EAAoBW,IAAK,SAAAC,GAKjD,OAAmC,IAA9BA,EAAeC,YAGnBhE,MAAMC,KAAM8D,EAAexG,iBACzBC,QAAS,SAAAyG,GAAS,OAAIhK,EAAOW,aAAPsJ,MAAAjK,EAAMkC,OAAAgI,EAAA,KAAAhI,CACzB8H,GADyBzK,QAE5BJ,EAAWkB,mBAAoByJ,QAG1BA,EAAeK,SAAU,IAEzBL,IAITpK,EAAKyJ,QAAUnJ,EAAOoK,uBAAwBR,+BA5JjD,WACC,OAASzF,EAAce,OAAYmF,gCAMpC,WACC,MAAO,4BAZuClF,4BCvChDmF,EAAAC,QAAA,gOCAAD,EAAAC,QAAA","file":"js/chunk-040c83e1.c5a91bb1.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 image/image/converters\n */\n\nimport { first } from 'ckeditor5/src/utils';\n\n/**\n * Returns a function that converts the image view representation:\n *\n *\t\t
\n *\n * to the model representation:\n *\n *\t\t\n *\n * The entire content of the `` element except the first `
` is being converted as children\n * of the `` model element.\n *\n * @protected\n * @param {module:image/imageutils~ImageUtils} imageUtils\n * @returns {Function}\n */\nexport function upcastImageFigure( imageUtils ) {\n\treturn dispatcher => {\n\t\tdispatcher.on( 'element:figure', converter );\n\t};\n\n\tfunction converter( evt, data, conversionApi ) {\n\t\t// Do not convert if this is not an \"image figure\".\n\t\tif ( !conversionApi.consumable.test( data.viewItem, { name: true, classes: 'image' } ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Find an image element inside the figure element.\n\t\tconst viewImage = imageUtils.findViewImgElement( data.viewItem );\n\n\t\t// Do not convert if image element is absent, is missing src attribute or was already converted.\n\t\tif ( !viewImage || !viewImage.hasAttribute( 'src' ) || !conversionApi.consumable.test( viewImage, { name: true } ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Convert view image to model image.\n\t\tconst conversionResult = conversionApi.convertItem( viewImage, data.modelCursor );\n\n\t\t// Get image element from conversion result.\n\t\tconst modelImage = first( conversionResult.modelRange.getItems() );\n\n\t\t// When image wasn't successfully converted then finish conversion.\n\t\tif ( !modelImage ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Convert rest of the figure element's children as an image children.\n\t\tconversionApi.convertChildren( data.viewItem, modelImage );\n\n\t\tconversionApi.updateConversionResult( modelImage, data );\n\t}\n}\n\n/**\n * Returns a function that converts the image view representation:\n *\n *\t\t...
\n *\n * to the model representation as the `sources` attribute:\n *\n *\t\t\n *\n * @protected\n * @param {module:image/imageutils~ImageUtils} imageUtils\n * @returns {Function}\n */\nexport function upcastPicture( imageUtils ) {\n\tconst sourceAttributeNames = [ 'srcset', 'media', 'type' ];\n\n\treturn dispatcher => {\n\t\tdispatcher.on( 'element:picture', converter );\n\t};\n\n\tfunction converter( evt, data, conversionApi ) {\n\t\tconst pictureViewElement = data.viewItem;\n\n\t\t// Do not convert if already consumed.\n\t\tif ( !conversionApi.consumable.test( pictureViewElement, { name: true } ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst sources = new Map();\n\n\t\t// Collect all elements attribute values.\n\t\tfor ( const childSourceElement of pictureViewElement.getChildren() ) {\n\t\t\tif ( childSourceElement.is( 'element', 'source' ) ) {\n\t\t\t\tconst attributes = {};\n\n\t\t\t\tfor ( const name of sourceAttributeNames ) {\n\t\t\t\t\tif ( childSourceElement.hasAttribute( name ) ) {\n\t\t\t\t\t\t// Don't collect attribute if already consumed somewhere else.\n\t\t\t\t\t\tif ( conversionApi.consumable.test( childSourceElement, { attributes: name } ) ) {\n\t\t\t\t\t\t\tattributes[ name ] = childSourceElement.getAttribute( name );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif ( Object.keys( attributes ).length ) {\n\t\t\t\t\tsources.set( childSourceElement, attributes );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst imgViewElement = imageUtils.findViewImgElement( pictureViewElement );\n\n\t\t// Don't convert when a picture has no
inside (it is broken).\n\t\tif ( !imgViewElement ) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet modelImage = data.modelCursor.parent;\n\n\t\t// - In case of an inline image (cursor parent in a ), the
must be converted right away\n\t\t// because no converter handled it yet and otherwise there would be no model element to set the sources attribute on.\n\t\t// - In case of a block image, the converter (in ImageBlockEditing) converts the\n\t\t//
right away on its own and the modelCursor is already inside an imageBlock and there's nothing special\n\t\t// to do here.\n\t\tif ( !modelImage.is( 'element', 'imageBlock' ) ) {\n\t\t\tconst conversionResult = conversionApi.convertItem( imgViewElement, data.modelCursor );\n\n\t\t\t// Set image range as conversion result.\n\t\t\tdata.modelRange = conversionResult.modelRange;\n\n\t\t\t// Continue conversion where image conversion ends.\n\t\t\tdata.modelCursor = conversionResult.modelCursor;\n\n\t\t\tmodelImage = first( conversionResult.modelRange.getItems() );\n\n\t\t\t// It could be that the
was broken (e.g. missing \"src\"). There's no point in converting\n\t\t\t// any further around a broken
.\n\t\t\tif ( !modelImage ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tconversionApi.consumable.consume( pictureViewElement, { name: true } );\n\n\t\t// Consume only these attributes that were actually collected and will be passed on\n\t\t// to the image model element.\n\t\tfor ( const [ sourceElement, attributes ] of sources ) {\n\t\t\tconversionApi.consumable.consume( sourceElement, { attributes: Object.keys( attributes ) } );\n\t\t}\n\n\t\tif ( sources.size ) {\n\t\t\tconversionApi.writer.setAttribute( 'sources', Array.from( sources.values() ), modelImage );\n\t\t}\n\n\t\t// Convert rest of the children as an image children. Other converters may want to consume them.\n\t\tconversionApi.convertChildren( pictureViewElement, modelImage );\n\t}\n}\n\n/**\n * Converter used to convert the `srcset` model image attribute to the `srcset`, `sizes` and `width` attributes in the view.\n *\n * @protected\n * @param {module:image/imageutils~ImageUtils} imageUtils\n * @param {'imageBlock'|'imageInline'} imageType The type of the image.\n * @returns {Function}\n */\nexport function downcastSrcsetAttribute( imageUtils, imageType ) {\n\treturn dispatcher => {\n\t\tdispatcher.on( `attribute:srcset:${ imageType }`, converter );\n\t};\n\n\tfunction converter( evt, data, conversionApi ) {\n\t\tif ( !conversionApi.consumable.consume( data.item, evt.name ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst writer = conversionApi.writer;\n\t\tconst element = conversionApi.mapper.toViewElement( data.item );\n\t\tconst img = imageUtils.findViewImgElement( element );\n\n\t\tif ( data.attributeNewValue === null ) {\n\t\t\tconst srcset = data.attributeOldValue;\n\n\t\t\tif ( srcset.data ) {\n\t\t\t\twriter.removeAttribute( 'srcset', img );\n\t\t\t\twriter.removeAttribute( 'sizes', img );\n\n\t\t\t\tif ( srcset.width ) {\n\t\t\t\t\twriter.removeAttribute( 'width', img );\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconst srcset = data.attributeNewValue;\n\n\t\t\tif ( srcset.data ) {\n\t\t\t\twriter.setAttribute( 'srcset', srcset.data, img );\n\t\t\t\t// Always outputting `100vw`. See https://github.com/ckeditor/ckeditor5-image/issues/2.\n\t\t\t\twriter.setAttribute( 'sizes', '100vw', img );\n\n\t\t\t\tif ( srcset.width ) {\n\t\t\t\t\twriter.setAttribute( 'width', srcset.width, img );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Converts the `source` model attribute to the `...
`\n * view structure.\n *\n * @protected\n * @param {module:image/imageutils~ImageUtils} imageUtils\n * @returns {Function}\n */\nexport function downcastSourcesAttribute( imageUtils ) {\n\treturn dispatcher => {\n\t\tdispatcher.on( 'attribute:sources:imageBlock', converter );\n\t\tdispatcher.on( 'attribute:sources:imageInline', converter );\n\t};\n\n\tfunction converter( evt, data, conversionApi ) {\n\t\tif ( !conversionApi.consumable.consume( data.item, evt.name ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst viewWriter = conversionApi.writer;\n\t\tconst element = conversionApi.mapper.toViewElement( data.item );\n\t\tconst imgElement = imageUtils.findViewImgElement( element );\n\n\t\tif ( data.attributeNewValue && data.attributeNewValue.length ) {\n\t\t\t// Make sure does not break attribute elements, for instance in linked images.\n\t\t\tconst pictureElement = viewWriter.createContainerElement( 'picture', {}, { isAllowedInsideAttributeElement: true } );\n\n\t\t\tfor ( const sourceAttributes of data.attributeNewValue ) {\n\t\t\t\tconst sourceElement = viewWriter.createEmptyElement( 'source', sourceAttributes );\n\n\t\t\t\tviewWriter.insert( viewWriter.createPositionAt( pictureElement, 'end' ), sourceElement );\n\t\t\t}\n\n\t\t\t// Collect all wrapping attribute elements.\n\t\t\tconst attributeElements = [];\n\t\t\tlet viewElement = imgElement.parent;\n\n\t\t\twhile ( viewElement && viewElement.is( 'attributeElement' ) ) {\n\t\t\t\tconst parentElement = viewElement.parent;\n\n\t\t\t\tviewWriter.unwrap( viewWriter.createRangeOn( imgElement ), viewElement );\n\n\t\t\t\tattributeElements.unshift( viewElement );\n\t\t\t\tviewElement = parentElement;\n\t\t\t}\n\n\t\t\t// Insert the picture and move img into it.\n\t\t\tviewWriter.insert( viewWriter.createPositionBefore( imgElement ), pictureElement );\n\t\t\tviewWriter.move( viewWriter.createRangeOn( imgElement ), viewWriter.createPositionAt( pictureElement, 'end' ) );\n\n\t\t\t// Apply collected attribute elements over the new picture element.\n\t\t\tfor ( const attributeElement of attributeElements ) {\n\t\t\t\tviewWriter.wrap( viewWriter.createRangeOn( pictureElement ), attributeElement );\n\t\t\t}\n\t\t}\n\t\t// Both setting \"sources\" to an empty array and removing the attribute should unwrap the
.\n\t\t// Unwrap once if the latter followed the former, though.\n\t\telse if ( imgElement.parent.is( 'element', 'picture' ) ) {\n\t\t\tconst pictureElement = imgElement.parent;\n\n\t\t\tviewWriter.move( viewWriter.createRangeOn( imgElement ), viewWriter.createPositionBefore( pictureElement ) );\n\t\t\tviewWriter.remove( pictureElement );\n\t\t}\n\t}\n}\n\n/**\n * Converter used to convert a given image attribute from the model to the view.\n *\n * @protected\n * @param {module:image/imageutils~ImageUtils} imageUtils\n * @param {'imageBlock'|'imageInline'} imageType The type of the image.\n * @param {String} attributeKey The name of the attribute to convert.\n * @returns {Function}\n */\nexport function downcastImageAttribute( imageUtils, imageType, attributeKey ) {\n\treturn dispatcher => {\n\t\tdispatcher.on( `attribute:${ attributeKey }:${ imageType }`, converter );\n\t};\n\n\tfunction converter( evt, data, conversionApi ) {\n\t\tif ( !conversionApi.consumable.consume( data.item, evt.name ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst viewWriter = conversionApi.writer;\n\t\tconst element = conversionApi.mapper.toViewElement( data.item );\n\t\tconst img = imageUtils.findViewImgElement( element );\n\n\t\tviewWriter.setAttribute( data.attributeKey, data.attributeNewValue || '', img );\n\t}\n}\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 image/image/imageloadobserver\n */\n\nimport { Observer } from 'ckeditor5/src/engine';\n\n/**\n * Observes all new images added to the {@link module:engine/view/document~Document},\n * fires {@link module:engine/view/document~Document#event:imageLoaded} and\n * {@link module:engine/view/document~Document#event:layoutChanged} event every time when the new image\n * has been loaded.\n *\n * **Note:** This event is not fired for images that has been added to the document and rendered as `complete` (already loaded).\n *\n * @extends module:engine/view/observer/observer~Observer\n */\nexport default class ImageLoadObserver extends Observer {\n\t/**\n\t * @inheritDoc\n\t */\n\tobserve( domRoot ) {\n\t\tthis.listenTo( domRoot, 'load', ( event, domEvent ) => {\n\t\t\tconst domElement = domEvent.target;\n\n\t\t\tif ( this.checkShouldIgnoreEventFromTarget( domElement ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( domElement.tagName == 'IMG' ) {\n\t\t\t\tthis._fireEvents( domEvent );\n\t\t\t}\n\t\t\t// Use capture phase for better performance (#4504).\n\t\t}, { useCapture: true } );\n\t}\n\n\t/**\n\t * Fires {@link module:engine/view/document~Document#event:layoutChanged} and\n\t * {@link module:engine/view/document~Document#event:imageLoaded}\n\t * if observer {@link #isEnabled is enabled}.\n\t *\n\t * @protected\n\t * @param {Event} domEvent The DOM event.\n\t */\n\t_fireEvents( domEvent ) {\n\t\tif ( this.isEnabled ) {\n\t\t\tthis.document.fire( 'layoutChanged' );\n\t\t\tthis.document.fire( 'imageLoaded', domEvent );\n\t\t}\n\t}\n}\n\n/**\n * Fired when an
DOM element has been loaded in the DOM root.\n *\n * Introduced by {@link module:image/image/imageloadobserver~ImageLoadObserver}.\n *\n * @see module:image/image/imageloadobserver~ImageLoadObserver\n * @event module:engine/view/document~Document#event:imageLoaded\n * @param {module:engine/view/observer/domeventdata~DomEventData} data 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\nimport { Command } from 'ckeditor5/src/core';\nimport { logWarning, toArray } from 'ckeditor5/src/utils';\n\n/**\n * @module image/image/insertimagecommand\n */\n\n/**\n * Insert image command.\n *\n * The command is registered by the {@link module:image/image/imageediting~ImageEditing} plugin as `insertImage`\n * and it is also available via aliased `imageInsert` name.\n *\n * In order to insert an image at the current selection position\n * (according to the {@link module:widget/utils~findOptimalInsertionRange} algorithm),\n * execute the command and specify the image source:\n *\n *\t\teditor.execute( 'insertImage', { source: 'http://url.to.the/image' } );\n *\n * It is also possible to insert multiple images at once:\n *\n *\t\teditor.execute( 'insertImage', {\n *\t\t\tsource: [\n *\t\t\t\t'path/to/image.jpg',\n *\t\t\t\t'path/to/other-image.jpg'\n *\t\t\t]\n *\t\t} );\n *\n * If you want to take the full control over the process, you can specify individual model attributes:\n *\n *\t\teditor.execute( 'insertImage', {\n *\t\t\tsource: [\n *\t\t\t\t{ src: 'path/to/image.jpg', alt: 'First alt text' },\n *\t\t\t\t{ src: 'path/to/other-image.jpg', alt: 'Second alt text', customAttribute: 'My attribute value' }\n *\t\t\t]\n *\t\t} );\n *\n * @extends module:core/command~Command\n */\nexport default class InsertImageCommand extends Command {\n\t/**\n\t * @inheritDoc\n\t */\n\tconstructor( editor ) {\n\t\tsuper( editor );\n\n\t\tconst configImageInsertType = editor.config.get( 'image.insert.type' );\n\n\t\tif ( !editor.plugins.has( 'ImageBlockEditing' ) ) {\n\t\t\tif ( configImageInsertType === 'block' ) {\n\t\t\t\t/**\n\t\t\t\t * The {@link module:image/imageblock~ImageBlock} plugin must be enabled to allow inserting block images. See\n\t\t\t\t * {@link module:image/imageinsert~ImageInsertConfig#type} to learn more.\n\t\t\t\t *\n\t\t\t\t * @error image-block-plugin-required\n\t\t\t\t */\n\t\t\t\tlogWarning( 'image-block-plugin-required' );\n\t\t\t}\n\t\t}\n\n\t\tif ( !editor.plugins.has( 'ImageInlineEditing' ) ) {\n\t\t\tif ( configImageInsertType === 'inline' ) {\n\t\t\t\t/**\n\t\t\t\t * The {@link module:image/imageinline~ImageInline} plugin must be enabled to allow inserting inline images. See\n\t\t\t\t * {@link module:image/imageinsert~ImageInsertConfig#type} to learn more.\n\t\t\t\t *\n\t\t\t\t * @error image-inline-plugin-required\n\t\t\t\t */\n\t\t\t\tlogWarning( 'image-inline-plugin-required' );\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\trefresh() {\n\t\tthis.isEnabled = this.editor.plugins.get( 'ImageUtils' ).isImageAllowed();\n\t}\n\n\t/**\n\t * Executes the command.\n\t *\n\t * @fires execute\n\t * @param {Object} options Options for the executed command.\n\t * @param {String|Array.|Array.