{"version":3,"sources":["webpack:///./node_modules/@ckeditor/ckeditor5-image/theme/icons/image_placeholder.svg","webpack:///./node_modules/@ckeditor/ckeditor5-image/src/imageutils.js"],"names":["module","exports","ImageUtils","modelElement","this","isInlineImage","isBlockImage","element","is","hasClass","attributes","arguments","length","undefined","selectable","imageType","editor","model","selection","document","attributeName","determineImageTypeForInsertion","_objectSpread","Object","fromEntries","getAttributes","schema","checkAttribute","change","writer","imageElement","createElement","findOptimalInsertionRange","insertContent","parent","setSelection","viewElement","getSelectedElement","isImageWidget","getFirstPosition","selectedElement","isImage","findAncestor","isImageAllowedInParent","isNotInsideImage","label","_this","setCustomProperty","labelCreator","imgElement","findViewImgElement","altText","getAttribute","concat","toWidget","getCustomProperty","isWidget","figureView","isInlineImageView","_step","editingView","editing","view","_iterator","_createForOfIteratorHelper","createRangeIn","s","n","done","item","value","err","e","f","Plugin","getInsertImageParent","checkChild","focus","D_Projects_UA_repo_Source_Client_UA_User_Web_node_modules_babel_runtime_helpers_esm_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_10__","getAncestors","every","ancestor","insertionRange","start","isEmpty","configImageInsertType","config","get","plugins","has","determineImageTypeForInsertionAtSelection"],"mappings":"mJAAAA,EAAAC,QAAA;;;;OCkBqBC,8JAcpB,SAASC,GACR,OAAOC,KAAKC,cAAeF,IAAkBC,KAAKE,aAAcH,oCAWjE,SAAmBI,GAClB,QAASA,GAAWA,EAAQC,GAAI,UAAW,uCAW5C,SAAkBD,GACjB,QAASA,GAAWA,EAAQC,GAAI,UAAW,WAAcD,EAAQE,SAAU,oCAwB5E,WAAoE,IAAvDC,EAAuDC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,MAAtCG,EAAsCH,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAzB,KAAMI,EAAmBJ,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAP,KACtDK,EAASZ,KAAKY,OACdC,EAAQD,EA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tB2D,EAAwBrE,EAAOsE,OAAOC,IAAK,qBAEjD,OAAMvE,EAAOwE,QAAQC,IAAK,qBAIpBzE,EAAOwE,QAAQC,IAAK,sBAIrB1E,IAI0B,WAA1BsE,EACG,cAGuB,UAA1BA,EACG,aAIHvE,EAAWN,GAAI,aACZkF,eAA2ChE,EAAQZ,GAGpDY,EAAOkD,WAAY9D,EAAY,eAAkB,cAAgB,cApBhE,aAJA","file":"js/chunk-eca7838a.e2f44155.js","sourcesContent":["module.exports = \"\"","/**\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/imageutils\n */\n\nimport { Plugin } from 'ckeditor5/src/core';\nimport { findOptimalInsertionRange, isWidget, toWidget } from 'ckeditor5/src/widget';\nimport { determineImageTypeForInsertionAtSelection } from './image/utils';\n\n/**\n * A set of helpers related to images.\n *\n * @extends module:core/plugin~Plugin\n */\nexport default class ImageUtils extends Plugin {\n\t/**\n\t * @inheritDoc\n\t */\n\tstatic get pluginName() {\n\t\treturn 'ImageUtils';\n\t}\n\n\t/**\n\t * Checks if the provided model element is an `image` or `imageInline`.\n\t *\n\t * @param {module:engine/model/element~Element} modelElement\n\t * @returns {Boolean}\n\t */\n\tisImage( modelElement ) {\n\t\treturn this.isInlineImage( modelElement ) || this.isBlockImage( modelElement );\n\t}\n\n\t/**\n\t * Checks if the provided view element represents an inline image.\n\t *\n\t * Also, see {@link module:image/imageutils~ImageUtils#isImageWidget}.\n\t *\n\t * @param {module:engine/view/element~Element} element\n\t * @returns {Boolean}\n\t */\n\tisInlineImageView( element ) {\n\t\treturn !!element && element.is( 'element', 'img' );\n\t}\n\n\t/**\n\t * Checks if the provided view element represents a block image.\n\t *\n\t * Also, see {@link module:image/imageutils~ImageUtils#isImageWidget}.\n\t *\n\t * @param {module:engine/view/element~Element} element\n\t * @returns {Boolean}\n\t */\n\tisBlockImageView( element ) {\n\t\treturn !!element && element.is( 'element', 'figure' ) && element.hasClass( 'image' );\n\t}\n\n\t/**\n\t * Handles inserting single file. This method unifies image insertion using {@link module:widget/utils~findOptimalInsertionRange}\n\t * method.\n\t *\n\t *\t\tconst imageUtils = editor.plugins.get( 'ImageUtils' );\n\t *\n\t *\t\timageUtils.insertImage( { src: 'path/to/image.jpg' } );\n\t *\n\t * @param {Object} [attributes={}] Attributes of the inserted image.\n\t * This method filters out the attributes which are disallowed by the {@link module:engine/model/schema~Schema}.\n\t * @param {module:engine/model/selection~Selectable} [selectable] Place to insert the image. If not specified,\n\t * the {@link module:widget/utils~findOptimalInsertionRange} logic will be applied for the block images\n\t * and `model.document.selection` for the inline images.\n\t *\n\t * **Note**: If `selectable` is passed, this helper will not be able to set selection attributes (such as `linkHref`)\n\t * and apply them to the new image. In this case, make sure all selection attributes are passed in `attributes`.\n\t *\n\t * @param {'imageBlock'|'imageInline'} [imageType] Image type of inserted image. If not specified,\n\t * it will be determined automatically depending of editor config or place of the insertion.\n\t * @return {module:engine/view/element~Element|null} The inserted model image element.\n\t */\n\tinsertImage( attributes = {}, selectable = null, imageType = null ) {\n\t\tconst editor = this.editor;\n\t\tconst model = editor.model;\n\t\tconst selection = model.document.selection;\n\n\t\timageType = determineImageTypeForInsertion( editor, selectable || selection, imageType );\n\n\t\t// Mix declarative attributes with selection attributes because the new image should \"inherit\"\n\t\t// the latter for best UX. For instance, inline images inserted into existing links\n\t\t// should not split them. To do that, they need to have \"linkHref\" inherited from the selection.\n\t\tattributes = {\n\t\t\t...Object.fromEntries( selection.getAttributes() ),\n\t\t\t...attributes\n\t\t};\n\n\t\tfor ( const attributeName in attributes ) {\n\t\t\tif ( !model.schema.checkAttribute( imageType, attributeName ) ) {\n\t\t\t\tdelete attributes[ attributeName ];\n\t\t\t}\n\t\t}\n\n\t\treturn model.change( writer => {\n\t\t\tconst imageElement = writer.createElement( imageType, attributes );\n\n\t\t\t// If we want to insert a block image (for whatever reason) then we don't want to split text blocks.\n\t\t\t// This applies only when we don't have the selectable specified (i.e., we insert multiple block images at once).\n\t\t\tif ( !selectable && imageType != 'imageInline' ) {\n\t\t\t\tselectable = findOptimalInsertionRange( selection, model );\n\t\t\t}\n\n\t\t\tmodel.insertContent( imageElement, selectable );\n\n\t\t\t// Inserting an image might've failed due to schema regulations.\n\t\t\tif ( imageElement.parent ) {\n\t\t\t\twriter.setSelection( imageElement, 'on' );\n\n\t\t\t\treturn imageElement;\n\t\t\t}\n\n\t\t\treturn null;\n\t\t} );\n\t}\n\n\t/**\n\t * Returns an image widget editing view element if one is selected or is among the selection's ancestors.\n\t *\n\t * @protected\n\t * @param {module:engine/view/selection~Selection|module:engine/view/documentselection~DocumentSelection} selection\n\t * @returns {module:engine/view/element~Element|null}\n\t */\n\tgetClosestSelectedImageWidget( selection ) {\n\t\tconst viewElement = selection.getSelectedElement();\n\n\t\tif ( viewElement && this.isImageWidget( viewElement ) ) {\n\t\t\treturn viewElement;\n\t\t}\n\n\t\tlet parent = selection.getFirstPosition().parent;\n\n\t\twhile ( parent ) {\n\t\t\tif ( parent.is( 'element' ) && this.isImageWidget( parent ) ) {\n\t\t\t\treturn parent;\n\t\t\t}\n\n\t\t\tparent = parent.parent;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t/**\n\t * Returns a image model element if one is selected or is among the selection's ancestors.\n\t *\n\t * @param {module:engine/model/selection~Selection|module:engine/model/documentselection~DocumentSelection} selection\n\t * @returns {module:engine/model/element~Element|null}\n\t */\n\tgetClosestSelectedImageElement( selection ) {\n\t\tconst selectedElement = selection.getSelectedElement();\n\n\t\treturn this.isImage( selectedElement ) ? selectedElement : selection.getFirstPosition().findAncestor( 'imageBlock' );\n\t}\n\n\t/**\n\t * Checks if image can be inserted at current model selection.\n\t *\n\t * @protected\n\t * @returns {Boolean}\n\t */\n\tisImageAllowed() {\n\t\tconst model = this.editor.model;\n\t\tconst selection = model.document.selection;\n\n\t\treturn isImageAllowedInParent( this.editor, selection ) && isNotInsideImage( selection );\n\t}\n\n\t/**\n\t * Converts a given {@link module:engine/view/element~Element} to an image widget:\n\t * * Adds a {@link module:engine/view/element~Element#_setCustomProperty custom property} allowing to recognize the image widget\n\t * element.\n\t * * Calls the {@link module:widget/utils~toWidget} function with the proper element's label creator.\n\t *\n\t * @protected\n\t * @param {module:engine/view/element~Element} viewElement\n\t * @param {module:engine/view/downcastwriter~DowncastWriter} writer An instance of the view writer.\n\t * @param {String} label The element's label. It will be concatenated with the image `alt` attribute if one is present.\n\t * @returns {module:engine/view/element~Element}\n\t */\n\ttoImageWidget( viewElement, writer, label ) {\n\t\twriter.setCustomProperty( 'image', true, viewElement );\n\n\t\tconst labelCreator = () => {\n\t\t\tconst imgElement = this.findViewImgElement( viewElement );\n\t\t\tconst altText = imgElement.getAttribute( 'alt' );\n\n\t\t\treturn altText ? `${ altText } ${ label }` : label;\n\t\t};\n\n\t\treturn toWidget( viewElement, writer, { label: labelCreator } );\n\t}\n\n\t/**\n\t * Checks if a given view element is an image widget.\n\t *\n\t * @protected\n\t * @param {module:engine/view/element~Element} viewElement\n\t * @returns {Boolean}\n\t */\n\tisImageWidget( viewElement ) {\n\t\treturn !!viewElement.getCustomProperty( 'image' ) && isWidget( viewElement );\n\t}\n\n\t/**\n\t * Checks if the provided model element is an `image`.\n\t *\n\t * @param {module:engine/model/element~Element} modelElement\n\t * @returns {Boolean}\n\t */\n\tisBlockImage( modelElement ) {\n\t\treturn !!modelElement && modelElement.is( 'element', 'imageBlock' );\n\t}\n\n\t/**\n\t * Checks if the provided model element is an `imageInline`.\n\t *\n\t * @param {module:engine/model/element~Element} modelElement\n\t * @returns {Boolean}\n\t */\n\tisInlineImage( modelElement ) {\n\t\treturn !!modelElement && modelElement.is( 'element', 'imageInline' );\n\t}\n\n\t/**\n\t * Get the view `` from another view element, e.g. a widget (``), a link (``).\n\t *\n\t * The `` can be located deep in other elements, so this helper performs a deep tree search.\n\t *\n\t * @param {module:engine/view/element~Element} figureView\n\t * @returns {module:engine/view/element~Element}\n\t */\n\tfindViewImgElement( figureView ) {\n\t\tif ( this.isInlineImageView( figureView ) ) {\n\t\t\treturn figureView;\n\t\t}\n\n\t\tconst editingView = this.editor.editing.view;\n\n\t\tfor ( const { item } of editingView.createRangeIn( figureView ) ) {\n\t\t\tif ( this.isInlineImageView( item ) ) {\n\t\t\t\treturn item;\n\t\t\t}\n\t\t}\n\t}\n}\n\n// Checks if image is allowed by schema in optimal insertion parent.\n//\n// @private\n// @param {module:core/editor/editor~Editor} editor\n// @param {module:engine/model/selection~Selection} selection\n// @returns {Boolean}\nfunction isImageAllowedInParent( editor, selection ) {\n\tconst imageType = determineImageTypeForInsertion( editor, selection );\n\n\tif ( imageType == 'imageBlock' ) {\n\t\tconst parent = getInsertImageParent( selection, editor.model );\n\n\t\tif ( editor.model.schema.checkChild( parent, 'imageBlock' ) ) {\n\t\t\treturn true;\n\t\t}\n\t} else if ( editor.model.schema.checkChild( selection.focus, 'imageInline' ) ) {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n\n// Checks if selection is not placed inside an image (e.g. its caption).\n//\n// @private\n// @param {module:engine/model/selection~Selectable} selection\n// @returns {Boolean}\nfunction isNotInsideImage( selection ) {\n\treturn [ ...selection.focus.getAncestors() ].every( ancestor => !ancestor.is( 'element', 'imageBlock' ) );\n}\n\n// Returns a node that will be used to insert image with `model.insertContent`.\n//\n// @private\n// @param {module:engine/model/selection~Selection} selection\n// @param {module:engine/model/model~Model} model\n// @returns {module:engine/model/element~Element}\nfunction getInsertImageParent( selection, model ) {\n\tconst insertionRange = findOptimalInsertionRange( selection, model );\n\tconst parent = insertionRange.start.parent;\n\n\tif ( parent.isEmpty && !parent.is( 'element', '$root' ) ) {\n\t\treturn parent.parent;\n\t}\n\n\treturn parent;\n}\n\n// Determine image element type name depending on editor config or place of insertion.\n//\n// @private\n// @param {module:core/editor/editor~Editor} editor\n// @param {module:engine/model/selection~Selectable} selectable\n// @param {'imageBlock'|'imageInline'} [imageType] Image element type name. Used to force return of provided element name,\n// but only if there is proper plugin enabled.\n// @returns {'imageBlock'|'imageInline'} imageType\nfunction determineImageTypeForInsertion( editor, selectable, imageType ) {\n\tconst schema = editor.model.schema;\n\tconst configImageInsertType = editor.config.get( 'image.insert.type' );\n\n\tif ( !editor.plugins.has( 'ImageBlockEditing' ) ) {\n\t\treturn 'imageInline';\n\t}\n\n\tif ( !editor.plugins.has( 'ImageInlineEditing' ) ) {\n\t\treturn 'imageBlock';\n\t}\n\n\tif ( imageType ) {\n\t\treturn imageType;\n\t}\n\n\tif ( configImageInsertType === 'inline' ) {\n\t\treturn 'imageInline';\n\t}\n\n\tif ( configImageInsertType === 'block' ) {\n\t\treturn 'imageBlock';\n\t}\n\n\t// Try to replace the selected widget (e.g. another image).\n\tif ( selectable.is( 'selection' ) ) {\n\t\treturn determineImageTypeForInsertionAtSelection( schema, selectable );\n\t}\n\n\treturn schema.checkChild( selectable, 'imageInline' ) ? 'imageInline' : 'imageBlock';\n}\n"],"sourceRoot":""}