Skip to content

Commit 4788ad2

Browse files
committed
refactor(texteditor): remove tiptap-markdown with related logic
1 parent d046056 commit 4788ad2

6 files changed

Lines changed: 22 additions & 61 deletions

File tree

contentcuration/contentcuration/frontend/shared/views/TipTapEditor/TipTapEditor/DevHarness.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ try inline formulas $$x^2$$ test
3535
small text
3636
</small>
3737
38-
1. list one
38+
1. list one<sub>[1]</sub>
3939
2. list two
4040
4141
There is a [link here](https://github.com/learningequality/studio/pull/5155/checks)!

contentcuration/contentcuration/frontend/shared/views/TipTapEditor/TipTapEditor/composables/useEditor.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { Image } from '../extensions/Image';
99
import { CodeBlockSyntaxHighlight } from '../extensions/CodeBlockSyntaxHighlight';
1010
import { CustomLink } from '../extensions/Link';
1111
import { Math } from '../extensions/Math';
12-
import { Markdown } from '../extensions/Markdown';
1312
import { createCustomMarkdownSerializer } from '../utils/markdownSerializer';
1413

1514
export function useEditor() {
@@ -31,7 +30,6 @@ export function useEditor() {
3130
Image,
3231
CustomLink, // Use our custom Link extension
3332
Math,
34-
Markdown,
3533
],
3634
content: content || '<p></p>',
3735
editorProps: {
@@ -43,10 +41,11 @@ export function useEditor() {
4341
onCreate: () => {
4442
isReady.value = true;
4543

46-
const markdownStorage = editor.value.storage.markdown;
47-
if (markdownStorage) {
48-
markdownStorage.getMarkdown = createCustomMarkdownSerializer(editor.value);
44+
// Create a simple storage object to hold our custom markdown serializer
45+
if (!editor.value.storage.markdown) {
46+
editor.value.storage.markdown = {};
4947
}
48+
editor.value.storage.markdown.getMarkdown = createCustomMarkdownSerializer(editor.value);
5049
},
5150
});
5251
};

contentcuration/contentcuration/frontend/shared/views/TipTapEditor/TipTapEditor/extensions/Markdown.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

contentcuration/contentcuration/frontend/shared/views/TipTapEditor/TipTapEditor/utils/markdown.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// Contains utilities for handling Markdown content bidirectional conversion in TipTap editor.
2+
// eslint-disable-next-line import/namespace
3+
import { marked } from 'marked';
24

35
// --- Image Translation ---
46
export const IMAGE_PLACEHOLDER = 'placeholder';
@@ -53,21 +55,22 @@ export const paramsToMathMd = ({ latex }) => {
5355
*/
5456
export function preprocessMarkdown(markdown) {
5557
if (!markdown) return '';
58+
5659
let processedMarkdown = markdown;
5760

58-
// Replace custom images with standard <img> tags
61+
// First handle your custom syntax (images and math) as before
5962
processedMarkdown = processedMarkdown.replace(IMAGE_REGEX, match => {
6063
const params = imageMdToParams(match);
6164
if (!params) return match;
6265
return `<img src="${params.src}" alt="${params.alt}" width="${params.width}" height="${params.height}" />`;
6366
});
6467

65-
// Replace $$...$$ with a custom <span> tag for our Math extension
6668
processedMarkdown = processedMarkdown.replace(MATH_REGEX, match => {
6769
const params = mathMdToParams(match);
6870
if (!params) return match;
6971
return `<span data-latex="${params.latex}"></span>`;
7072
});
7173

72-
return processedMarkdown;
74+
// Use marked.js to parse the rest of the markdown
75+
return marked(processedMarkdown);
7376
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
"kolibri-design-system": "5.2.0",
8585
"lodash": "^4.17.21",
8686
"lowlight": "^3.3.0",
87+
"marked": "^16.1.1",
8788
"material-icons": "0.3.1",
8889
"mathlive": "^0.105.3",
8990
"mutex-js": "^1.1.5",
@@ -97,7 +98,6 @@
9798
"spark-md5": "^3.0.0",
9899
"store2": "^2.14.4",
99100
"string-strip-html": "8.3.0",
100-
"tiptap-markdown": "^0.8.10",
101101
"uuid": "^11.1.0",
102102
"vue": "~2.7.16",
103103
"vue-croppa": "^1.3.8",

pnpm-lock.yaml

Lines changed: 10 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)