@tiptap/extension-code-block
Advanced tools
Comparing version 2.0.0-beta.33 to 2.0.0-beta.34
import { Node } from '@tiptap/core'; | ||
export interface CodeBlockOptions { | ||
/** | ||
* Adds a prefix to language classes that are applied to code tags. | ||
* Defaults to `'language-'`. | ||
*/ | ||
languageClassPrefix: string; | ||
/** | ||
* Define whether the node should be exited on triple enter. | ||
* Defaults to `true`. | ||
*/ | ||
exitOnTripleEnter: boolean; | ||
/** | ||
* Define whether the node should be exited on arrow down if there is no node after it. | ||
* Defaults to `true`. | ||
*/ | ||
exitOnArrowDown: boolean; | ||
/** | ||
* Custom HTML attributes that should be added to the rendered HTML tag. | ||
*/ | ||
HTMLAttributes: Record<string, any>; | ||
@@ -5,0 +22,0 @@ } |
@@ -15,2 +15,4 @@ 'use strict'; | ||
languageClassPrefix: 'language-', | ||
exitOnTripleEnter: true, | ||
exitOnArrowDown: true, | ||
HTMLAttributes: {}, | ||
@@ -88,4 +90,7 @@ }; | ||
}, | ||
// escape node on triple enter | ||
// exit node on triple enter | ||
Enter: ({ editor }) => { | ||
if (!this.options.exitOnTripleEnter) { | ||
return false; | ||
} | ||
const { state } = editor; | ||
@@ -111,4 +116,7 @@ const { selection } = state; | ||
}, | ||
// escape node on arrow down | ||
// exit node on arrow down | ||
ArrowDown: ({ editor }) => { | ||
if (!this.options.exitOnArrowDown) { | ||
return false; | ||
} | ||
const { state } = editor; | ||
@@ -115,0 +123,0 @@ const { selection, doc } = state; |
@@ -11,2 +11,4 @@ import { Node, textblockTypeInputRule } from '@tiptap/core'; | ||
languageClassPrefix: 'language-', | ||
exitOnTripleEnter: true, | ||
exitOnArrowDown: true, | ||
HTMLAttributes: {}, | ||
@@ -84,4 +86,7 @@ }; | ||
}, | ||
// escape node on triple enter | ||
// exit node on triple enter | ||
Enter: ({ editor }) => { | ||
if (!this.options.exitOnTripleEnter) { | ||
return false; | ||
} | ||
const { state } = editor; | ||
@@ -107,4 +112,7 @@ const { selection } = state; | ||
}, | ||
// escape node on arrow down | ||
// exit node on arrow down | ||
ArrowDown: ({ editor }) => { | ||
if (!this.options.exitOnArrowDown) { | ||
return false; | ||
} | ||
const { state } = editor; | ||
@@ -111,0 +119,0 @@ const { selection, doc } = state; |
@@ -14,2 +14,4 @@ (function (global, factory) { | ||
languageClassPrefix: 'language-', | ||
exitOnTripleEnter: true, | ||
exitOnArrowDown: true, | ||
HTMLAttributes: {}, | ||
@@ -87,4 +89,7 @@ }; | ||
}, | ||
// escape node on triple enter | ||
// exit node on triple enter | ||
Enter: ({ editor }) => { | ||
if (!this.options.exitOnTripleEnter) { | ||
return false; | ||
} | ||
const { state } = editor; | ||
@@ -110,4 +115,7 @@ const { selection } = state; | ||
}, | ||
// escape node on arrow down | ||
// exit node on arrow down | ||
ArrowDown: ({ editor }) => { | ||
if (!this.options.exitOnArrowDown) { | ||
return false; | ||
} | ||
const { state } = editor; | ||
@@ -114,0 +122,0 @@ const { selection, doc } = state; |
{ | ||
"name": "@tiptap/extension-code-block", | ||
"description": "code block extension for tiptap", | ||
"version": "2.0.0-beta.33", | ||
"version": "2.0.0-beta.34", | ||
"homepage": "https://tiptap.dev", | ||
@@ -34,3 +34,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "8844627773ac1cfb0d01eaf1f52b3be937701b2d" | ||
"gitHead": "0c4ab8bf68412c6f34d82e45a8600925b11ee2f5" | ||
} |
@@ -5,3 +5,20 @@ import { Node, textblockTypeInputRule } from '@tiptap/core' | ||
export interface CodeBlockOptions { | ||
/** | ||
* Adds a prefix to language classes that are applied to code tags. | ||
* Defaults to `'language-'`. | ||
*/ | ||
languageClassPrefix: string, | ||
/** | ||
* Define whether the node should be exited on triple enter. | ||
* Defaults to `true`. | ||
*/ | ||
exitOnTripleEnter: boolean, | ||
/** | ||
* Define whether the node should be exited on arrow down if there is no node after it. | ||
* Defaults to `true`. | ||
*/ | ||
exitOnArrowDown: boolean, | ||
/** | ||
* Custom HTML attributes that should be added to the rendered HTML tag. | ||
*/ | ||
HTMLAttributes: Record<string, any>, | ||
@@ -34,2 +51,4 @@ } | ||
languageClassPrefix: 'language-', | ||
exitOnTripleEnter: true, | ||
exitOnArrowDown: true, | ||
HTMLAttributes: {}, | ||
@@ -124,4 +143,8 @@ } | ||
// escape node on triple enter | ||
// exit node on triple enter | ||
Enter: ({ editor }) => { | ||
if (!this.options.exitOnTripleEnter) { | ||
return false | ||
} | ||
const { state } = editor | ||
@@ -153,4 +176,8 @@ const { selection } = state | ||
// escape node on arrow down | ||
// exit node on arrow down | ||
ArrowDown: ({ editor }) => { | ||
if (!this.options.exitOnArrowDown) { | ||
return false | ||
} | ||
const { state } = editor | ||
@@ -157,0 +184,0 @@ const { selection, doc } = state |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
75622
878