From 27e473c2a41618caa6dc73acdc2dcb9b1483bbcd Mon Sep 17 00:00:00 2001 From: Erick Wilder Date: Sat, 13 Oct 2018 16:22:33 +0200 Subject: [PATCH] refactor(tiptap-extensions): Do not import the full `lowlight` library. BREAKING CHANGE: `CodeBlockHighlight` was importing the full `lowlight` libraries, including _all_ syntax highlightning definitions from `highlight.js`. The new behavior changes the signature of `CodeBlockHighlight` to accept an object with all syntax highlightning definitions. This means that now the user of the library __MUST__ import languages themselves and tiptap will no longer bundle the full `highlight.js` in itself. --- .../Routes/CodeHighlighting/examples.js | 22 ++++++++++++++ .../Routes/CodeHighlighting/index.vue | 30 ++++++++++++++----- .../src/nodes/CodeBlockHighlight.js | 22 ++++++++++++-- 3 files changed, 65 insertions(+), 9 deletions(-) diff --git a/examples/Components/Routes/CodeHighlighting/examples.js b/examples/Components/Routes/CodeHighlighting/examples.js index b36ae785..62069654 100644 --- a/examples/Components/Routes/CodeHighlighting/examples.js +++ b/examples/Components/Routes/CodeHighlighting/examples.js @@ -26,3 +26,25 @@ body, .usertext { content: attr(href) } }` + + +export const explicitImportExample = `import javascript from 'highlight.js/lib/languages/javascript' +import { Editor } from 'tiptap' + +export default { + components: { + Editor + }, + data() { + return { + extensions: [ + new CodeBlockHighlightNode({ + languages: { + javascript, + css + } + }) + ] + } + } +}`; diff --git a/examples/Components/Routes/CodeHighlighting/index.vue b/examples/Components/Routes/CodeHighlighting/index.vue index e65a5288..48ff1d77 100644 --- a/examples/Components/Routes/CodeHighlighting/index.vue +++ b/examples/Components/Routes/CodeHighlighting/index.vue @@ -9,8 +9,14 @@

These are code blocks with automatic syntax highlighting based on highlight.js.

-
-
+
+
+ +

+ Note: tiptap doesn't import syntax highlighting language definitions from highlight.js. You + must import them and initialize the extension with all languages you want to support: +

+
@@ -18,6 +24,9 @@