diff options
author | Max <max@nextcloud.com> | 2022-01-20 11:20:41 +0300 |
---|---|---|
committer | Max <max@nextcloud.com> | 2022-01-24 14:32:39 +0300 |
commit | 260b53f6025571f161b91bd3e7a80deb8623530d (patch) | |
tree | cb27ad71b92a2e55405ae385e9ebefe58d29eb76 /src | |
parent | 4221a8243aa5a64abe8782dff838a0d4c4bafdad (diff) |
refactor: move markdownit to its own directory
Signed-off-by: Max <max@nextcloud.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/EditorFactory.js | 8 | ||||
-rw-r--r-- | src/components/EditorWrapper.vue | 3 | ||||
-rw-r--r-- | src/components/ReadOnlyEditor.vue | 3 | ||||
-rw-r--r-- | src/markdownit/index.js | 8 | ||||
-rw-r--r-- | src/marks/index.js | 2 | ||||
-rw-r--r-- | src/tests/markdown.spec.js | 3 | ||||
-rw-r--r-- | src/tests/plaintext.spec.js | 2 |
7 files changed, 17 insertions, 12 deletions
diff --git a/src/EditorFactory.js b/src/EditorFactory.js index 638ff0bd0..8f26671e6 100644 --- a/src/EditorFactory.js +++ b/src/EditorFactory.js @@ -35,8 +35,6 @@ import { } from 'tiptap-extensions' import { Strong, Italic, Strike, Link, Underline } from './marks' import { Image, PlainTextDocument, ListItem, BulletList } from './nodes' -import MarkdownIt from 'markdown-it' -import taskLists from 'markdown-it-task-lists' import { translate as t } from '@nextcloud/l10n' import 'proxy-polyfill' @@ -114,10 +112,6 @@ const createEditor = ({ content, onInit, onUpdate, extensions, enableRichEditing }) } -const markdownit = MarkdownIt('commonmark', { html: false, breaks: false }) - .enable('strikethrough') - .use(taskLists, { enable: true, labelAfter: true }) - const SerializeException = function(message) { this.message = message } @@ -167,4 +161,4 @@ const serializePlainText = (tiptap) => { } export default createEditor -export { markdownit, createEditor, createMarkdownSerializer, serializePlainText, loadSyntaxHighlight } +export { createEditor, createMarkdownSerializer, serializePlainText, loadSyntaxHighlight } diff --git a/src/components/EditorWrapper.vue b/src/components/EditorWrapper.vue index 7869aee5c..97da5a549 100644 --- a/src/components/EditorWrapper.vue +++ b/src/components/EditorWrapper.vue @@ -83,7 +83,8 @@ import moment from '@nextcloud/moment' import { SyncService, ERROR_TYPE, IDLE_TIMEOUT } from './../services/SyncService' import { endpointUrl, getRandomGuestName } from './../helpers' import { extensionHighlight } from '../helpers/mappings' -import { createEditor, markdownit, createMarkdownSerializer, serializePlainText, loadSyntaxHighlight } from './../EditorFactory' +import { createEditor, createMarkdownSerializer, serializePlainText, loadSyntaxHighlight } from './../EditorFactory' +import markdownit from './../markdownit' import { EditorContent } from 'tiptap' import { Collaboration } from 'tiptap-extensions' diff --git a/src/components/ReadOnlyEditor.vue b/src/components/ReadOnlyEditor.vue index 3bd967e2f..fe27f873c 100644 --- a/src/components/ReadOnlyEditor.vue +++ b/src/components/ReadOnlyEditor.vue @@ -27,7 +27,8 @@ <script> import { EditorContent } from 'tiptap' import escapeHtml from 'escape-html' -import { createEditor, markdownit } from '../EditorFactory' +import { createEditor } from '../EditorFactory' +import markdownit from './../markdownit' export default { name: 'ReadOnlyEditor', diff --git a/src/markdownit/index.js b/src/markdownit/index.js new file mode 100644 index 000000000..da4a6fe6d --- /dev/null +++ b/src/markdownit/index.js @@ -0,0 +1,8 @@ +import MarkdownIt from 'markdown-it' +import taskLists from 'markdown-it-task-lists' + +const markdownit = MarkdownIt('commonmark', { html: false, breaks: false }) + .enable('strikethrough') + .use(taskLists, { enable: true, labelAfter: true }) + +export default markdownit diff --git a/src/marks/index.js b/src/marks/index.js index 88c9ad995..0a6907f22 100644 --- a/src/marks/index.js +++ b/src/marks/index.js @@ -31,7 +31,7 @@ import { Plugin } from 'tiptap' import { getMarkAttrs } from 'tiptap-utils' import { markInputRule, markPasteRule } from 'tiptap-commands' import { domHref, parseHref } from './../helpers/links' -import { markdownit } from './../EditorFactory' +import markdownit from './../markdownit' /** * This file maps prosemirror mark names to tiptap classes, diff --git a/src/tests/markdown.spec.js b/src/tests/markdown.spec.js index 8e22d53ee..674f5c416 100644 --- a/src/tests/markdown.spec.js +++ b/src/tests/markdown.spec.js @@ -1,5 +1,6 @@ -import { markdownit, createEditor, createMarkdownSerializer } from './../EditorFactory'; +import { createEditor, createMarkdownSerializer } from './../EditorFactory'; import spec from "./fixtures/spec" +import markdownit from './../markdownit' const markdownThroughEditor = (markdown) => { const tiptap = createEditor({ diff --git a/src/tests/plaintext.spec.js b/src/tests/plaintext.spec.js index f64e7c2a8..d820a448f 100644 --- a/src/tests/plaintext.spec.js +++ b/src/tests/plaintext.spec.js @@ -1,4 +1,4 @@ -import { markdownit, createEditor, createMarkdownSerializer, serializePlainText } from './../EditorFactory'; +import { createEditor, serializePlainText } from './../EditorFactory'; import spec from "./fixtures/spec" import xssFuzzVectors from './fixtures/xssFuzzVectors'; |