diff options
author | Max <max@nextcloud.com> | 2022-02-07 12:46:13 +0300 |
---|---|---|
committer | Max <max@nextcloud.com> | 2022-02-09 11:42:47 +0300 |
commit | 8f64aaa06475726456ee5099a86effd03873b1eb (patch) | |
tree | f4841858b7c3d8d026bbc93c1ecfaedbb4dd3c8a /src | |
parent | a4ab0066e12c656682e29a716b866d6ed3d36ccc (diff) |
fix: use same lowlight version as tiptap
Lowlight 2.4.1 was causing failures with jest.
Jest was unhappy with it being an ESM module:
https://github.com/nextcloud/text/runs/5089748945
Do not hand around the lowlight global between EditorFactory and EditorWrapper.
Tiptaps CodeBlockLowLight does not need it anyway.
Signed-off-by: Max <max@nextcloud.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/EditorFactory.js | 18 | ||||
-rw-r--r-- | src/components/EditorWrapper.vue | 3 |
2 files changed, 9 insertions, 12 deletions
diff --git a/src/EditorFactory.js b/src/EditorFactory.js index 9b7ae8817..8a1601c16 100644 --- a/src/EditorFactory.js +++ b/src/EditorFactory.js @@ -25,9 +25,9 @@ import Text from '@tiptap/extension-text' import Heading from '@tiptap/extension-heading' import History from '@tiptap/extension-history' import Blockquote from '@tiptap/extension-blockquote' -import Codeblock from '@tiptap/extension-code-block' import Placeholder from '@tiptap/extension-placeholder' import OrderedList from '@tiptap/extension-ordered-list' +import CodeBlock from '@tiptap/extension-code-block' import CodeBlockLowlight from '@tiptap/extension-code-block-lowlight' import { Editor } from '@tiptap/core' import { Strong, Italic, Strike, Link, Underline } from './marks' @@ -40,26 +40,25 @@ import { } from './nodes' import { Markdown, Emoji } from './extensions' import { translate as t } from '@nextcloud/l10n' -import { lowlight } from 'lowlight/lib/core' +import { listLanguages, registerLanguage } from 'lowlight/lib/core' import 'proxy-polyfill' const loadSyntaxHighlight = async (language) => { - const list = lowlight.listLanguages() + const list = listLanguages() console.info(list) - if (!lowlight.listLanguages().includes(language)) { + if (!listLanguages().includes(language)) { try { const syntax = await import(/* webpackChunkName: "highlight/[request]" */'highlight.js/lib/languages/' + language) - lowlight.registerLanguage(language, syntax.default) + registerLanguage(language, syntax.default) } catch (e) { // No matching highlighing found, fallback to none console.debug(e) } } - return lowlight } -const createEditor = ({ content, onCreate, onUpdate, extensions, enableRichEditing, languages, currentDirectory }) => { +const createEditor = ({ content, onCreate, onUpdate, extensions, enableRichEditing, currentDirectory }) => { let richEditingExtensions = [] if (enableRichEditing) { richEditingExtensions = [ @@ -72,7 +71,7 @@ const createEditor = ({ content, onCreate, onUpdate, extensions, enableRichEditi Strike, Link.configure({ openOnClick: true }), Blockquote, - Codeblock, + CodeBlock, BulletList, OrderedList, ListItem, @@ -89,8 +88,7 @@ const createEditor = ({ content, onCreate, onUpdate, extensions, enableRichEditi } else { richEditingExtensions = [ PlainTextDocument, - Codeblock, - CodeBlockLowlight.configure({ lowlight }), + CodeBlockLowlight, ] } extensions = extensions || [] diff --git a/src/components/EditorWrapper.vue b/src/components/EditorWrapper.vue index 9e8a0d25f..cf0c8ab6d 100644 --- a/src/components/EditorWrapper.vue +++ b/src/components/EditorWrapper.vue @@ -329,7 +329,7 @@ export default { ? markdownit.render(documentSource) : '<pre>' + escapeHtml(documentSource) + '</pre>' const language = extensionHighlight[this.fileExtension] || this.fileExtension - loadSyntaxHighlight(language).then(lowlight => { + loadSyntaxHighlight(language).then(() => { this.tiptap = createEditor({ content, onCreate: ({ editor }) => { @@ -385,7 +385,6 @@ export default { }), ], enableRichEditing: this.isRichEditor, - lowlight, currentDirectory: this.currentDirectory, }) this.tiptap.on('focus', () => { |