{"version":3,"sources":["webpack:///./node_modules/@ckeditor/ckeditor5-code-block/src/codeblockcommand.js","webpack:///./node_modules/@ckeditor/ckeditor5-code-block/src/codeblockediting.js","webpack:///./node_modules/@ckeditor/ckeditor5-code-block/src/codeblockui.js","webpack:///./node_modules/@ckeditor/ckeditor5-code-block/src/codeblock.js"],"names":["CodeBlockCommand","editor","_this","Object","classCallCheck","this","_super","call","_lastLanguage","value","_getValue","isEnabled","_checkEnabled","_this2","options","arguments","length","undefined","model","selection","document","normalizedLanguagesDefs","getNormalizedAndLocalizedLanguageDefinitions","firstLanguageInConfig","blocks","Array","from","getSelectedBlocks","forceValue","language","getLanguage","change","writer","_applyCodeBlock","_removeCodeBlock","firstBlock","first","isCodeBlock","is","getAttribute","schema","canBeCodeBlock","_step","allowedBlocks","filter","block","_iterator","_createForOfIteratorHelper","_loop","rename","setAttribute","removeDisallowedAttributes","getChildren","child","checkChild","forEach","remove","s","n","done","err","e","f","reverse","currentBlock","i","nextBlock","previousSibling","appendElement","merge","createPositionBefore","_step2","codeBlocks","_iterator2","_step3","range","createRangeOn","_iterator3","getItems","item","parent","_writer$split","split","position","nodeAfter","removeAttribute","Command","element","isLimit","lastLanguage","defaultLanguage","usePreviousLanguageChoice","DEFAULT_ELEMENT","CodeBlockEditing","config","define","languages","label","indentSequence","view","editing","commands","add","IndentCodeBlockCommand","OutdentCodeBlockCommand","getCommandExecuter","commandName","data","cancel","command","get","execute","keystrokes","set","register","allowWhere","allowChildren","isBlock","allowAttributes","addAttributeCheck","context","endsWith","addChildCheck","childDefinition","isObject","downcastDispatcher","on","modelToViewCodeBlockInsertion","modelToDataViewSoftBreakInsertion","priority","upcastDispatcher","dataViewToModelCodeBlockInsertion","dataViewToModelTextNewlinesInsertion","listenTo","evt","insertionRange","createRange","anchor","targetRanges","mapper","toModelRange","start","text","dataTransfer","getData","UpcastWriter","content","rawSnippetTextToViewDocumentFragment","_ref","_ref2","slicedToArray","isCollapsed","hasSameParentAs","focus","docFragment","return","childCount","containsEntireContent","codeBlock","createElement","getAttributes","append","newDocumentFragment","createDocumentFragment","textNode","getChild","checkAttribute","indent","outdent","registerChildCommand","positionParent","getLastPosition","leaveBlockStartOnEnter","isSoft","leaveBlockEndOnEnter","breakLineOnEnter","preventDefault","stop","ShiftEnter","Plugin","leadingWhiteSpaces","modelDoc","lastSelectionPosition","node","nodeBefore","getLeadingWhiteSpaces","insertText","isSoftEnter","isAtStart","newBlock","setSelection","scrollToTheSelection","emptyLineRangeToRemoveOnEnter","isAtEnd","match","createPositionAfter","CodeBlockUI","t","componentFactory","ui","normalizedLanguageDefs","locale","dropdownView","createDropdown","SplitButtonView","splitButtonView","buttonView","tooltip","icon","codeBlockIcon","isToggleable","bind","to","source","_codeBlockLanguage","class","addListToDropdown","_getLanguageListItemDefinitions","itemDefinitions","Collection","codeblockui_createForOfIteratorHelper","languageDef","definition","type","Model","withText","CodeBlock"],"mappings":";;;;OAmBqBA,6CAIpB,SAAAA,EAAaC,GAAS,IAAAC,EAAA,OAAAC,OAAAC,EAAA,KAAAD,CAAAE,KAAAL,GACrBE,EAAAI,EAAAC,KAAAF,KAAOJ,GAQPC,EAAKM,cAAgB,KATAN,gDAuBtB,WACCG,KAAKI,MAAQJ,KAAKK,YAClBL,KAAKM,UAAYN,KAAKO,uCAgBvB,WAAwB,IAAAC,EAAAR,KAAfS,EAAeC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,MACjBd,EAASI,KAAKJ,OACdiB,EAAQjB,EAAOiB,MACfC,EAAYD,EAAME,SAASD,UAC3BE,EAA0BC,eAA8CrB,GACxEsB,EAAwBF,EAAyB,GAEjDG,EAASC,MAAMC,KAAMP,EAAUQ,qBAC/BlB,OAAiCQ,IAAvBH,EAAQc,YAA8BvB,KAAKI,MAAQK,EAAQc,WACrEC,EAAWC,EAAahB,EAAST,KAAKG,cAAee,EAAsBM,UAEjFX,EAAMa,OAAQ,SAAAC,GACRvB,EACJI,EAAKoB,gBAAiBD,EAAQ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iM,KAAM,QAASC,GAAIvG,EAAS,QAAS,SAAApG,GACrD,OAAOA,IAAUqN,EAAW5M,MAAMoM,qBAGnCI,EAAgBpH,IAAKwH,IAdtB,IAAAhL,EAAAW,MAAAf,EAAAI,EAAAY,KAAAC,MAAoDX,IALK,MAAAY,GAAAd,EAAAe,EAAAD,GAAA,QAAAd,EAAAgB,IAsBzD,OAAO4J,4BAnFR,WACC,MAAO,qBALgCvC;;;;OCApB+C,kKAIpB,WACC,OAASrI,EAAkBuG,2BAM5B,WACC,MAAO,mBAZ8BjB","file":"js/chunk-2d0a38be.26f40f67.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/codeblockcommand\n */\n\nimport { Command } from 'ckeditor5/src/core';\nimport { first } from 'ckeditor5/src/utils';\n\nimport { getNormalizedAndLocalizedLanguageDefinitions } from './utils';\n\n/**\n * The code block command plugin.\n *\n * @extends module:core/command~Command\n */\nexport default class CodeBlockCommand extends Command {\n\t/**\n\t * @inheritDoc\n\t */\n\tconstructor( editor ) {\n\t\tsuper( editor );\n\n\t\t/**\n\t\t * Contains the last used language.\n\n\t\t * @protected\n\t\t * @type {String|null}\n\t\t */\n\t\tthis._lastLanguage = null;\n\t}\n\n\t/**\n\t * Whether the selection starts in a code block.\n\t *\n\t * @observable\n\t * @readonly\n\t * @member {Boolean} #value\n\t */\n\n\t/**\n\t * @inheritDoc\n\t */\n\trefresh() {\n\t\tthis.value = this._getValue();\n\t\tthis.isEnabled = this._checkEnabled();\n\t}\n\n\t/**\n\t * Executes the command. When the command {@link #value is on}, all topmost code blocks within\n\t * the selection will be removed. If it is off, all selected blocks will be flattened and\n\t * wrapped by a code block.\n\t *\n\t * @fires execute\n\t * @param {Object} [options] Command options.\n\t * @param {String} [options.language] The code block language.\n\t * @param {Boolean} [options.forceValue] If set, it will force the command behavior. If `true`, the command will apply a code block,\n\t * otherwise the command will remove the code block. If not set, the command will act basing on its current value.\n\t * @param {Boolean} [options.usePreviousLanguageChoice] If set on `true` and the `options.language` is not specified, the command\n\t * will apply the previous language (if the command was already executed) when inserting the `codeBlock` element.\n\t */\n\texecute( options = {} ) {\n\t\tconst editor = this.editor;\n\t\tconst model = editor.model;\n\t\tconst selection = model.document.selection;\n\t\tconst normalizedLanguagesDefs = getNormalizedAndLocalizedLanguageDefinitions( editor );\n\t\tconst firstLanguageInConfig = normalizedLanguagesDefs[ 0 ];\n\n\t\tconst blocks = Array.from( selection.getSelectedBlocks() );\n\t\tconst value = ( options.forceValue === undefined ) ? !this.value : options.forceValue;\n\t\tconst language = getLanguage( options, this._lastLanguage, firstLanguageInConfig.language );\n\n\t\tmodel.change( writer => {\n\t\t\tif ( value ) {\n\t\t\t\tthis._applyCodeBlock( writer, blocks, language );\n\t\t\t} else {\n\t\t\t\tthis._removeCodeBlock( writer, blocks );\n\t\t\t}\n\t\t} );\n\t}\n\n\t/**\n\t * Checks the command's {@link #value}.\n\t *\n\t * @private\n\t * @returns {Boolean} The current value.\n\t */\n\t_getValue() {\n\t\tconst selection = this.editor.model.document.selection;\n\t\tconst firstBlock = first( selection.getSelectedBlocks() );\n\t\tconst isCodeBlock = !!( firstBlock && firstBlock.is( 'element', 'codeBlock' ) );\n\n\t\treturn isCodeBlock ? firstBlock.getAttribute( 'language' ) : false;\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.value ) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst selection = this.editor.model.document.selection;\n\t\tconst schema = this.editor.model.schema;\n\n\t\tconst firstBlock = first( selection.getSelectedBlocks() );\n\n\t\tif ( !firstBlock ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn canBeCodeBlock( schema, firstBlock );\n\t}\n\n\t/**\n\t * @private\n\t * @param {module:engine/model/writer~Writer} writer\n\t * @param {Array.} blocks\n\t * @param {String} [language]\n\t */\n\t_applyCodeBlock( writer, blocks, language ) {\n\t\tthis._lastLanguage = language;\n\n\t\tconst schema = this.editor.model.schema;\n\t\tconst allowedBlocks = blocks.filter( block => canBeCodeBlock( schema, block ) );\n\n\t\tfor ( const block of allowedBlocks ) {\n\t\t\twriter.rename( block, 'codeBlock' );\n\t\t\twriter.setAttribute( 'language', language, block );\n\t\t\tschema.removeDisallowedAttributes( [ block ], writer );\n\n\t\t\t// Remove children of the `codeBlock` element that are not allowed. See #9567.\n\t\t\tArray.from( block.getChildren() )\n\t\t\t\t.filter( child => !schema.checkChild( block, child ) )\n\t\t\t\t.forEach( child => writer.remove( child ) );\n\t\t}\n\n\t\tallowedBlocks.reverse().forEach( ( currentBlock, i ) => {\n\t\t\tconst nextBlock = allowedBlocks[ i + 1 ];\n\n\t\t\tif ( currentBlock.previousSibling === nextBlock ) {\n\t\t\t\twriter.appendElement( 'softBreak', nextBlock );\n\t\t\t\twriter.merge( writer.createPositionBefore( currentBlock ) );\n\t\t\t}\n\t\t} );\n\t}\n\n\t/**\n\t * @private\n\t * @param {module:engine/model/writer~Writer} writer\n\t * @param {Array.} blocks\n\t */\n\t_removeCodeBlock( writer, blocks ) {\n\t\tconst codeBlocks = blocks.filter( block => block.is( 'element', 'codeBlock' ) );\n\n\t\tfor ( const block of codeBlocks ) {\n\t\t\tconst range = writer.createRangeOn( block );\n\n\t\t\tfor ( const item of Array.from( range.getItems() ).reverse() ) {\n\t\t\t\tif ( item.is( 'element', 'softBreak' ) && item.parent.is( 'element', 'codeBlock' ) ) {\n\t\t\t\t\tconst { position } = writer.split( writer.createPositionBefore( item ) );\n\n\t\t\t\t\twriter.rename( position.nodeAfter, 'paragraph' );\n\t\t\t\t\twriter.removeAttribute( 'language', position.nodeAfter );\n\t\t\t\t\twriter.remove( item );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\twriter.rename( block, 'paragraph' );\n\t\t\twriter.removeAttribute( 'language', block );\n\t\t}\n\t}\n}\n\nfunction canBeCodeBlock( schema, element ) {\n\tif ( element.is( 'rootElement' ) || schema.isLimit( element ) ) {\n\t\treturn false;\n\t}\n\n\treturn schema.checkChild( element.parent, 'codeBlock' );\n}\n\n// Picks the language for the new code block. If any language is passed as an option,\n// it will be returned. Else, if option usePreviousLanguageChoice is true and some\n// code block was already created (lastLanguage is not null) then previously used\n// language will be returned. If not, it will return default language.\n//\n// @param {Object} options\n// @param {Boolean} [options.usePreviousLanguageChoice]\n// @param {String} [options.language]\n// @param {String|null} lastLanguage\n// @param {String} defaultLanguage\n// @return {String}\nfunction getLanguage( options, lastLanguage, defaultLanguage ) {\n\tif ( options.language ) {\n\t\treturn options.language;\n\t}\n\n\tif ( options.usePreviousLanguageChoice && lastLanguage ) {\n\t\treturn lastLanguage;\n\t}\n\n\treturn defaultLanguage;\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/codeblockediting\n */\n\nimport { Plugin } from 'ckeditor5/src/core';\nimport { ShiftEnter } from 'ckeditor5/src/enter';\nimport { UpcastWriter } from 'ckeditor5/src/engine';\n\nimport CodeBlockCommand from './codeblockcommand';\nimport IndentCodeBlockCommand from './indentcodeblockcommand';\nimport OutdentCodeBlockCommand from './outdentcodeblockcommand';\nimport {\n\tgetNormalizedAndLocalizedLanguageDefinitions,\n\tgetLeadingWhiteSpaces,\n\trawSnippetTextToViewDocumentFragment\n} from './utils';\nimport {\n\tmodelToViewCodeBlockInsertion,\n\tmodelToDataViewSoftBreakInsertion,\n\tdataViewToModelCodeBlockInsertion,\n\tdataViewToModelTextNewlinesInsertion\n} from './converters';\n\nconst DEFAULT_ELEMENT = 'paragraph';\n\n/**\n * The editing part of the code block feature.\n *\n * Introduces the `'codeBlock'` command and the `'codeBlock'` model element.\n *\n * @extends module:core/plugin~Plugin\n */\nexport default class CodeBlockEditing extends Plugin {\n\t/**\n\t * @inheritDoc\n\t */\n\tstatic get pluginName() {\n\t\treturn 'CodeBlockEditing';\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tstatic get requires() {\n\t\treturn [ ShiftEnter ];\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tconstructor( editor ) {\n\t\tsuper( editor );\n\n\t\teditor.config.define( 'codeBlock', {\n\t\t\tlanguages: [\n\t\t\t\t{ language: 'plaintext', label: 'Plain text' },\n\t\t\t\t{ language: 'c', label: 'C' },\n\t\t\t\t{ language: 'cs', label: 'C#' },\n\t\t\t\t{ language: 'cpp', label: 'C++' },\n\t\t\t\t{ language: 'css', label: 'CSS' },\n\t\t\t\t{ language: 'diff', label: 'Diff' },\n\t\t\t\t{ language: 'html', label: 'HTML' },\n\t\t\t\t{ language: 'java', label: 'Java' },\n\t\t\t\t{ language: 'javascript', label: 'JavaScript' },\n\t\t\t\t{ language: 'php', label: 'PHP' },\n\t\t\t\t{ language: 'python', label: 'Python' },\n\t\t\t\t{ language: 'ruby', label: 'Ruby' },\n\t\t\t\t{ language: 'typescript', label: 'TypeScript' },\n\t\t\t\t{ language: 'xml', label: 'XML' }\n\t\t\t],\n\n\t\t\t// A single tab.\n\t\t\tindentSequence: '\\t'\n\t\t} );\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\t\tconst model = editor.model;\n\t\tconst view = editor.editing.view;\n\n\t\tconst normalizedLanguagesDefs = getNormalizedAndLocalizedLanguageDefinitions( editor );\n\n\t\t// The main command.\n\t\teditor.commands.add( 'codeBlock', new CodeBlockCommand( editor ) );\n\n\t\t// Commands that change the indentation.\n\t\teditor.commands.add( 'indentCodeBlock', new IndentCodeBlockCommand( editor ) );\n\t\teditor.commands.add( 'outdentCodeBlock', new OutdentCodeBlockCommand( editor ) );\n\n\t\tconst getCommandExecuter = commandName => {\n\t\t\treturn ( data, cancel ) => {\n\t\t\t\tconst command = this.editor.commands.get( commandName );\n\n\t\t\t\tif ( command.isEnabled ) {\n\t\t\t\t\tthis.editor.execute( commandName );\n\t\t\t\t\tcancel();\n\t\t\t\t}\n\t\t\t};\n\t\t};\n\n\t\teditor.keystrokes.set( 'Tab', getCommandExecuter( 'indentCodeBlock' ) );\n\t\teditor.keystrokes.set( 'Shift+Tab', getCommandExecuter( 'outdentCodeBlock' ) );\n\n\t\tschema.register( 'codeBlock', {\n\t\t\tallowWhere: '$block',\n\t\t\tallowChildren: '$text',\n\t\t\tisBlock: true,\n\t\t\tallowAttributes: [ 'language' ]\n\t\t} );\n\n\t\t// Disallow all attributes on $text inside `codeBlock`.\n\t\tschema.addAttributeCheck( context => {\n\t\t\tif ( context.endsWith( 'codeBlock $text' ) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} );\n\n\t\t// Disallow object elements inside `codeBlock`. See #9567.\n\t\teditor.model.schema.addChildCheck( ( context, childDefinition ) => {\n\t\t\tif ( context.endsWith( 'codeBlock' ) && childDefinition.isObject ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} );\n\n\t\t// Conversion.\n\t\teditor.editing.downcastDispatcher.on( 'insert:codeBlock', modelToViewCodeBlockInsertion( model, normalizedLanguagesDefs, true ) );\n\t\teditor.data.downcastDispatcher.on( 'insert:codeBlock', modelToViewCodeBlockInsertion( model, normalizedLanguagesDefs ) );\n\t\teditor.data.downcastDispatcher.on( 'insert:softBreak', modelToDataViewSoftBreakInsertion( model ), { priority: 'high' } );\n\n\t\teditor.data.upcastDispatcher.on( 'element:code', dataViewToModelCodeBlockInsertion( view, normalizedLanguagesDefs ) );\n\t\teditor.data.upcastDispatcher.on( 'text', dataViewToModelTextNewlinesInsertion() );\n\n\t\t// Intercept the clipboard input (paste) when the selection is anchored in the code block and force the clipboard\n\t\t// data to be pasted as a single plain text. Otherwise, the code lines will split the code block and\n\t\t// \"spill out\" as separate paragraphs.\n\t\tthis.listenTo( editor.editing.view.document, 'clipboardInput', ( evt, data ) => {\n\t\t\tlet insertionRange = model.createRange( model.document.selection.anchor );\n\n\t\t\t// Use target ranges in case this is a drop.\n\t\t\tif ( data.targetRanges ) {\n\t\t\t\tinsertionRange = editor.editing.mapper.toModelRange( data.targetRanges[ 0 ] );\n\t\t\t}\n\n\t\t\tif ( !insertionRange.start.parent.is( 'element', 'codeBlock' ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst text = data.dataTransfer.getData( 'text/plain' );\n\t\t\tconst writer = new UpcastWriter( editor.editing.view.document );\n\n\t\t\t// Pass the view fragment to the default clipboardInput handler.\n\t\t\tdata.content = rawSnippetTextToViewDocumentFragment( writer, text );\n\t\t} );\n\n\t\t// Make sure multi–line selection is always wrapped in a code block when `getSelectedContent()`\n\t\t// is used (e.g. clipboard copy). Otherwise, only the raw text will be copied to the clipboard and,\n\t\t// upon next paste, this bare text will not be inserted as a code block, which is not the best UX.\n\t\t// Similarly, when the selection in a single line, the selected content should be an inline code\n\t\t// so it can be pasted later on and retain it's preformatted nature.\n\t\tthis.listenTo( model, 'getSelectedContent', ( evt, [ selection ] ) => {\n\t\t\tconst anchor = selection.anchor;\n\n\t\t\tif ( selection.isCollapsed || !anchor.parent.is( 'element', 'codeBlock' ) || !anchor.hasSameParentAs( selection.focus ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tmodel.change( writer => {\n\t\t\t\tconst docFragment = evt.return;\n\n\t\t\t\t// fo[ob]ar -> [ob]\n\t\t\t\tif ( docFragment.childCount > 1 || selection.containsEntireContent( anchor.parent ) ) {\n\t\t\t\t\tconst codeBlock = writer.createElement( 'codeBlock', anchor.parent.getAttributes() );\n\t\t\t\t\twriter.append( docFragment, codeBlock );\n\n\t\t\t\t\tconst newDocumentFragment = writer.createDocumentFragment();\n\t\t\t\t\twriter.append( codeBlock, newDocumentFragment );\n\n\t\t\t\t\tevt.return = newDocumentFragment;\n\t\t\t\t}\n\n\t\t\t\t// \"f[oo]\" -> <$text code=\"true\">oo\n\t\t\t\telse {\n\t\t\t\t\tconst textNode = docFragment.getChild( 0 );\n\n\t\t\t\t\tif ( schema.checkAttribute( textNode, 'code' ) ) {\n\t\t\t\t\t\twriter.setAttribute( 'code', true, textNode );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} );\n\t\t} );\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tafterInit() {\n\t\tconst editor = this.editor;\n\t\tconst commands = editor.commands;\n\t\tconst indent = commands.get( 'indent' );\n\t\tconst outdent = commands.get( 'outdent' );\n\n\t\tif ( indent ) {\n\t\t\tindent.registerChildCommand( commands.get( 'indentCodeBlock' ) );\n\t\t}\n\n\t\tif ( outdent ) {\n\t\t\toutdent.registerChildCommand( commands.get( 'outdentCodeBlock' ) );\n\t\t}\n\n\t\t// Customize the response to the Enter and Shift+Enter\n\t\t// key press when the selection is in the code block. Upon enter key press we can either\n\t\t// leave the block if it's \"two enters\" in a row or create a new code block line, preserving\n\t\t// previous line's indentation.\n\t\tthis.listenTo( editor.editing.view.document, 'enter', ( evt, data ) => {\n\t\t\tconst positionParent = editor.model.document.selection.getLastPosition().parent;\n\n\t\t\tif ( !positionParent.is( 'element', 'codeBlock' ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( !leaveBlockStartOnEnter( editor, data.isSoft ) && !leaveBlockEndOnEnter( editor, data.isSoft ) ) {\n\t\t\t\tbreakLineOnEnter( editor );\n\t\t\t}\n\n\t\t\tdata.preventDefault();\n\t\t\tevt.stop();\n\t\t}, { context: 'pre' } );\n\t}\n}\n\n// Normally, when the Enter (or Shift+Enter) key is pressed, a soft line break is to be added to the\n// code block. Let's try to follow the indentation of the previous line when possible, for instance:\n//\n//\t\t// Before pressing enter (or shift enter)\n//\t\t\n//\t\t\" foo()\"[] // Indent of 4 spaces.\n//\t\t\n//\n//\t\t// After pressing:\n//\t\t\n//\t\t\" foo()\" // Indent of 4 spaces.\n//\t\t // A new soft break created by pressing enter.\n//\t\t\" \"[] // Retain the indent of 4 spaces.\n//\t\t\n//\n// @param {module:core/editor/editor~Editor} editor\nfunction breakLineOnEnter( editor ) {\n\tconst model = editor.model;\n\tconst modelDoc = model.document;\n\tconst lastSelectionPosition = modelDoc.selection.getLastPosition();\n\tconst node = lastSelectionPosition.nodeBefore || lastSelectionPosition.textNode;\n\tlet leadingWhiteSpaces;\n\n\t// Figure out the indentation (white space chars) at the beginning of the line.\n\tif ( node && node.is( '$text' ) ) {\n\t\tleadingWhiteSpaces = getLeadingWhiteSpaces( node );\n\t}\n\n\t// Keeping everything in a change block for a single undo step.\n\teditor.model.change( writer => {\n\t\teditor.execute( 'shiftEnter' );\n\n\t\t// If the line before being broken in two had some indentation, let's retain it\n\t\t// in the new line.\n\t\tif ( leadingWhiteSpaces ) {\n\t\t\twriter.insertText( leadingWhiteSpaces, modelDoc.selection.anchor );\n\t\t}\n\t} );\n}\n\n// Leave the code block when Enter (but NOT Shift+Enter) has been pressed twice at the beginning\n// of the code block:\n//\n//\t\t// Before:\n//\t\t[]foo\n//\n//\t\t// After pressing:\n//\t\t[]foo\n//\n// @param {module:core/editor/editor~Editor} editor\n// @param {Boolean} isSoftEnter When `true`, enter was pressed along with Shift.\n// @returns {Boolean} `true` when selection left the block. `false` if stayed.\nfunction leaveBlockStartOnEnter( editor, isSoftEnter ) {\n\tconst model = editor.model;\n\tconst modelDoc = model.document;\n\tconst view = editor.editing.view;\n\tconst lastSelectionPosition = modelDoc.selection.getLastPosition();\n\tconst nodeAfter = lastSelectionPosition.nodeAfter;\n\n\tif ( isSoftEnter || !modelDoc.selection.isCollapsed || !lastSelectionPosition.isAtStart ) {\n\t\treturn false;\n\t}\n\n\tif ( !nodeAfter || !nodeAfter.is( 'element', 'softBreak' ) ) {\n\t\treturn false;\n\t}\n\n\t// We're doing everything in a single change block to have a single undo step.\n\teditor.model.change( writer => {\n\t\t// \"Clone\" the in the standard way.\n\t\teditor.execute( 'enter' );\n\n\t\t// The cloned block exists now before the original code block.\n\t\tconst newBlock = modelDoc.selection.anchor.parent.previousSibling;\n\n\t\t// Make the cloned a regular (with clean attributes, so no language).\n\t\twriter.rename( newBlock, DEFAULT_ELEMENT );\n\t\twriter.setSelection( newBlock, 'in' );\n\t\teditor.model.schema.removeDisallowedAttributes( [ newBlock ], writer );\n\n\t\t// Remove the that originally followed the selection position.\n\t\twriter.remove( nodeAfter );\n\t} );\n\n\t// Eye candy.\n\tview.scrollToTheSelection();\n\n\treturn true;\n}\n\n// Leave the code block when Enter (but NOT Shift+Enter) has been pressed twice at the end\n// of the code block:\n//\n//\t\t// Before:\n//\t\tfoo[]\n//\n//\t\t// After first press:\n//\t\tfoo[]\n//\n//\t\t// After second press:\n//\t\tfoo[]\n//\n// @param {module:core/editor/editor~Editor} editor\n// @param {Boolean} isSoftEnter When `true`, enter was pressed along with Shift.\n// @returns {Boolean} `true` when selection left the block. `false` if stayed.\nfunction leaveBlockEndOnEnter( editor, isSoftEnter ) {\n\tconst model = editor.model;\n\tconst modelDoc = model.document;\n\tconst view = editor.editing.view;\n\tconst lastSelectionPosition = modelDoc.selection.getLastPosition();\n\tconst nodeBefore = lastSelectionPosition.nodeBefore;\n\n\tlet emptyLineRangeToRemoveOnEnter;\n\n\tif ( isSoftEnter || !modelDoc.selection.isCollapsed || !lastSelectionPosition.isAtEnd || !nodeBefore ) {\n\t\treturn false;\n\t}\n\n\t// When the position is directly preceded by a soft break\n\t//\n\t//\t\tfoo[]\n\t//\n\t// it creates the following range that will be cleaned up before leaving:\n\t//\n\t//\t\tfoo[]\n\t//\n\tif ( nodeBefore.is( 'element', 'softBreak' ) ) {\n\t\temptyLineRangeToRemoveOnEnter = model.createRangeOn( nodeBefore );\n\t}\n\n\t// When there's some text before the position made purely of white–space characters\n\t//\n\t//\t\tfoo []\n\t//\n\t// but NOT when it's the first one of the kind\n\t//\n\t//\t\t []\n\t//\n\t// it creates the following range to clean up before leaving:\n\t//\n\t//\t\tfoo[ ]\n\t//\n\telse if (\n\t\tnodeBefore.is( '$text' ) &&\n\t\t!nodeBefore.data.match( /\\S/ ) &&\n\t\tnodeBefore.previousSibling &&\n\t\tnodeBefore.previousSibling.is( 'element', 'softBreak' )\n\t) {\n\t\temptyLineRangeToRemoveOnEnter = model.createRange(\n\t\t\tmodel.createPositionBefore( nodeBefore.previousSibling ), model.createPositionAfter( nodeBefore )\n\t\t);\n\t}\n\n\t// Not leaving the block in the following cases:\n\t//\n\t//\t\t []\n\t//\t\t a []\n\t//\t\tfoobar[]\n\t//\t\tfoo a []\n\t//\n\telse {\n\t\treturn false;\n\t}\n\n\t// We're doing everything in a single change block to have a single undo step.\n\teditor.model.change( writer => {\n\t\t// Remove the last and all white space characters that followed it.\n\t\twriter.remove( emptyLineRangeToRemoveOnEnter );\n\n\t\t// \"Clone\" the in the standard way.\n\t\teditor.execute( 'enter' );\n\n\t\tconst newBlock = modelDoc.selection.anchor.parent;\n\n\t\t// Make the cloned a regular (with clean attributes, so no language).\n\t\twriter.rename( newBlock, DEFAULT_ELEMENT );\n\t\teditor.model.schema.removeDisallowedAttributes( [ newBlock ], writer );\n\t} );\n\n\t// Eye candy.\n\tview.scrollToTheSelection();\n\n\treturn true;\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/codeblockui\n */\n\nimport { Plugin } from 'ckeditor5/src/core';\nimport { Collection } from 'ckeditor5/src/utils';\nimport { Model, SplitButtonView, createDropdown, addListToDropdown } from 'ckeditor5/src/ui';\n\nimport { getNormalizedAndLocalizedLanguageDefinitions } from './utils';\n\nimport codeBlockIcon from '../theme/icons/codeblock.svg';\nimport '../theme/codeblock.css';\n\n/**\n * The code block UI plugin.\n *\n * Introduces the `'codeBlock'` dropdown.\n *\n * @extends module:core/plugin~Plugin\n */\nexport default class CodeBlockUI extends Plugin {\n\t/**\n\t * @inheritDoc\n\t */\n\tstatic get pluginName() {\n\t\treturn 'CodeBlockUI';\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tinit() {\n\t\tconst editor = this.editor;\n\t\tconst t = editor.t;\n\t\tconst componentFactory = editor.ui.componentFactory;\n\t\tconst normalizedLanguageDefs = getNormalizedAndLocalizedLanguageDefinitions( editor );\n\n\t\tcomponentFactory.add( 'codeBlock', locale => {\n\t\t\tconst command = editor.commands.get( 'codeBlock' );\n\t\t\tconst dropdownView = createDropdown( locale, SplitButtonView );\n\t\t\tconst splitButtonView = dropdownView.buttonView;\n\n\t\t\tsplitButtonView.set( {\n\t\t\t\tlabel: t( 'Insert code block' ),\n\t\t\t\ttooltip: true,\n\t\t\t\ticon: codeBlockIcon,\n\t\t\t\tisToggleable: true\n\t\t\t} );\n\n\t\t\tsplitButtonView.bind( 'isOn' ).to( command, 'value', value => !!value );\n\n\t\t\tsplitButtonView.on( 'execute', () => {\n\t\t\t\teditor.execute( 'codeBlock', {\n\t\t\t\t\tusePreviousLanguageChoice: true\n\t\t\t\t} );\n\n\t\t\t\teditor.editing.view.focus();\n\t\t\t} );\n\n\t\t\tdropdownView.on( 'execute', evt => {\n\t\t\t\teditor.execute( 'codeBlock', {\n\t\t\t\t\tlanguage: evt.source._codeBlockLanguage,\n\t\t\t\t\tforceValue: true\n\t\t\t\t} );\n\n\t\t\t\teditor.editing.view.focus();\n\t\t\t} );\n\n\t\t\tdropdownView.class = 'ck-code-block-dropdown';\n\t\t\tdropdownView.bind( 'isEnabled' ).to( command );\n\n\t\t\taddListToDropdown( dropdownView, this._getLanguageListItemDefinitions( normalizedLanguageDefs ) );\n\n\t\t\treturn dropdownView;\n\t\t} );\n\t}\n\n\t/**\n\t * A helper returning a collection of the `codeBlock` dropdown items representing languages\n\t * available for the user to choose from.\n\t *\n\t * @private\n\t * @param {Array.} normalizedLanguageDefs\n\t * @returns {Iterable.}\n\t */\n\t_getLanguageListItemDefinitions( normalizedLanguageDefs ) {\n\t\tconst editor = this.editor;\n\t\tconst command = editor.commands.get( 'codeBlock' );\n\t\tconst itemDefinitions = new Collection();\n\n\t\tfor ( const languageDef of normalizedLanguageDefs ) {\n\t\t\tconst definition = {\n\t\t\t\ttype: 'button',\n\t\t\t\tmodel: new Model( {\n\t\t\t\t\t_codeBlockLanguage: languageDef.language,\n\t\t\t\t\tlabel: languageDef.label,\n\t\t\t\t\twithText: true\n\t\t\t\t} )\n\t\t\t};\n\n\t\t\tdefinition.model.bind( 'isOn' ).to( command, 'value', value => {\n\t\t\t\treturn value === definition.model._codeBlockLanguage;\n\t\t\t} );\n\n\t\t\titemDefinitions.add( definition );\n\t\t}\n\n\t\treturn itemDefinitions;\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/codeblock\n */\n\nimport { Plugin } from 'ckeditor5/src/core';\n\nimport CodeBlockEditing from './codeblockediting';\nimport CodeBlockUI from './codeblockui';\n\n/**\n * The code block plugin.\n *\n * For more information about this feature check the {@glink api/code-block package page} and the\n * {@glink features/code-blocks code block feature guide}.\n *\n * This is a \"glue\" plugin that loads the {@link module:code-block/codeblockediting~CodeBlockEditing code block editing feature}\n * and the {@link module:code-block/codeblockui~CodeBlockUI code block UI feature}.\n *\n * @extends module:core/plugin~Plugin\n */\nexport default class CodeBlock extends Plugin {\n\t/**\n\t * @inheritDoc\n\t */\n\tstatic get requires() {\n\t\treturn [ CodeBlockEditing, CodeBlockUI ];\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tstatic get pluginName() {\n\t\treturn 'CodeBlock';\n\t}\n}\n\n/**\n * The configuration of the {@link module:code-block/codeblock~CodeBlock} feature.\n *\n * Read more in {@link module:code-block/codeblock~CodeBlockConfig}.\n *\n * @member {module:code-block/codeblock~CodeBlockConfig} module:core/editor/editorconfig~EditorConfig#codeBlock\n */\n\n/**\n * The configuration of the {@link module:code-block/codeblock~CodeBlock code block feature}.\n *\n *\t\tClassicEditor\n *\t\t\t.create( editorElement, {\n *\t\t\t\tcodeBlock: ... // The code block feature configuration.\n *\t\t\t} )\n *\t\t\t.then( ... )\n *\t\t\t.catch( ... );\n *\n * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.\n *\n * @interface CodeBlockConfig\n */\n\n/**\n * The code block language descriptor. See {@link module:code-block/codeblock~CodeBlockConfig#languages} to learn more.\n *\n *\t\t{\n *\t\t\t language: 'javascript',\n *\t\t\t label: 'JavaScript'\n *\t\t}\n *\n * @typedef {Object} module:code-block/codeblock~CodeBlockLanguageDefinition\n * @property {String} language The name of the language that will be stored in the model attribute. Also, when `class`\n * is not specified, it will be used to create the CSS class associated with the language (prefixed by \"language-\").\n * @property {String} label The human–readable label associated with the language and displayed in the UI.\n * @property {String} [class] The CSS class associated with the language. When not specified the `language`\n * property is used to create a class prefixed by \"language-\".\n */\n\n/**\n * The list of code languages available in the user interface to choose for a particular code block.\n *\n * The language of the code block is represented as a CSS class (by default prefixed by \"language-\") set on the\n * `` element, both when editing and in the editor data. The CSS class associated with the language\n * can be used by third–party code syntax highlighters to detect and apply the correct highlighting.\n *\n * For instance, this language configuration:\n *\n *\t\tClassicEditor\n *\t\t\t.create( document.querySelector( '#editor' ), {\n *\t\t\t\tcodeBlock: {\n *\t\t\t\t\tlanguages: [\n *\t\t\t\t\t\t// ...\n *\t\t\t\t\t\t{ language: 'javascript', label: 'JavaScript' },\n *\t\t\t\t\t\t// ...\n *\t\t\t\t\t]\n *\t\t\t\t}\n *\t\t} )\n *\t\t.then( ... )\n *\t\t.catch( ... );\n *\n * will result in the following structure of JavaScript code blocks in the editor editing and data:\n *\n *\t\t
window.alert( 'Hello world!' )
\n *\n * You can customize the CSS class by specifying an optional `class` property in the language definition.\n * You can set **multiple classes** but **only the first one** will be used as defining language class:\n *\n *\t\tClassicEditor\n *\t\t\t.create( document.querySelector( '#editor' ), {\n *\t\t\t\tcodeBlock: {\n *\t\t\t\t\tlanguages: [\n *\t\t\t\t\t\t// Do not render the CSS class for the plain text code blocks.\n *\t\t\t\t\t\t{ language: 'plaintext', label: 'Plain text', class: '' },\n *\n *\t\t\t\t\t\t// Use the \"php-code\" class for PHP code blocks.\n *\t\t\t\t\t\t{ language: 'php', label: 'PHP', class: 'php-code' },\n *\n *\t\t\t\t\t\t// Use the \"js\" class for JavaScript code blocks.\n *\t\t\t\t\t\t// Note that only the first (\"js\") class will determine the language of the block when loading data.\n *\t\t\t\t\t\t{ language: 'javascript', label: 'JavaScript', class: 'js javascript js-code' },\n *\n *\t\t\t\t\t\t// Python code blocks will have the default \"language-python\" CSS class.\n *\t\t\t\t\t\t{ language: 'python', label: 'Python' }\n *\t\t\t\t\t]\n *\t\t\t\t}\n *\t\t} )\n *\t\t.then( ... )\n *\t\t.catch( ... );\n *\n * The default value of the language configuration is as follows:\n *\n *\t\tlanguages: [\n *\t\t\t{ language: 'plaintext', label: 'Plain text' }, // The default language.\n *\t\t\t{ language: 'c', label: 'C' },\n *\t\t\t{ language: 'cs', label: 'C#' },\n *\t\t\t{ language: 'cpp', label: 'C++' },\n *\t\t\t{ language: 'css', label: 'CSS' },\n *\t\t\t{ language: 'diff', label: 'Diff' },\n *\t\t\t{ language: 'html', label: 'HTML' },\n *\t\t\t{ language: 'java', label: 'Java' },\n *\t\t\t{ language: 'javascript', label: 'JavaScript' },\n *\t\t\t{ language: 'php', label: 'PHP' },\n *\t\t\t{ language: 'python', label: 'Python' },\n *\t\t\t{ language: 'ruby', label: 'Ruby' },\n *\t\t\t{ language: 'typescript', label: 'TypeScript' },\n *\t\t\t{ language: 'xml', label: 'XML' }\n *\t\t]\n *\n * **Note**: The first language defined in the configuration is considered the default one. This means it will be\n * applied to code blocks loaded from the data that have no CSS `class` specified (or no matching `class` in the configuration).\n * It will also be used when creating new code blocks using the main UI button. By default it is \"Plain text\".\n *\n * @member {Array.} module:code-block/codeblock~CodeBlockConfig#languages\n */\n\n/**\n * A sequence of characters inserted or removed from the code block lines when its indentation\n * is changed by the user, for instance, using Tab and Shift+Tab keys.\n *\n * The default value is a single tab character (\"\t\", `\\u0009` in Unicode).\n *\n * This configuration is used by `indentCodeBlock` and `outdentCodeBlock` commands (instances of\n * {@link module:code-block/indentcodeblockcommand~IndentCodeBlockCommand}).\n *\n * **Note**: Setting this configuration to `false` will disable the code block indentation commands\n * and associated keystrokes.\n *\n * @member {String} module:code-block/codeblock~CodeBlockConfig#indentSequence\n */\n"],"sourceRoot":""}