Skip to content

Commit 9c963c9

Browse files
committed
chore: update
1 parent dcb1b7b commit 9c963c9

File tree

6 files changed

+9
-25
lines changed

6 files changed

+9
-25
lines changed

playground/src/App.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ function convertBase64ToBlob(base64: string) {
130130
// custom document to support columns
131131
const DocumentColumn = /* @__PURE__ */ Document.extend({
132132
content: '(block|columns)+',
133-
// echo editor is a block editor
134133
});
135134

136135
const MOCK_USERS = [{

src/components/Bubble/RichTextBubbleKatex.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import { useAttributes } from '@/hooks/useAttributes';
1414
import { useLocale } from '@/locales';
1515
import { useEditorInstance } from '@/store/editor';
1616
import { useEditableEditor } from '@/store/store';
17-
import { parseJSONString } from '@/utils/columns';
1817
import { deleteNode } from '@/utils/delete-node';
18+
import { safeJSONParse } from '@/utils/json';
1919

2020
function ModalEditKatex({
2121
children,
@@ -54,7 +54,7 @@ function ModalEditKatex({
5454
const formatText = useMemo(() => {
5555
try {
5656
return katexLib.renderToString(currentValue, {
57-
macros: parseJSONString(currentMacros || '')
57+
macros: safeJSONParse(currentMacros || '')
5858
});
5959
} catch {
6060
return currentValue;

src/extensions/Katex/components/KatexWrapper.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ import { useMemo } from 'react';
33
import { NodeViewWrapper } from '@tiptap/react';
44
import katexLib from 'katex';
55

6-
import { parseJSONString } from '@/utils/columns';
6+
import { safeJSONParse } from '@/utils/json';
77

88
export function KatexNodeView({ node }: any) {
99
const { text, macros } = node.attrs;
1010

1111
const formatText = useMemo(() => {
1212
try {
1313
return katexLib.renderToString(decodeURIComponent(text || ''), {
14-
macros: parseJSONString(decodeURIComponent(macros || ''))
14+
macros: safeJSONParse(decodeURIComponent(macros || ''))
1515
});
1616
} catch {
1717
return text;

src/extensions/Katex/components/RichTextKatex.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { useAttributes } from '@/hooks/useAttributes';
1212
import { useButtonProps } from '@/hooks/useButtonProps';
1313
import { useLocale } from '@/locales';
1414
import { useEditorInstance } from '@/store/editor';
15-
import { parseJSONString } from '@/utils/columns';
15+
import { safeJSONParse } from '@/utils/json';
1616

1717
export function RichTextKatex() {
1818
const { t } = useLocale();
@@ -55,7 +55,7 @@ export function RichTextKatex() {
5555
const formatText = useMemo(() => {
5656
try {
5757
return katexLib.renderToString(currentValue, {
58-
macros: parseJSONString(currentMacros)
58+
macros: safeJSONParse(currentMacros)
5959
});
6060
} catch {
6161
return currentValue;

src/utils/columns.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -140,19 +140,3 @@ export function gotoCol({ state, dispatch, type }: { state: EditorState, dispatc
140140

141141
return false;
142142
}
143-
144-
export function toJSONString (obj: any) {
145-
try {
146-
return JSON.stringify(obj);
147-
} catch {
148-
return '';
149-
}
150-
}
151-
152-
export function parseJSONString (str: string) {
153-
try {
154-
return JSON.parse(str);
155-
} catch {
156-
return {};
157-
}
158-
}

src/utils/pdf.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Editor } from '@tiptap/core';
2-
import { ExportPdfOptions } from '@/extensions/ExportPdf';
2+
3+
import { type ExportPdfOptions } from '@/extensions/ExportPdf';
34

45
function printHtml(content: string, exportPdfOptions: ExportPdfOptions) {
56
const iframe: HTMLIFrameElement = document.createElement('iframe');
@@ -15,7 +16,7 @@ function printHtml(content: string, exportPdfOptions: ExportPdfOptions) {
1516

1617
const {
1718
paperSize,
18-
title = 'Echo Editor',
19+
title = 'React Tiptap Editor',
1920
margins: {
2021
top: marginTop,
2122
right: marginRight,

0 commit comments

Comments
 (0)