\n${ReactDOMServer.renderToString(
-
{icon}
- )}
`
- } else {
- // closing tag
- return '
\n'
- }
- },
- })
-}
diff --git a/libs/shared/markdown/render.tsx b/libs/shared/markdown/render.tsx
deleted file mode 100644
index 1dd4c94ae..000000000
--- a/libs/shared/markdown/render.tsx
+++ /dev/null
@@ -1,49 +0,0 @@
-import markdownit from 'markdown-it'
-import markPlugin from 'rich-markdown-editor/dist/lib/markdown/mark'
-import embedsPlugin from 'rich-markdown-editor/dist/lib/markdown/embeds'
-import breakPlugin from 'rich-markdown-editor/dist/lib/markdown/breaks'
-import tablesPlugin from 'rich-markdown-editor/dist/lib/markdown/tables'
-import noticesPlugin from './notice-plugin'
-import underlinesPlugin from 'rich-markdown-editor/dist/lib/markdown/underlines'
-import hljs from 'highlight.js'
-
-function highlight(str: string, lang: string) {
- if (lang && hljs.getLanguage(lang)) {
- try {
- return hljs.highlight(str, { language: lang }).value
- } catch (_) {
- // nothing
- }
- }
-
- return '' // use external default escaping
-}
-
-export function renderMarkdown(src: string) {
- src = src.replace(/\\\n/g, '\n')
-
- const html = markdownit('default', {
- breaks: false,
- html: false,
- linkify: true,
- highlight,
- })
- .use(embedsPlugin([]))
- .use(breakPlugin)
- .use(markPlugin({ delim: '==', mark: 'highlight' }))
- .use(markPlugin({ delim: '!!', mark: 'placeholder' }))
- .use(underlinesPlugin)
- .use(tablesPlugin)
- .use(noticesPlugin)
- .use(require('markdown-it-task-checkbox'), {
- disabled: true,
- })
- .use(require('markdown-it-implicit-figures'), {
- figcaption: true,
- dataType: true,
- })
- .render(src)
- .trim()
-
- return html
-}
diff --git a/libs/web/state/editor.ts b/libs/web/state/editor.ts
index 0b8aa4062..f0b862aa4 100644
--- a/libs/web/state/editor.ts
+++ b/libs/web/state/editor.ts
@@ -36,13 +36,14 @@ const onSearchLink = async (keyword: string) => {
}))
}
-const useEditor = () => {
+const useEditor = (initNote?: NoteModel) => {
const {
createNoteWithTitle,
updateNote,
createNote,
- note,
+ note: noteProp,
} = NoteState.useContainer()
+ const note = initNote ?? noteProp
const {
ua: { isBrowser },
} = UIState.useContainer()
@@ -118,7 +119,7 @@ const useEditor = () => {
const onHoverLink = useCallback(
(event: MouseEvent | ReactMouseEvent) => {
- if (!isBrowser) {
+ if (!isBrowser || editorEl.current?.props.readOnly) {
return true
}
const link = event.target as HTMLLinkElement
diff --git a/package.json b/package.json
index 6f2bdcdcf..c8b787241 100644
--- a/package.json
+++ b/package.json
@@ -44,10 +44,6 @@
"localforage": "^1.9.0",
"lodash": "^4.17.21",
"lzutf8": "^0.6.0",
- "markdown-it": "^12.0.6",
- "markdown-it-container": "^3.0.0",
- "markdown-it-implicit-figures": "^0.10.0",
- "markdown-it-task-checkbox": "^1.0.6",
"markdown-link-extractor": "^1.3.0",
"md5": "^2.3.0",
"minio": "^7.0.18",
@@ -81,8 +77,6 @@
"@types/classnames": "^2.2.11",
"@types/formidable": "^1.0.32",
"@types/lodash": "^4.14.168",
- "@types/markdown-it": "^12.0.1",
- "@types/markdown-it-container": "^2.0.3",
"@types/md5": "^2.3.0",
"@types/minio": "^7.0.7",
"@types/node": "^12.12.21",
diff --git a/pages/[id].tsx b/pages/[id].tsx
index 1cbd1b809..80e03858e 100644
--- a/pages/[id].tsx
+++ b/pages/[id].tsx
@@ -9,7 +9,6 @@ import { PostContainer } from 'components/container/post-container'
import { applyCsrf } from 'libs/server/middlewares/csrf'
import { ssr, SSRContext, ServerProps } from 'libs/server/connect'
import { applyUA } from 'libs/server/middlewares/ua'
-import { applyPostWithAuth } from 'libs/server/middlewares/post'
import { isNoteLink } from 'libs/shared/note'
import { applyReset } from 'libs/server/middlewares/reset'
@@ -19,7 +18,6 @@ export default function EditNotePage({
pageMode,
baseURL,
isLoggedIn,
- post,
}: ServerProps) {
if (isLoggedIn) {
return (
@@ -31,7 +29,7 @@ export default function EditNotePage({
return (