Merge pull request #15 from ueberdosis/feature/parse-code-blocks

Add language support to Code Block’s parseDOM function
This commit is contained in:
Philipp Kühn
2020-09-30 19:21:17 +02:00
committed by GitHub
6 changed files with 44 additions and 8 deletions

View File

@@ -69,6 +69,16 @@ context('/api/extensions/code-block', () => {
})
})
it('should parse the language from a HTML code block', () => {
cy.get('.ProseMirror').then(([{ editor }]) => {
editor.setContent('<pre><code class="language-css">body { display: none; }</code></pre>')
cy.get('.ProseMirror')
.find('pre>code.language-css')
.should('have.length', 1)
})
})
it('should make a code block for js', () => {
cy.get('.ProseMirror').then(([{ editor }]) => {
editor.clearContent()

View File

@@ -17,9 +17,10 @@ yarn add @tiptap/extension-code-block
```
## Settings
| Option | Type | Default | Description |
| ------ | ------ | ------- | -------------------------------------------- |
| class | string | | Add a custom class to the rendered HTML tag. |
| Option | Type | Default | Description |
| ------------------- | ------ | --------- | ---------------------------------------------------------------- |
| class | string | | Add a custom class to the rendered HTML tag. |
| languageClassPrefix | string | language- | Adds a prefix to language classes that are applied to code tags. |
## Commands
| Command | Options | Description |