code-block/converters
Functions
dataViewToModelCodeBlockInsertion( editingView, languageDefs ) → GetCallback<UpcastElementEvent>internalmodule:code-block/converters~dataViewToModelCodeBlockInsertionA view-to-model converter for
<pre>with the<code>HTML.Sample input:
<pre><code class="language-javascript">foo();bar();</code></pre>Copy codeSample output:
<codeBlock language="javascript">foo();bar();</codeBlock>Copy codeParameters
editingView : EditingViewlanguageDefs : Array<CodeBlockLanguageDefinition>The normalized language configuration passed to the feature.
Returns
GetCallback<UpcastElementEvent>Returns a conversion callback.
module:code-block/converters~dataViewToModelOrphanNodeConsumerA view-to-model converter that handles orphan text nodes (white spaces, new lines, etc.) that surround
<code>inside<pre>.Sample input:
// White spaces <pre> <code>foo()</code> </pre> // White spaces <pre> <code>foo()</code> </pre> // White spaces <pre> <code>foo()</code> </pre> // New lines <pre> <code>foo()</code> </pre> // Redundant text <pre>ABC<code>foo()</code>DEF</pre>Copy codeUnified output for each case:
<codeBlock language="plaintext">foo()</codeBlock>Copy codeReturns
GetCallback<UpcastElementEvent>Returns a conversion callback.
module:code-block/converters~dataViewToModelTextNewlinesInsertionA view-to-model converter for new line characters in
<pre>.Sample input:
<pre><code class="language-javascript">foo();\nbar();</code></pre>Copy codeSample output:
<codeBlock language="javascript">foo();<softBreak></softBreak>bar();</codeBlock>Copy codeReturns
GetCallback<UpcastTextEvent>Returns a conversion callback.
modelToDataViewSoftBreakInsertion( model ) → GetCallback<DowncastInsertEvent>internalmodule:code-block/converters~modelToDataViewSoftBreakInsertionA model-to-data view converter for the new line (
softBreak) separator.Sample input:
<codeBlock ...>foo();<softBreak></softBreak>bar();</codeBlock>Copy codeSample output:
<pre><code ...>foo();\nbar();</code></pre>Copy codeParameters
model : Model
Returns
GetCallback<DowncastInsertEvent>Returns a conversion callback.
modelToViewCodeBlockInsertion( model, languageDefs, useLabels ) → GetCallback<DowncastInsertEvent>internalmodule:code-block/converters~modelToViewCodeBlockInsertionA model-to-view (both editing and data) converter for the
codeBlockelement.Sample input:
<codeBlock language="javascript">foo();<softBreak></softBreak>bar();</codeBlock>Copy codeSample output (editing):
<pre data-language="JavaScript"><code class="language-javascript">foo();<br />bar();</code></pre>Copy codeSample output (data, see
modelToDataViewSoftBreakInsertion):<pre><code class="language-javascript">foo();\nbar();</code></pre>Copy codeParameters
model : ModellanguageDefs : Array<CodeBlockLanguageDefinition>The normalized language configuration passed to the feature.
useLabels : booleanWhen
true, the<pre>element will get adata-languageattribute with a human–readable label of the language. Used only in the editing.Defaults to
false
Returns
GetCallback<DowncastInsertEvent>Returns a conversion callback.