rename the code block extension, add content to the code block extension
This commit is contained in:
5
docs/src/demos/Extensions/CodeBlock/index.spec.js
Normal file
5
docs/src/demos/Extensions/CodeBlock/index.spec.js
Normal file
@@ -0,0 +1,5 @@
|
||||
context('/api/extensions/code-block', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit('/api/extensions/code-block')
|
||||
})
|
||||
})
|
||||
51
docs/src/demos/Extensions/CodeBlock/index.vue
Normal file
51
docs/src/demos/Extensions/CodeBlock/index.vue
Normal file
@@ -0,0 +1,51 @@
|
||||
<template>
|
||||
<div v-if="editor">
|
||||
<button @click="editor.focus().codeBlock()" :class="{ 'is-active': editor.isActive('codeBlock') }">
|
||||
code block
|
||||
</button>
|
||||
|
||||
<editor-content :editor="editor" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { Editor } from '@tiptap/core'
|
||||
import { EditorContent } from '@tiptap/vue'
|
||||
import Document from '@tiptap/extension-document'
|
||||
import Paragraph from '@tiptap/extension-paragraph'
|
||||
import Text from '@tiptap/extension-text'
|
||||
import CodeBlock from '@tiptap/extension-code-block'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
EditorContent,
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
editor: null,
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.editor = new Editor({
|
||||
extensions: [
|
||||
Document(),
|
||||
Paragraph(),
|
||||
Text(),
|
||||
CodeBlock(),
|
||||
],
|
||||
content: `
|
||||
<p>This is a code block:</p>
|
||||
<pre><code>const foo = 'bar'</code></pre>
|
||||
`,
|
||||
})
|
||||
|
||||
window.editor = this.editor
|
||||
},
|
||||
|
||||
beforeDestroy() {
|
||||
this.editor.destroy()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -37,7 +37,7 @@ import History from '@tiptap/extension-history'
|
||||
import Bold from '@tiptap/extension-bold'
|
||||
import Italic from '@tiptap/extension-italic'
|
||||
import Code from '@tiptap/extension-code'
|
||||
import CodeBlock from '@tiptap/extension-codeblock'
|
||||
import CodeBlock from '@tiptap/extension-code-block'
|
||||
import Heading from '@tiptap/extension-heading'
|
||||
|
||||
export default {
|
||||
|
||||
@@ -2,10 +2,20 @@
|
||||
Enables you to use the `<pre>` HTML tag in the editor.
|
||||
|
||||
## Options
|
||||
*None*
|
||||
| Option | Type | Default | Description |
|
||||
| ------ | ------ | ------- | -------------------------------------------- |
|
||||
| class | string | – | Add a custom class to the rendered HTML tag. |
|
||||
|
||||
## Commands
|
||||
*None*
|
||||
| Command | Options | Description |
|
||||
| --------- | ------- | ----------------------------- |
|
||||
| codeBlock | — | Wrap content in a code block. |
|
||||
|
||||
## Keyboard shortcuts
|
||||
*None*
|
||||
* `Shift` + `Control` + `\`
|
||||
|
||||
## Source Code
|
||||
[packages/extension-code-block/](https://github.com/ueberdosis/tiptap-next/blob/main/packages/extension-code-block/)
|
||||
|
||||
## Usage
|
||||
<demo name="Extensions/CodeBlock" highlight="3-5,17,36" />
|
||||
|
||||
Reference in New Issue
Block a user