diff --git a/.eslintrc.json b/.eslintrc.json index bffb357..eb82587 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,3 +1,6 @@ { - "extends": "next/core-web-vitals" + "extends": "next/core-web-vitals", + "rules": { + "react/display-name": "off" + } } diff --git a/package-lock.json b/package-lock.json index 2319a85..4bc6905 100644 --- a/package-lock.json +++ b/package-lock.json @@ -71,6 +71,7 @@ "tippy.js": "^6.3.7" }, "devDependencies": { + "@types/markdown-it": "^13.0.7", "@types/node": "20.9.4", "@types/react": "18.2.38", "@types/react-dom": "^18", @@ -2029,6 +2030,28 @@ "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", "dev": true }, + "node_modules/@types/linkify-it": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-3.0.5.tgz", + "integrity": "sha512-yg6E+u0/+Zjva+buc3EIb+29XEg4wltq7cSmd4Uc2EE/1nUVmxyzpX6gUXD0V8jIrG0r7YeOGVIbYRkxeooCtw==", + "dev": true + }, + "node_modules/@types/markdown-it": { + "version": "13.0.7", + "resolved": "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-13.0.7.tgz", + "integrity": "sha512-U/CBi2YUUcTHBt5tjO2r5QV/x0Po6nsYwQU4Y04fBS6vfoImaiZ6f8bi3CjTCxBPQSO1LMyUqkByzi8AidyxfA==", + "dev": true, + "dependencies": { + "@types/linkify-it": "*", + "@types/mdurl": "*" + } + }, + "node_modules/@types/mdurl": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@types/mdurl/-/mdurl-1.0.5.tgz", + "integrity": "sha512-6L6VymKTzYSrEf4Nev4Xa1LCHKrlTlYCBMTlQKFuddo1CvQcE52I0mwfOJayueUC7MJuXOeHTcIU683lzd0cUA==", + "dev": true + }, "node_modules/@types/node": { "version": "20.9.4", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.9.4.tgz", diff --git a/package.json b/package.json index 8792f96..98adab1 100644 --- a/package.json +++ b/package.json @@ -76,6 +76,7 @@ "node": ">=18" }, "devDependencies": { + "@types/markdown-it": "^13.0.7", "@types/node": "20.9.4", "@types/react": "18.2.38", "@types/react-dom": "^18", diff --git a/src/components/editor/live-editor.jsx b/src/components/editor/live-editor.tsx similarity index 55% rename from src/components/editor/live-editor.jsx rename to src/components/editor/live-editor.tsx index 73af1c1..1efb625 100644 --- a/src/components/editor/live-editor.jsx +++ b/src/components/editor/live-editor.tsx @@ -19,36 +19,36 @@ import { Sidebar } from './sidebar' const md = new MarkdownIt() const extensions = [ - CommandFunctions, - TrackChangeExtension.configure({ - enabled: false, - }), - StarterKit.configure({ - bulletList: { - keepMarks: true, - keepAttributes: false, // TODO : Making this as `false` becase marks are not preserved when I try to preserve attrs, awaiting a bit of help - }, - orderedList: { - keepMarks: true, - keepAttributes: false, // TODO : Making this as `false` becase marks are not preserved when I try to preserve attrs, awaiting a bit of help - }, - }), - createSlashExtension('ai-slash', { - items: [ - { - title: 'AI 续写', - command: 'continue', - }, - { - title: 'AI 总结', - command: 'summarize', - } - ] - }), - createAiBlock(), - Color.configure({ types: [TextStyle.name, ListItem.name] }), - // @ts-ignore - TextStyle.configure({ types: [ListItem.name] }), + CommandFunctions, + TrackChangeExtension.configure({ + enabled: false, + }), + StarterKit.configure({ + bulletList: { + keepMarks: true, + keepAttributes: false, // TODO : Making this as `false` becase marks are not preserved when I try to preserve attrs, awaiting a bit of help + }, + orderedList: { + keepMarks: true, + keepAttributes: false, // TODO : Making this as `false` becase marks are not preserved when I try to preserve attrs, awaiting a bit of help + }, + }), + createSlashExtension('ai-slash', { + items: [ + { + title: 'AI 续写', + command: 'continue', + }, + { + title: 'AI 总结', + command: 'summarize', + } + ] + }), + createAiBlock(), + Color.configure({ types: [TextStyle.name, ListItem.name] }), + // @ts-ignore + TextStyle.configure({ types: [ListItem.name] }), ] const content = ` @@ -78,35 +78,35 @@ Chinese text for testing grammar and spellings, select long text to see the menu ` const LiveEditor = () => { - const editor = useEditor({ - extensions, - content: md.render(content), - editorProps: { - attributes: { - class: 'prose lg:prose-xl bb-editor-inner', - }, - }, - }) - - return (