{"version":3,"sources":["webpack:///./node_modules/@ckeditor/ckeditor5-code-block/src/converters.js","webpack:///./node_modules/@ckeditor/ckeditor5-code-block/src/outdentcodeblockcommand.js","webpack:///./node_modules/@ckeditor/ckeditor5-code-block/src/indentcodeblockcommand.js"],"names":["modelToViewCodeBlockInsertion","model","languageDefs","useLabels","arguments","length","undefined","languagesToClasses","getPropertyAssociation","languagesToLabels","evt","data","conversionApi","writer","mapper","consumable","consume","item","codeBlockLanguage","getAttribute","targetViewPosition","toViewPosition","createPositionBefore","preAttributes","spellcheck","pre","createContainerElement","code","class","insert","createPositionAt","bindElements","modelToDataViewSoftBreakInsertion","parent","name","position","createText","dataViewToModelCodeBlockInsertion","editingView","classesToLanguages","defaultLanguageName","language","viewCodeElement","viewItem","viewPreElement","is","modelCursor","findAncestor","test","codeBlock","createElement","viewChildClasses","Object","D_Projects_UA_repo_Source_Client_UA_User_Web_node_modules_babel_runtime_helpers_esm_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_6__","getClassNames","push","_step","_iterator","_createForOfIteratorHelper","s","n","done","className","value","setAttribute","err","e","f","hasAttribute","convertChildren","safeInsert","updateConversionResult","dataViewToModelTextNewlinesInsertion","_ref","_step2","text","textLines","split","map","lastLine","_iterator2","node","getShiftedBy","offsetSize","softBreak","createPositionAfter","modelRange","createRange","OutdentCodeBlockCommand","editor","_this","D_Projects_UA_repo_Source_Client_UA_User_Web_node_modules_babel_runtime_helpers_esm_classCallCheck_js__WEBPACK_IMPORTED_MODULE_7__","this","_super","call","_indentSequence","config","get","isEnabled","_checkEnabled","_this2","change","positions","getIndentOutdentPositions","range","getLastOutdentableSequenceRange","remove","_this3","isModelSelectionInCodeBlock","document","selection","some","Command","sequence","nodeAtPosition","getCodeLineTextNodeAtPosition","leadingWhiteSpaces","getLeadingWhiteSpaces","lastIndexOfSequence","lastIndexOf","startOffset","getChild","index","nodeBefore","IndentCodeBlockCommand","insertText"],"mappings":";;;;GAiCO,SAASA,EAA+BC,EAAOC,GA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,EAAwBqB,EAAAO,MACnClD,EAAOgH,WAAYzB,EAAKL,gBAAiB5D,IA1BnB,MAAA8B,GAAAR,EAAAS,EAAAD,GAAA,QAAAR,EAAAU,oCAqCzB,WACC,QAAMyB,KAAKG,iBAMJa,eAA6BhB,KAAKH,OAAOxF,MAAM4G,SAASC,kBA3EbE","file":"js/chunk-17cdaca4.fe808274.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 code-block/converters\n */\n\nimport { getPropertyAssociation } from './utils';\n\n/**\n * A model-to-view (both editing and data) converter for the `codeBlock` element.\n *\n * Sample input:\n *\n *\t\tfoo();bar();\n *\n * Sample output (editing):\n *\n *\t\t
foo();
bar();
\n *\n * Sample output (data, see {@link module:code-block/converters~modelToDataViewSoftBreakInsertion}):\n *\n *\t\t
foo();\\nbar();
\n *\n * @param {module:engine/model/model~Model} model\n * @param {Array.} languageDefs The normalized language\n * configuration passed to the feature.\n * @param {Boolean} [useLabels=false] When `true`, the `
` element will get a `data-language` attribute with a\n * human–readable label of the language. Used only in the editing.\n * @returns {Function} Returns a conversion callback.\n */\nexport function modelToViewCodeBlockInsertion( model, languageDefs, useLabels = false ) {\n\t// Language CSS classes:\n\t//\n\t//\t\t{\n\t//\t\t\tphp: 'language-php',\n\t//\t\t\tpython: 'language-python',\n\t//\t\t\tjavascript: 'js',\n\t//\t\t\t...\n\t//\t\t}\n\tconst languagesToClasses = getPropertyAssociation( languageDefs, 'language', 'class' );\n\n\t// Language labels:\n\t//\n\t//\t\t{\n\t//\t\t\tphp: 'PHP',\n\t//\t\t\tpython: 'Python',\n\t//\t\t\tjavascript: 'JavaScript',\n\t//\t\t\t...\n\t//\t\t}\n\tconst languagesToLabels = getPropertyAssociation( languageDefs, 'language', 'label' );\n\n\treturn ( evt, data, conversionApi ) => {\n\t\tconst { writer, mapper, consumable } = conversionApi;\n\n\t\tif ( !consumable.consume( data.item, 'insert' ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst codeBlockLanguage = data.item.getAttribute( 'language' );\n\t\tconst targetViewPosition = mapper.toViewPosition( model.createPositionBefore( data.item ) );\n\t\tconst preAttributes = {};\n\n\t\t// Attributes added only in the editing view.\n\t\tif ( useLabels ) {\n\t\t\tpreAttributes[ 'data-language' ] = languagesToLabels[ codeBlockLanguage ];\n\t\t\tpreAttributes.spellcheck = 'false';\n\t\t}\n\n\t\tconst pre = writer.createContainerElement( 'pre', preAttributes );\n\t\tconst code = writer.createContainerElement( 'code', {\n\t\t\tclass: languagesToClasses[ codeBlockLanguage ] || null\n\t\t} );\n\n\t\twriter.insert( writer.createPositionAt( pre, 0 ), code );\n\t\twriter.insert( targetViewPosition, pre );\n\t\tmapper.bindElements( data.item, code );\n\t};\n}\n\n/**\n * A model-to-data view converter for the new line (`softBreak`) separator.\n *\n * Sample input:\n *\n *\t\tfoo();bar();\n *\n * Sample output:\n *\n *\t\t
foo();\\nbar();
\n *\n * @param {module:engine/model/model~Model} model\n * @returns {Function} Returns a conversion callback.\n */\nexport function modelToDataViewSoftBreakInsertion( model ) {\n\treturn ( evt, data, conversionApi ) => {\n\t\tif ( data.item.parent.name !== 'codeBlock' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { writer, mapper, consumable } = conversionApi;\n\n\t\tif ( !consumable.consume( data.item, 'insert' ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst position = mapper.toViewPosition( model.createPositionBefore( data.item ) );\n\n\t\twriter.insert( position, writer.createText( '\\n' ) );\n\t};\n}\n\n/**\n * A view-to-model converter for `
` with the `` HTML.\n *\n * Sample input:\n *\n *\t\t
foo();bar();
\n *\n * Sample output:\n *\n *\t\tfoo();bar();\n *\n * @param {module:engine/view/view~View} editingView\n * @param {Array.} languageDefs The normalized language\n * configuration passed to the feature.\n * @returns {Function} Returns a conversion callback.\n */\nexport function dataViewToModelCodeBlockInsertion( editingView, languageDefs ) {\n\t// Language names associated with CSS classes:\n\t//\n\t//\t\t{\n\t//\t\t\t'language-php': 'php',\n\t//\t\t\t'language-python': 'python',\n\t//\t\t\tjs: 'javascript',\n\t//\t\t\t...\n\t//\t\t}\n\tconst classesToLanguages = getPropertyAssociation( languageDefs, 'class', 'language' );\n\tconst defaultLanguageName = languageDefs[ 0 ].language;\n\n\treturn ( evt, data, conversionApi ) => {\n\t\tconst viewCodeElement = data.viewItem;\n\t\tconst viewPreElement = viewCodeElement.parent;\n\n\t\tif ( !viewPreElement || !viewPreElement.is( 'element', 'pre' ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// In case of nested code blocks we don't want to convert to another code block.\n\t\tif ( data.modelCursor.findAncestor( 'codeBlock' ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { consumable, writer } = conversionApi;\n\n\t\tif ( !consumable.test( viewCodeElement, { name: true } ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst codeBlock = writer.createElement( 'codeBlock' );\n\t\tconst viewChildClasses = [ ...viewCodeElement.getClassNames() ];\n\n\t\t// As we're to associate each class with a model language, a lack of class (empty class) can be\n\t\t// also associated with a language if the language definition was configured so. Pushing an empty\n\t\t// string to make sure the association will work.\n\t\tif ( !viewChildClasses.length ) {\n\t\t\tviewChildClasses.push( '' );\n\t\t}\n\n\t\t// Figure out if any of the element's class names is a valid programming\n\t\t// language class. If so, use it on the model element (becomes the language of the entire block).\n\t\tfor ( const className of viewChildClasses ) {\n\t\t\tconst language = classesToLanguages[ className ];\n\n\t\t\tif ( language ) {\n\t\t\t\twriter.setAttribute( 'language', language, codeBlock );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t// If no language value was set, use the default language from the config.\n\t\tif ( !codeBlock.hasAttribute( 'language' ) ) {\n\t\t\twriter.setAttribute( 'language', defaultLanguageName, codeBlock );\n\t\t}\n\n\t\tconversionApi.convertChildren( viewCodeElement, codeBlock );\n\n\t\t// Let's try to insert code block.\n\t\tif ( !conversionApi.safeInsert( codeBlock, data.modelCursor ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconsumable.consume( viewCodeElement, { name: true } );\n\n\t\tconversionApi.updateConversionResult( codeBlock, data );\n\t};\n}\n\n/**\n * A view-to-model converter for new line characters in `
`.\n *\n * Sample input:\n *\n *\t\t
foo();\\nbar();
\n *\n * Sample output:\n *\n *\t\tfoo();bar();\n *\n * @returns {Function} Returns a conversion callback.\n */\nexport function dataViewToModelTextNewlinesInsertion() {\n\treturn ( evt, data, { consumable, writer } ) => {\n\t\tlet position = data.modelCursor;\n\n\t\t// When node is already converted then do nothing.\n\t\tif ( !consumable.test( data.viewItem ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// When not inside `codeBlock` then do nothing.\n\t\tif ( !position.findAncestor( 'codeBlock' ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconsumable.consume( data.viewItem );\n\n\t\tconst text = data.viewItem.data;\n\t\tconst textLines = text.split( '\\n' ).map( data => writer.createText( data ) );\n\t\tconst lastLine = textLines[ textLines.length - 1 ];\n\n\t\tfor ( const node of textLines ) {\n\t\t\twriter.insert( node, position );\n\t\t\tposition = position.getShiftedBy( node.offsetSize );\n\n\t\t\tif ( node !== lastLine ) {\n\t\t\t\tconst softBreak = writer.createElement( 'softBreak' );\n\n\t\t\t\twriter.insert( softBreak, position );\n\t\t\t\tposition = writer.createPositionAfter( softBreak );\n\t\t\t}\n\t\t}\n\n\t\tdata.modelRange = writer.createRange(\n\t\t\tdata.modelCursor,\n\t\t\tposition\n\t\t);\n\t\tdata.modelCursor = position;\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 code-block/outdentcodeblockcommand\n */\n\nimport { Command } from 'ckeditor5/src/core';\n\nimport {\n\tgetLeadingWhiteSpaces,\n\tgetIndentOutdentPositions,\n\tisModelSelectionInCodeBlock\n} from './utils';\n\n/**\n * The code block indentation decrease command plugin.\n *\n * @extends module:core/command~Command\n */\nexport default class OutdentCodeBlockCommand extends Command {\n\tconstructor( editor ) {\n\t\tsuper( editor );\n\n\t\t/**\n\t\t * A sequence of characters removed from the line when the command is executed.\n\t\t *\n\t\t * @readonly\n\t\t * @private\n\t\t * @member {String}\n\t\t */\n\t\tthis._indentSequence = editor.config.get( 'codeBlock.indentSequence' );\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\trefresh() {\n\t\tthis.isEnabled = this._checkEnabled();\n\t}\n\n\t/**\n\t * Executes the command. When the command {@link #isEnabled is enabled}, the indentation of the\n\t * code lines in the selection will be decreased.\n\t *\n\t * @fires execute\n\t */\n\texecute() {\n\t\tconst editor = this.editor;\n\t\tconst model = editor.model;\n\n\t\tmodel.change( writer => {\n\t\t\tconst positions = getIndentOutdentPositions( model );\n\n\t\t\t// Outdent all positions, for instance assuming the indent sequence is 4x space (\" \"):\n\t\t\t//\n\t\t\t//\t\t^foo -> foo\n\t\t\t//\n\t\t\t//\t\t ^bar -> bar\n\t\t\t//\n\t\t\t// Also, when there is more than one position:\n\t\t\t//\n\t\t\t//\t\t\n\t\t\t//\t\t\t ^foobar\n\t\t\t//\t\t\t\n\t\t\t//\t\t\t ^bazqux\n\t\t\t//\t\t\n\t\t\t//\n\t\t\t//\t\t->\n\t\t\t//\n\t\t\t//\t\t\n\t\t\t//\t\t\tfoobar\n\t\t\t//\t\t\t\n\t\t\t//\t\t\tbazqux\n\t\t\t//\t\t\n\t\t\tfor ( const position of positions ) {\n\t\t\t\tconst range = getLastOutdentableSequenceRange( this.editor.model, position, this._indentSequence );\n\n\t\t\t\tif ( range ) {\n\t\t\t\t\twriter.remove( range );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t}\n\n\t/**\n\t * Checks whether the command can be enabled in the current context.\n\t *\n\t * @private\n\t * @returns {Boolean} Whether the command should be enabled.\n\t */\n\t_checkEnabled() {\n\t\tif ( !this._indentSequence ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst model = this.editor.model;\n\n\t\tif ( !isModelSelectionInCodeBlock( model.document.selection ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Outdent command can execute only when there is an indent character sequence\n\t\t// in some of the lines.\n\t\treturn getIndentOutdentPositions( model ).some( position => {\n\t\t\treturn getLastOutdentableSequenceRange( model, position, this._indentSequence );\n\t\t} );\n\t}\n}\n\n// For a position coming from `getIndentOutdentPositions()`, it returns the range representing\n// the last occurrence of the indent sequence among the leading whitespaces of the code line the\n// position represents.\n//\n// For instance, assuming the indent sequence is 4x space (\" \"):\n//\n//\t\tfoo^ -> null\n//\t\tfoo^bar -> null\n//\t\t ^foo -> null\n//\t\t ^foo -> [ ]foo\n//\t\t ^foo bar -> [ ]foo bar\n//\n// @param {} model\n// @param {} position\n// @param {String} sequence\n// @returns {|null}\nfunction getLastOutdentableSequenceRange( model, position, sequence ) {\n\t// Positions start before each text node (code line). Get the node corresponding to the position.\n\tconst nodeAtPosition = getCodeLineTextNodeAtPosition( position );\n\n\tif ( !nodeAtPosition ) {\n\t\treturn null;\n\t}\n\n\tconst leadingWhiteSpaces = getLeadingWhiteSpaces( nodeAtPosition );\n\tconst lastIndexOfSequence = leadingWhiteSpaces.lastIndexOf( sequence );\n\n\t// For instance, assuming the indent sequence is 4x space (\" \"):\n\t//\n\t//\t\t \t^foo -> null\n\t//\n\tif ( lastIndexOfSequence + sequence.length !== leadingWhiteSpaces.length ) {\n\t\treturn null;\n\t}\n\n\t// For instance, assuming the indent sequence is 4x space (\" \"):\n\t//\n\t//\t\t ^foo -> null\n\t//\n\tif ( lastIndexOfSequence === -1 ) {\n\t\treturn null;\n\t}\n\n\tconst { parent, startOffset } = nodeAtPosition;\n\n\t// Create a range that contains the **last** indent sequence among the leading whitespaces\n\t// of the line.\n\t//\n\t// For instance, assuming the indent sequence is 4x space (\" \"):\n\t//\n\t//\t\t ^foo -> [ ]foo\n\t//\n\treturn model.createRange(\n\t\tmodel.createPositionAt( parent, startOffset + lastIndexOfSequence ),\n\t\tmodel.createPositionAt( parent, startOffset + lastIndexOfSequence + sequence.length )\n\t);\n}\n\nfunction getCodeLineTextNodeAtPosition( position ) {\n\t// Positions start before each text node (code line). Get the node corresponding to the position.\n\tlet nodeAtPosition = position.parent.getChild( position.index );\n\n\t// foo^\n\t// foo^bar\n\tif ( !nodeAtPosition || nodeAtPosition.is( 'element', 'softBreak' ) ) {\n\t\tnodeAtPosition = position.nodeBefore;\n\t}\n\n\t// ^\n\t// foo^bar\n\tif ( !nodeAtPosition || nodeAtPosition.is( 'element', 'softBreak' ) ) {\n\t\treturn null;\n\t}\n\n\treturn nodeAtPosition;\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 code-block/indentcodeblockcommand\n */\n\nimport { Command } from 'ckeditor5/src/core';\n\nimport {\n\tgetIndentOutdentPositions,\n\tisModelSelectionInCodeBlock\n} from './utils';\n\n/**\n * The code block indentation increase command plugin.\n *\n * @extends module:core/command~Command\n */\nexport default class IndentCodeBlockCommand extends Command {\n\tconstructor( editor ) {\n\t\tsuper( editor );\n\n\t\t/**\n\t\t * A sequence of characters added to the line when the command is executed.\n\t\t *\n\t\t * @readonly\n\t\t * @private\n\t\t * @member {String}\n\t\t */\n\t\tthis._indentSequence = editor.config.get( 'codeBlock.indentSequence' );\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\trefresh() {\n\t\tthis.isEnabled = this._checkEnabled();\n\t}\n\n\t/**\n\t * Executes the command. When the command {@link #isEnabled is enabled}, the indentation of the\n\t * code lines in the selection will be increased.\n\t *\n\t * @fires execute\n\t */\n\texecute() {\n\t\tconst editor = this.editor;\n\t\tconst model = editor.model;\n\n\t\tmodel.change( writer => {\n\t\t\tconst positions = getIndentOutdentPositions( model );\n\n\t\t\t// Indent all positions, for instance assuming the indent sequence is 4x space (\" \"):\n\t\t\t//\n\t\t\t//\t\t^foo -> foo\n\t\t\t//\n\t\t\t//\t\tfoo^bar -> foo bar\n\t\t\t//\n\t\t\t// Also, when there is more than one position:\n\t\t\t//\n\t\t\t//\t\t\n\t\t\t//\t\t\t^foobar\n\t\t\t//\t\t\t\n\t\t\t//\t\t\t^bazqux\n\t\t\t//\t\t\n\t\t\t//\n\t\t\t//\t\t->\n\t\t\t//\n\t\t\t//\t\t\n\t\t\t//\t\t\t foobar\n\t\t\t//\t\t\t\n\t\t\t//\t\t\t bazqux\n\t\t\t//\t\t\n\t\t\t//\n\t\t\tfor ( const position of positions ) {\n\t\t\t\twriter.insertText( this._indentSequence, position );\n\t\t\t}\n\t\t} );\n\t}\n\n\t/**\n\t * Checks whether the command can be enabled in the current context.\n\t *\n\t * @private\n\t * @returns {Boolean} Whether the command should be enabled.\n\t */\n\t_checkEnabled() {\n\t\tif ( !this._indentSequence ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Indent (forward) command is always enabled when there's any code block in the selection\n\t\t// because you can always indent code lines.\n\t\treturn isModelSelectionInCodeBlock( this.editor.model.document.selection );\n\t}\n}\n"],"sourceRoot":""}