{"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.} options.source The image source or an array of image sources to insert.\n\t * See the documentation of the command to learn more about accepted formats.\n\t */\n\texecute( options ) {\n\t\tconst sourceDefinitions = toArray( options.source );\n\t\tconst selection = this.editor.model.document.selection;\n\t\tconst imageUtils = this.editor.plugins.get( 'ImageUtils' );\n\n\t\t// In case of multiple images, each image (starting from the 2nd) will be inserted at a position that\n\t\t// follows the previous one. That will move the selection and, to stay on the safe side and make sure\n\t\t// all images inherit the same selection attributes, they are collected beforehand.\n\t\t//\n\t\t// Applying these attributes ensures, for instance, that inserting an (inline) image into a link does\n\t\t// not split that link but preserves its continuity.\n\t\t//\n\t\t// Note: Selection attributes that do not make sense for images will be filtered out by insertImage() anyway.\n\t\tconst selectionAttributes = Object.fromEntries( selection.getAttributes() );\n\n\t\tsourceDefinitions.forEach( ( sourceDefinition, index ) => {\n\t\t\tconst selectedElement = selection.getSelectedElement();\n\n\t\t\tif ( typeof sourceDefinition === 'string' ) {\n\t\t\t\tsourceDefinition = { src: sourceDefinition };\n\t\t\t}\n\n\t\t\t// Inserting of an inline image replace the selected element and make a selection on the inserted image.\n\t\t\t// Therefore inserting multiple inline images requires creating position after each element.\n\t\t\tif ( index && selectedElement && imageUtils.isImage( selectedElement ) ) {\n\t\t\t\tconst position = this.editor.model.createPositionAfter( selectedElement );\n\n\t\t\t\timageUtils.insertImage( { ...sourceDefinition, ...selectionAttributes }, position );\n\t\t\t} else {\n\t\t\t\timageUtils.insertImage( { ...sourceDefinition, ...selectionAttributes } );\n\t\t\t}\n\t\t} );\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 image/image/imageediting\n */\n\nimport { Plugin } from 'ckeditor5/src/core';\nimport ImageLoadObserver from './imageloadobserver';\nimport InsertImageCommand from './insertimagecommand';\nimport ImageUtils from '../imageutils';\n\n/**\n * The image engine plugin. This module loads common code shared between\n * {@link module:image/image/imageinlineediting~ImageInlineEditing} and\n * {@link module:image/image/imageblockediting~ImageBlockEditing} plugins.\n *\n * This plugin registers the {@link module:image/image/insertimagecommand~InsertImageCommand 'insertImage'} command.\n *\n * @extends module:core/plugin~Plugin\n */\nexport default class ImageEditing extends Plugin {\n\t/**\n\t * @inheritDoc\n\t */\n\tstatic get requires() {\n\t\treturn [ ImageUtils ];\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tstatic get pluginName() {\n\t\treturn 'ImageEditing';\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tinit() {\n\t\tconst editor = this.editor;\n\t\tconst conversion = editor.conversion;\n\n\t\t// See https://github.com/ckeditor/ckeditor5-image/issues/142.\n\t\teditor.editing.view.addObserver( ImageLoadObserver );\n\n\t\tconversion.for( 'upcast' )\n\t\t\t.attributeToAttribute( {\n\t\t\t\tview: {\n\t\t\t\t\tname: 'img',\n\t\t\t\t\tkey: 'alt'\n\t\t\t\t},\n\t\t\t\tmodel: 'alt'\n\t\t\t} )\n\t\t\t.attributeToAttribute( {\n\t\t\t\tview: {\n\t\t\t\t\tname: 'img',\n\t\t\t\t\tkey: 'srcset'\n\t\t\t\t},\n\t\t\t\tmodel: {\n\t\t\t\t\tkey: 'srcset',\n\t\t\t\t\tvalue: viewImage => {\n\t\t\t\t\t\tconst value = {\n\t\t\t\t\t\t\tdata: viewImage.getAttribute( 'srcset' )\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tif ( viewImage.hasAttribute( 'width' ) ) {\n\t\t\t\t\t\t\tvalue.width = viewImage.getAttribute( 'width' );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn value;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} );\n\n\t\tconst insertImageCommand = new InsertImageCommand( editor );\n\n\t\t// Register `insertImage` command and add `imageInsert` command as an alias for backward compatibility.\n\t\teditor.commands.add( 'insertImage', insertImageCommand );\n\t\teditor.commands.add( 'imageInsert', insertImageCommand );\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 image/image/imagetypecommand\n */\n\nimport { Command } from 'ckeditor5/src/core';\n\n/**\n * The image type command. It changes the type of a selected image, depending on the configuration.\n *\n * @extends module:core/command~Command\n */\nexport default class ImageTypeCommand extends Command {\n\t/**\n\t * @inheritDoc\n\t *\n\t * @param {module:core/editor/editor~Editor} editor\n\t * @param {'imageBlock'|'imageInline'} modelElementName Model element name the command converts to.\n\t */\n\tconstructor( editor, modelElementName ) {\n\t\tsuper( editor );\n\n\t\t/**\n\t\t * Model element name the command converts to.\n\t\t *\n\t\t * @readonly\n\t\t * @private\n\t\t * @member {'imageBlock'|'imageInline'}\n\t\t */\n\t\tthis._modelElementName = modelElementName;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\trefresh() {\n\t\tconst editor = this.editor;\n\t\tconst imageUtils = editor.plugins.get( 'ImageUtils' );\n\t\tconst element = imageUtils.getClosestSelectedImageElement( this.editor.model.document.selection );\n\n\t\tif ( this._modelElementName === 'imageBlock' ) {\n\t\t\tthis.isEnabled = imageUtils.isInlineImage( element );\n\t\t} else {\n\t\t\tthis.isEnabled = imageUtils.isBlockImage( element );\n\t\t}\n\t}\n\n\t/**\n\t * Executes the command and changes the type of a selected image.\n\t *\n\t * @fires execute\n\t * @returns {Object|null} An object containing references to old and new model image elements\n\t * (for before and after the change) so external integrations can hook into the decorated\n\t * `execute` event and handle this change. `null` if the type change failed.\n\t */\n\texecute() {\n\t\tconst editor = this.editor;\n\t\tconst model = this.editor.model;\n\t\tconst imageUtils = editor.plugins.get( 'ImageUtils' );\n\t\tconst oldElement = imageUtils.getClosestSelectedImageElement( model.document.selection );\n\t\tconst attributes = Object.fromEntries( oldElement.getAttributes() );\n\n\t\t// Don't change image type if \"src\" is missing (a broken image), unless there's \"uploadId\" set.\n\t\t// This state may happen during image upload (before it finishes) and it should be possible to change type\n\t\t// of the image in the meantime.\n\t\tif ( !attributes.src && !attributes.uploadId ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn model.change( writer => {\n\t\t\t// Get all markers that contain the old image element.\n\t\t\tconst markers = Array.from( model.markers )\n\t\t\t\t.filter( marker => marker.getRange().containsItem( oldElement ) );\n\n\t\t\tconst newElement = imageUtils.insertImage( attributes, model.createSelection( oldElement, 'on' ), this._modelElementName );\n\n\t\t\tif ( !newElement ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst newElementRange = writer.createRangeOn( newElement );\n\n\t\t\t// Expand the previously intersecting markers' ranges to include the new image element.\n\t\t\tfor ( const marker of markers ) {\n\t\t\t\tconst markerRange = marker.getRange();\n\n\t\t\t\t// Join the survived part of the old marker range with the new element range\n\t\t\t\t// (loosely because there could be some new paragraph or the existing one might got split).\n\t\t\t\tconst range = markerRange.root.rootName != '$graveyard' ?\n\t\t\t\t\tmarkerRange.getJoined( newElementRange, true ) : newElementRange;\n\n\t\t\t\twriter.updateMarker( marker, { range } );\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\toldElement,\n\t\t\t\tnewElement\n\t\t\t};\n\t\t} );\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 image/image/imageinlineediting\n */\n\nimport { Plugin } from 'ckeditor5/src/core';\nimport { ClipboardPipeline } from 'ckeditor5/src/clipboard';\nimport { UpcastWriter } from 'ckeditor5/src/engine';\n\nimport {\n\tdowncastImageAttribute,\n\tdowncastSrcsetAttribute\n} from './converters';\n\nimport ImageEditing from './imageediting';\nimport ImageTypeCommand from './imagetypecommand';\nimport ImageUtils from '../imageutils';\nimport {\n\tgetImgViewElementMatcher,\n\tcreateImageViewElement,\n\tdetermineImageTypeForInsertionAtSelection\n} from '../image/utils';\n\n/**\n * The image inline plugin.\n *\n * It registers:\n *\n * * `` as an inline element in the document schema, and allows `alt`, `src` and `srcset` attributes.\n * * converters for editing and data pipelines.\n * * {@link module:image/image/imagetypecommand~ImageTypeCommand `'imageTypeInline'`} command that converts block images into\n * inline images.\n *\n * @extends module:core/plugin~Plugin\n */\nexport default class ImageInlineEditing extends Plugin {\n\t/**\n\t * @inheritDoc\n\t */\n\tstatic get requires() {\n\t\treturn [ ImageEditing, ImageUtils, ClipboardPipeline ];\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tstatic get pluginName() {\n\t\treturn 'ImageInlineEditing';\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tinit() {\n\t\tconst editor = this.editor;\n\t\tconst schema = editor.model.schema;\n\n\t\t// Converters 'alt' and 'srcset' are added in 'ImageEditing' plugin.\n\t\tschema.register( 'imageInline', {\n\t\t\tisObject: true,\n\t\t\tisInline: true,\n\t\t\tallowWhere: '$text',\n\t\t\tallowAttributes: [ 'alt', 'src', 'srcset' ]\n\t\t} );\n\n\t\t// Disallow inline images in captions (for now). This is the best spot to do that because\n\t\t// independent packages can introduce captions (ImageCaption, TableCaption, etc.) so better this\n\t\t// be future-proof.\n\t\tschema.addChildCheck( ( context, childDefinition ) => {\n\t\t\tif ( context.endsWith( 'caption' ) && childDefinition.name === 'imageInline' ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} );\n\n\t\tthis._setupConversion();\n\n\t\tif ( editor.plugins.has( 'ImageBlockEditing' ) ) {\n\t\t\teditor.commands.add( 'imageTypeInline', new ImageTypeCommand( this.editor, 'imageInline' ) );\n\n\t\t\tthis._setupClipboardIntegration();\n\t\t}\n\t}\n\n\t/**\n\t * Configures conversion pipelines to support upcasting and downcasting\n\t * inline images (inline image widgets) and their attributes.\n\t *\n\t * @private\n\t */\n\t_setupConversion() {\n\t\tconst editor = this.editor;\n\t\tconst t = editor.t;\n\t\tconst conversion = editor.conversion;\n\t\tconst imageUtils = editor.plugins.get( 'ImageUtils' );\n\n\t\tconversion.for( 'dataDowncast' )\n\t\t\t.elementToElement( {\n\t\t\t\tmodel: 'imageInline',\n\t\t\t\tview: ( modelElement, { writer } ) => writer.createEmptyElement( 'img' )\n\t\t\t} );\n\n\t\tconversion.for( 'editingDowncast' )\n\t\t\t.elementToElement( {\n\t\t\t\tmodel: 'imageInline',\n\t\t\t\tview: ( modelElement, { writer } ) => imageUtils.toImageWidget(\n\t\t\t\t\tcreateImageViewElement( writer, 'imageInline' ), writer, t( 'image widget' )\n\t\t\t\t)\n\t\t\t} );\n\n\t\tconversion.for( 'downcast' )\n\t\t\t.add( downcastImageAttribute( imageUtils, 'imageInline', 'src' ) )\n\t\t\t.add( downcastImageAttribute( imageUtils, 'imageInline', 'alt' ) )\n\t\t\t.add( downcastSrcsetAttribute( imageUtils, 'imageInline' ) );\n\n\t\t// More image related upcasts are in 'ImageEditing' plugin.\n\t\tconversion.for( 'upcast' )\n\t\t\t.elementToElement( {\n\t\t\t\tview: getImgViewElementMatcher( editor, 'imageInline' ),\n\t\t\t\tmodel: ( viewImage, { writer } ) => writer.createElement( 'imageInline', { src: viewImage.getAttribute( 'src' ) } )\n\t\t\t} );\n\t}\n\n\t/**\n\t * Integrates the plugin with the clipboard pipeline.\n\t *\n\t * Idea is that the feature should recognize the user's intent when an **block** image is\n\t * pasted or dropped. If such an image is pasted/dropped into a non-empty block\n\t * (e.g. a paragraph with some text) it gets converted into an inline image on the fly.\n\t *\n\t * We assume this is the user's intent if they decided to put their image there.\n\t *\n\t * **Note**: If a block image has a caption, it will not be converted to an inline image\n\t * to avoid the confusion. Captions are added on purpose and they should never be lost\n\t * in the clipboard pipeline.\n\t *\n\t * See the `ImageBlockEditing` for the similar integration that works in the opposite direction.\n\t *\n\t * @private\n\t */\n\t_setupClipboardIntegration() {\n\t\tconst editor = this.editor;\n\t\tconst model = editor.model;\n\t\tconst editingView = editor.editing.view;\n\t\tconst imageUtils = editor.plugins.get( 'ImageUtils' );\n\n\t\tthis.listenTo( editor.plugins.get( 'ClipboardPipeline' ), 'inputTransformation', ( evt, data ) => {\n\t\t\tconst docFragmentChildren = Array.from( data.content.getChildren() );\n\t\t\tlet modelRange;\n\n\t\t\t// Make sure only
elements are dropped or pasted. Otherwise, if there some other HTML\n\t\t\t// mixed up, this should be handled as a regular paste.\n\t\t\tif ( !docFragmentChildren.every( imageUtils.isBlockImageView ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// When drag and dropping, data.targetRanges specifies where to drop because\n\t\t\t// this is usually a different place than the current model selection (the user\n\t\t\t// uses a drop marker to specify the drop location).\n\t\t\tif ( data.targetRanges ) {\n\t\t\t\tmodelRange = editor.editing.mapper.toModelRange( data.targetRanges[ 0 ] );\n\t\t\t}\n\t\t\t// Pasting, however, always occurs at the current model selection.\n\t\t\telse {\n\t\t\t\tmodelRange = model.document.selection.getFirstRange();\n\t\t\t}\n\n\t\t\tconst selection = model.createSelection( modelRange );\n\n\t\t\t// Convert block images into inline images only when pasting or dropping into non-empty blocks\n\t\t\t// and when the block is not an object (e.g. pasting to replace another widget).\n\t\t\tif ( determineImageTypeForInsertionAtSelection( model.schema, selection ) === 'imageInline' ) {\n\t\t\t\tconst writer = new UpcastWriter( editingView.document );\n\n\t\t\t\t// Unwrap
-> \n\t\t\t\t// but
...
-> stays the same\n\t\t\t\tconst inlineViewImages = docFragmentChildren.map( blockViewImage => {\n\t\t\t\t\t// If there's just one child, it can be either or .\n\t\t\t\t\t// If there are other children than , this means that the block image\n\t\t\t\t\t// has a caption or some other features and this kind of image should be\n\t\t\t\t\t// pasted/dropped without modifications.\n\t\t\t\t\tif ( blockViewImage.childCount === 1 ) {\n\t\t\t\t\t\t// Pass the attributes which are present only in the
to the \n\t\t\t\t\t\t// (e.g. the style=\"width:10%\" attribute applied by the ImageResize plugin).\n\t\t\t\t\t\tArray.from( blockViewImage.getAttributes() )\n\t\t\t\t\t\t\t.forEach( attribute => writer.setAttribute(\n\t\t\t\t\t\t\t\t...attribute,\n\t\t\t\t\t\t\t\timageUtils.findViewImgElement( blockViewImage )\n\t\t\t\t\t\t\t) );\n\n\t\t\t\t\t\treturn blockViewImage.getChild( 0 );\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn blockViewImage;\n\t\t\t\t\t}\n\t\t\t\t} );\n\n\t\t\t\tdata.content = writer.createDocumentFragment( inlineViewImages );\n\t\t\t}\n\t\t} );\n\t}\n}\n","module.exports = \"\"","module.exports = \"\""],"sourceRoot":""}