Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #10 from ckeditor/i/5794
Browse files Browse the repository at this point in the history
Other: XML and HTML will not be treated as the same language. Closes ckeditor/ckeditor5#5794.
  • Loading branch information
Reinmar authored Mar 27, 2020
2 parents f7a497d + d1516b8 commit 58a7009
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docs/_snippets/features/code-block-custom-languages.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div id="snippet-custom-languages">
<p>Put some text in the <code>&lt;body&gt;</code>:</p>
<pre><code class="language-xml"><body>Hello world!</body></code></pre>
<pre><code class="language-html"><body>Hello world!</body></code></pre>
<p>Then set the font color:</p>
<pre><code class="language-css">body { color: red }</code></pre>
</div>
2 changes: 1 addition & 1 deletion docs/_snippets/features/code-block-custom-languages.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ClassicEditor
codeBlock: {
languages: [
{ language: 'css', label: 'CSS' },
{ language: 'xml', label: 'HTML/XML' }
{ language: 'html', label: 'HTML' }
]
}
} )
Expand Down
2 changes: 1 addition & 1 deletion docs/_snippets/features/code-block.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<textarea id="snippet-highlight">
&lt;h2>Getting started with CKEditor 5&lt;/h2>
&lt;p>First, create an HTML element with the initial content:&lt;/p>
&lt;pre>&lt;code class="language-xml">&lt;div id="editor">
&lt;pre>&lt;code class="language-html">&lt;div id="editor">
&lt;p&gt;Here goes the initial content of the editor.&lt;/p&gt;
&lt;/div>&lt;/code>&lt;/pre>

Expand Down
7 changes: 4 additions & 3 deletions docs/features/code-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ Each code block can be assigned a programming language. The language of the code
<pre><code class="language-javascript">window.alert( 'Hello world!' )</code></pre>
```

It is possible to configure which languages are available to the users. You can use the {@link module:code-block/codeblock~CodeBlockConfig#languages `codeBlock.languages`} configuration and define your own languages. For example, the following editor supports only two languages (CSS and XML/HTML):
It is possible to configure which languages are available to the users. You can use the {@link module:code-block/codeblock~CodeBlockConfig#languages `codeBlock.languages`} configuration and define your own languages. For example, the following editor supports only two languages (CSS and HTML):

```js
ClassicEditor
.create( document.querySelector( '#editor' ), {
codeBlock: {
languages: [
{ language: 'css', label: 'CSS' },
{ language: 'xml', label: 'HTML/XML' }
{ language: 'html', label: 'HTML' }
]
}
} )
Expand Down Expand Up @@ -166,13 +166,14 @@ The {@link module:code-block/codeblock~CodeBlock} plugin registers:
{ language: 'cpp', label: 'C++' },
{ language: 'css', label: 'CSS' },
{ language: 'diff', label: 'Diff' },
{ language: 'xml', label: 'HTML/XML' },
{ language: 'html', label: 'HTML' },
{ language: 'java', label: 'Java' },
{ language: 'javascript', label: 'JavaScript' },
{ language: 'php', label: 'PHP' },
{ language: 'python', label: 'Python' },
{ language: 'ruby', label: 'Ruby' },
{ language: 'typescript', label: 'TypeScript' },
{ language: 'xml', label: 'XML' }
]
```

Expand Down
3 changes: 2 additions & 1 deletion src/codeblock.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,14 @@ export default class CodeBlock extends Plugin {
* { language: 'cpp', label: 'C++' },
* { language: 'css', label: 'CSS' },
* { language: 'diff', label: 'Diff' },
* { language: 'xml', label: 'HTML/XML' },
* { language: 'html', label: 'HTML' },
* { language: 'java', label: 'Java' },
* { language: 'javascript', label: 'JavaScript' },
* { language: 'php', label: 'PHP' },
* { language: 'python', label: 'Python' },
* { language: 'ruby', label: 'Ruby' },
* { language: 'typescript', label: 'TypeScript' },
* { language: 'xml', label: 'XML' }
* ]
*
* **Note**: The first language defined in the configuration is considered the default one. This means it will be
Expand Down
5 changes: 3 additions & 2 deletions src/codeblockediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,14 @@ export default class CodeBlockEditing extends Plugin {
{ language: 'cpp', label: 'C++' },
{ language: 'css', label: 'CSS' },
{ language: 'diff', label: 'Diff' },
{ language: 'xml', label: 'HTML/XML' },
{ language: 'html', label: 'HTML' },
{ language: 'java', label: 'Java' },
{ language: 'javascript', label: 'JavaScript' },
{ language: 'php', label: 'PHP' },
{ language: 'python', label: 'Python' },
{ language: 'ruby', label: 'Ruby' },
{ language: 'typescript', label: 'TypeScript' }
{ language: 'typescript', label: 'TypeScript' },
{ language: 'xml', label: 'XML' }
],

// A single tab.
Expand Down
5 changes: 3 additions & 2 deletions tests/codeblockediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,14 @@ describe( 'CodeBlockEditing', () => {
{ language: 'cpp', label: 'C++' },
{ language: 'css', label: 'CSS' },
{ language: 'diff', label: 'Diff' },
{ language: 'xml', label: 'HTML/XML' },
{ language: 'html', label: 'HTML' },
{ language: 'java', label: 'Java' },
{ language: 'javascript', label: 'JavaScript' },
{ language: 'php', label: 'PHP' },
{ language: 'python', label: 'Python' },
{ language: 'ruby', label: 'Ruby' },
{ language: 'typescript', label: 'TypeScript' }
{ language: 'typescript', label: 'TypeScript' },
{ language: 'xml', label: 'XML' }
] );
} );
} );
Expand Down
6 changes: 5 additions & 1 deletion tests/codeblockui.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ describe( 'CodeBlockUI', () => {
withText: true
},
{
label: 'HTML/XML',
label: 'HTML',
withText: true
},
{
Expand All @@ -147,6 +147,10 @@ describe( 'CodeBlockUI', () => {
{
label: 'TypeScript',
withText: true
},
{
label: 'XML',
withText: true
}
] );
} );
Expand Down

0 comments on commit 58a7009

Please sign in to comment.