Skip to content

Commit

Permalink
chore(dependencies): Switch to new lowlight imports
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr authored and mejo- committed Jan 28, 2023
1 parent 619d544 commit 1fc013c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/EditorFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,21 @@ import { Editor } from '@tiptap/core'
import { VueRenderer } from '@tiptap/vue-2'
import { translate as t } from '@nextcloud/l10n'
import { emojiSearch } from '@nextcloud/vue'
import { listLanguages, registerLanguage } from 'lowlight/lib/core.js'
import { lowlight } from 'lowlight/lib/core.js'
import hljs from 'highlight.js'

import { logger } from './helpers/logger.js'
import { Emoji, Markdown, Mention, PlainText, RichText } from './extensions/index.js'

const loadSyntaxHighlight = async (language) => {
const list = listLanguages()
const list = hljs.listLanguages()
logger.debug('Supported languages', { list })
if (!listLanguages().includes(language)) {
if (!lowlight.listLanguages().includes(language)) {
try {
logger.debug('Loading language', language)
// eslint-disable-next-line n/no-missing-import
const syntax = await import(/* webpackChunkName: "highlight/[request]" */'highlight.js/lib/languages/' + language)
registerLanguage(language, syntax.default)
const syntax = await import(/* webpackChunkName: "highlight/[request]" */`../node_modules/highlight.js/lib/languages/${language}`)
lowlight.registerLanguage(language, syntax.default)
} catch (error) {
// fallback to none
logger.debug('No matching highlighing found', { error })
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/PlainText.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import CodeBlockLowlight from '@tiptap/extension-code-block-lowlight'
import Text from '@tiptap/extension-text'
/* eslint-enable import/no-named-as-default */

import lowlight from 'lowlight/lib/core' // eslint-disable-line n/no-missing-import
import { lowlight } from 'lowlight/lib/core.js' // eslint-disable-line n/no-missing-import

import PlainTextDocument from './../nodes/PlainTextDocument.js'

Expand Down

0 comments on commit 1fc013c

Please sign in to comment.