@standardnotes/markdown-visual 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/asset-manifest.json +83 -0
- package/build/index.html +1 -0
- package/build/static/css/main.ea19efe4.css +3 -0
- package/build/static/css/main.ea19efe4.css.map +1 -0
- package/build/static/js/main.js +3 -0
- package/build/static/js/main.js.LICENSE.txt +59 -0
- package/build/static/js/main.js.map +1 -0
- package/build/static/media/KaTeX_AMS-Regular..ttf +0 -0
- package/build/static/media/KaTeX_AMS-Regular..woff +0 -0
- package/build/static/media/KaTeX_AMS-Regular..woff2 +0 -0
- package/build/static/media/KaTeX_Caligraphic-Bold..ttf +0 -0
- package/build/static/media/KaTeX_Caligraphic-Bold..woff +0 -0
- package/build/static/media/KaTeX_Caligraphic-Bold..woff2 +0 -0
- package/build/static/media/KaTeX_Caligraphic-Regular..ttf +0 -0
- package/build/static/media/KaTeX_Caligraphic-Regular..woff +0 -0
- package/build/static/media/KaTeX_Caligraphic-Regular..woff2 +0 -0
- package/build/static/media/KaTeX_Fraktur-Bold..ttf +0 -0
- package/build/static/media/KaTeX_Fraktur-Bold..woff +0 -0
- package/build/static/media/KaTeX_Fraktur-Bold..woff2 +0 -0
- package/build/static/media/KaTeX_Fraktur-Regular..ttf +0 -0
- package/build/static/media/KaTeX_Fraktur-Regular..woff +0 -0
- package/build/static/media/KaTeX_Fraktur-Regular..woff2 +0 -0
- package/build/static/media/KaTeX_Main-Bold..ttf +0 -0
- package/build/static/media/KaTeX_Main-Bold..woff +0 -0
- package/build/static/media/KaTeX_Main-Bold..woff2 +0 -0
- package/build/static/media/KaTeX_Main-BoldItalic..ttf +0 -0
- package/build/static/media/KaTeX_Main-BoldItalic..woff +0 -0
- package/build/static/media/KaTeX_Main-BoldItalic..woff2 +0 -0
- package/build/static/media/KaTeX_Main-Italic..ttf +0 -0
- package/build/static/media/KaTeX_Main-Italic..woff +0 -0
- package/build/static/media/KaTeX_Main-Italic..woff2 +0 -0
- package/build/static/media/KaTeX_Main-Regular..ttf +0 -0
- package/build/static/media/KaTeX_Main-Regular..woff +0 -0
- package/build/static/media/KaTeX_Main-Regular..woff2 +0 -0
- package/build/static/media/KaTeX_Math-BoldItalic..ttf +0 -0
- package/build/static/media/KaTeX_Math-BoldItalic..woff +0 -0
- package/build/static/media/KaTeX_Math-BoldItalic..woff2 +0 -0
- package/build/static/media/KaTeX_Math-Italic..ttf +0 -0
- package/build/static/media/KaTeX_Math-Italic..woff +0 -0
- package/build/static/media/KaTeX_Math-Italic..woff2 +0 -0
- package/build/static/media/KaTeX_SansSerif-Bold..ttf +0 -0
- package/build/static/media/KaTeX_SansSerif-Bold..woff +0 -0
- package/build/static/media/KaTeX_SansSerif-Bold..woff2 +0 -0
- package/build/static/media/KaTeX_SansSerif-Italic..ttf +0 -0
- package/build/static/media/KaTeX_SansSerif-Italic..woff +0 -0
- package/build/static/media/KaTeX_SansSerif-Italic..woff2 +0 -0
- package/build/static/media/KaTeX_SansSerif-Regular..ttf +0 -0
- package/build/static/media/KaTeX_SansSerif-Regular..woff +0 -0
- package/build/static/media/KaTeX_SansSerif-Regular..woff2 +0 -0
- package/build/static/media/KaTeX_Script-Regular..ttf +0 -0
- package/build/static/media/KaTeX_Script-Regular..woff +0 -0
- package/build/static/media/KaTeX_Script-Regular..woff2 +0 -0
- package/build/static/media/KaTeX_Size1-Regular..ttf +0 -0
- package/build/static/media/KaTeX_Size1-Regular..woff +0 -0
- package/build/static/media/KaTeX_Size1-Regular..woff2 +0 -0
- package/build/static/media/KaTeX_Size2-Regular..ttf +0 -0
- package/build/static/media/KaTeX_Size2-Regular..woff +0 -0
- package/build/static/media/KaTeX_Size2-Regular..woff2 +0 -0
- package/build/static/media/KaTeX_Size3-Regular..ttf +0 -0
- package/build/static/media/KaTeX_Size3-Regular..woff +0 -0
- package/build/static/media/KaTeX_Size3-Regular..woff2 +0 -0
- package/build/static/media/KaTeX_Size4-Regular..ttf +0 -0
- package/build/static/media/KaTeX_Size4-Regular..woff +0 -0
- package/build/static/media/KaTeX_Size4-Regular..woff2 +0 -0
- package/build/static/media/KaTeX_Typewriter-Regular..ttf +0 -0
- package/build/static/media/KaTeX_Typewriter-Regular..woff +0 -0
- package/build/static/media/KaTeX_Typewriter-Regular..woff2 +0 -0
- package/build/static/media/material-icons-outlined..woff +0 -0
- package/build/static/media/material-icons-outlined..woff2 +0 -0
- package/build/static/media/material-icons-round..woff +0 -0
- package/build/static/media/material-icons-round..woff2 +0 -0
- package/build/static/media/material-icons-sharp..woff +0 -0
- package/build/static/media/material-icons-sharp..woff2 +0 -0
- package/build/static/media/material-icons-two-tone..woff +0 -0
- package/build/static/media/material-icons-two-tone..woff2 +0 -0
- package/build/static/media/material-icons..woff +0 -0
- package/build/static/media/material-icons..woff2 +0 -0
- package/package.json +6 -2
- package/CHANGELOG.md +0 -108
- package/config-overrides.js +0 -2
- package/public/index.html +0 -31
- package/src/components/CodeMirror/index.tsx +0 -94
- package/src/components/CodeMirror/styles.scss +0 -55
- package/src/components/Milkdown/editor.ts +0 -62
- package/src/components/Milkdown/index.tsx +0 -77
- package/src/components/Milkdown/plugins/advanced-menu/README.md +0 -3
- package/src/components/Milkdown/plugins/advanced-menu/button.ts +0 -102
- package/src/components/Milkdown/plugins/advanced-menu/config.ts +0 -94
- package/src/components/Milkdown/plugins/advanced-menu/divider.ts +0 -37
- package/src/components/Milkdown/plugins/advanced-menu/index.ts +0 -64
- package/src/components/Milkdown/plugins/advanced-menu/manager.ts +0 -122
- package/src/components/Milkdown/plugins/advanced-menu/menuBar.ts +0 -108
- package/src/components/Milkdown/plugins/advanced-menu/select.ts +0 -163
- package/src/components/Milkdown/styles.scss +0 -209
- package/src/components/SplitView/index.tsx +0 -42
- package/src/components/SplitView/styles.scss +0 -51
- package/src/index.tsx +0 -215
- package/src/react-app-env.d.ts +0 -1
- package/src/setupTests.ts +0 -5
- package/src/stylesheets/main.scss +0 -45
- package/src/stylesheets/prism/material-light.css +0 -207
- package/tsconfig.json +0 -21
- /package/{public → build}/favicon.ico +0 -0
- /package/{public → build}/logo192.png +0 -0
- /package/{public → build}/logo512.png +0 -0
- /package/{public → build}/manifest.json +0 -0
- /package/{public → build}/robots.txt +0 -0
- /package/{public → build}/sample.ext.json +0 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@standardnotes/markdown-visual",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"author": "Standard Notes.",
|
|
5
5
|
"description": "A lightweight WYSIWYG markdown editor for Standard Notes, derived from Milkdown.",
|
|
6
6
|
"keywords": [
|
|
@@ -19,6 +19,10 @@
|
|
|
19
19
|
"publishConfig": {
|
|
20
20
|
"access": "public"
|
|
21
21
|
},
|
|
22
|
+
"files": [
|
|
23
|
+
"build",
|
|
24
|
+
"package.json"
|
|
25
|
+
],
|
|
22
26
|
"homepage": ".",
|
|
23
27
|
"scripts": {
|
|
24
28
|
"analyze": "source-map-explorer 'build/static/js/*.js'",
|
|
@@ -102,5 +106,5 @@
|
|
|
102
106
|
"prettier --write"
|
|
103
107
|
]
|
|
104
108
|
},
|
|
105
|
-
"gitHead": "
|
|
109
|
+
"gitHead": "6a89d185e7525c167fd55da57da72cb3ac615eff"
|
|
106
110
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
-
|
|
6
|
-
# [1.3.0](https://github.com/standardnotes/plugins/compare/@standardnotes/markdown-visual@1.2.3...@standardnotes/markdown-visual@1.3.0) (2023-01-20)
|
|
7
|
-
|
|
8
|
-
### Features
|
|
9
|
-
|
|
10
|
-
* designate markdown visual as community ([25c2b06](https://github.com/standardnotes/plugins/commit/25c2b0691c56c0eb96d5c2989ff2a9362dac37c2))
|
|
11
|
-
|
|
12
|
-
## [1.2.3](https://github.com/standardnotes/plugins/compare/@standardnotes/markdown-visual@1.2.2...@standardnotes/markdown-visual@1.2.3) (2022-11-04)
|
|
13
|
-
|
|
14
|
-
**Note:** Version bump only for package @standardnotes/markdown-visual
|
|
15
|
-
|
|
16
|
-
## [1.2.2](https://github.com/standardnotes/plugins/compare/@standardnotes/markdown-visual@1.2.1...@standardnotes/markdown-visual@1.2.2) (2022-11-04)
|
|
17
|
-
|
|
18
|
-
**Note:** Version bump only for package @standardnotes/markdown-visual
|
|
19
|
-
|
|
20
|
-
## [1.2.1](https://github.com/standardnotes/plugins/compare/@standardnotes/markdown-visual@1.2.0...@standardnotes/markdown-visual@1.2.1) (2022-11-04)
|
|
21
|
-
|
|
22
|
-
**Note:** Version bump only for package @standardnotes/markdown-visual
|
|
23
|
-
|
|
24
|
-
# 1.2.0 (2022-11-04)
|
|
25
|
-
|
|
26
|
-
### Features
|
|
27
|
-
|
|
28
|
-
* add core plugins ([b607787](https://github.com/standardnotes/plugins/commit/b60778762306f5647cb715102eab23083b266718))
|
|
29
|
-
|
|
30
|
-
## [1.1.5](https://github.com/standardnotes/app/compare/@standardnotes/markdown-visual@1.1.4...@standardnotes/markdown-visual@1.1.5) (2022-11-01)
|
|
31
|
-
|
|
32
|
-
**Note:** Version bump only for package @standardnotes/markdown-visual
|
|
33
|
-
|
|
34
|
-
## [1.1.4](https://github.com/standardnotes/app/compare/@standardnotes/markdown-visual@1.1.3...@standardnotes/markdown-visual@1.1.4) (2022-10-27)
|
|
35
|
-
|
|
36
|
-
**Note:** Version bump only for package @standardnotes/markdown-visual
|
|
37
|
-
|
|
38
|
-
## [1.1.3](https://github.com/standardnotes/app/compare/@standardnotes/markdown-visual@1.1.2...@standardnotes/markdown-visual@1.1.3) (2022-10-05)
|
|
39
|
-
|
|
40
|
-
**Note:** Version bump only for package @standardnotes/markdown-visual
|
|
41
|
-
|
|
42
|
-
## [1.1.2](https://github.com/standardnotes/app/compare/@standardnotes/markdown-visual@1.1.1...@standardnotes/markdown-visual@1.1.2) (2022-07-13)
|
|
43
|
-
|
|
44
|
-
### Bug Fixes
|
|
45
|
-
|
|
46
|
-
* upgrade jest with types to latest version ([09e08ca](https://github.com/standardnotes/app/commit/09e08ca899ba8694cf43292e918c4c204c0d2cb9))
|
|
47
|
-
|
|
48
|
-
## [1.1.1](https://github.com/standardnotes/app/compare/@standardnotes/markdown-visual@1.1.0...@standardnotes/markdown-visual@1.1.1) (2022-06-30)
|
|
49
|
-
|
|
50
|
-
**Note:** Version bump only for package @standardnotes/markdown-visual
|
|
51
|
-
|
|
52
|
-
# [1.1.0](https://github.com/standardnotes/app/compare/@standardnotes/markdown-visual@1.0.12...@standardnotes/markdown-visual@1.1.0) (2022-06-29)
|
|
53
|
-
|
|
54
|
-
### Features
|
|
55
|
-
|
|
56
|
-
* deprecated editors ([#1166](https://github.com/standardnotes/app/issues/1166)) ([60ca415](https://github.com/standardnotes/app/commit/60ca4150446f9a14bb6a31416686c6d07a7d0cd9))
|
|
57
|
-
|
|
58
|
-
## [1.0.12](https://github.com/standardnotes/app/compare/@standardnotes/markdown-visual@1.0.12-alpha.0...@standardnotes/markdown-visual@1.0.12) (2022-06-23)
|
|
59
|
-
|
|
60
|
-
**Note:** Version bump only for package @standardnotes/markdown-visual
|
|
61
|
-
|
|
62
|
-
## [1.0.12-alpha.0](https://github.com/standardnotes/app/compare/@standardnotes/markdown-visual@1.0.11...@standardnotes/markdown-visual@1.0.12-alpha.0) (2022-06-23)
|
|
63
|
-
|
|
64
|
-
**Note:** Version bump only for package @standardnotes/markdown-visual
|
|
65
|
-
|
|
66
|
-
## [1.0.11](https://github.com/standardnotes/app/compare/@standardnotes/markdown-visual@1.0.11-alpha.1...@standardnotes/markdown-visual@1.0.11) (2022-06-22)
|
|
67
|
-
|
|
68
|
-
**Note:** Version bump only for package @standardnotes/markdown-visual
|
|
69
|
-
|
|
70
|
-
## [1.0.11-alpha.1](https://github.com/standardnotes/app/compare/@standardnotes/markdown-visual@1.0.11-alpha.0...@standardnotes/markdown-visual@1.0.11-alpha.1) (2022-06-22)
|
|
71
|
-
|
|
72
|
-
### Bug Fixes
|
|
73
|
-
|
|
74
|
-
* components scripts ([#1136](https://github.com/standardnotes/app/issues/1136)) ([e80b4d0](https://github.com/standardnotes/app/commit/e80b4d0ffad495c758b593c30e1c4c754dda9b7e))
|
|
75
|
-
|
|
76
|
-
## [1.0.11-alpha.0](https://github.com/standardnotes/app/compare/@standardnotes/markdown-visual@1.0.10...@standardnotes/markdown-visual@1.0.11-alpha.0) (2022-06-21)
|
|
77
|
-
|
|
78
|
-
### Bug Fixes
|
|
79
|
-
|
|
80
|
-
* markdown visual font size ([#1127](https://github.com/standardnotes/app/issues/1127)) ([f4b9b5b](https://github.com/standardnotes/app/commit/f4b9b5b566e8d4104de71a87ee041cdc77c3ce6c))
|
|
81
|
-
|
|
82
|
-
## 1.0.10 (2022-06-16)
|
|
83
|
-
|
|
84
|
-
**Note:** Version bump only for package @standardnotes/markdown-visual
|
|
85
|
-
|
|
86
|
-
## 1.0.9 (2022-06-16)
|
|
87
|
-
|
|
88
|
-
**Note:** Version bump only for package @standardnotes/markdown-visual
|
|
89
|
-
|
|
90
|
-
## [1.0.8](https://github.com/standardnotes/app/compare/@standardnotes/markdown-visual@1.0.8-alpha.3...@standardnotes/markdown-visual@1.0.8) (2022-06-16)
|
|
91
|
-
|
|
92
|
-
**Note:** Version bump only for package @standardnotes/markdown-visual
|
|
93
|
-
|
|
94
|
-
## [1.0.8-alpha.3](https://github.com/standardnotes/app/compare/@standardnotes/markdown-visual@1.0.8-alpha.2...@standardnotes/markdown-visual@1.0.8-alpha.3) (2022-06-16)
|
|
95
|
-
|
|
96
|
-
**Note:** Version bump only for package @standardnotes/markdown-visual
|
|
97
|
-
|
|
98
|
-
## 1.0.8-alpha.2 (2022-06-16)
|
|
99
|
-
|
|
100
|
-
**Note:** Version bump only for package @standardnotes/markdown-visual
|
|
101
|
-
|
|
102
|
-
## 1.0.8-alpha.1 (2022-06-16)
|
|
103
|
-
|
|
104
|
-
**Note:** Version bump only for package @standardnotes/markdown-visual
|
|
105
|
-
|
|
106
|
-
## 1.0.8-alpha.0 (2022-06-15)
|
|
107
|
-
|
|
108
|
-
**Note:** Version bump only for package @standardnotes/markdown-visual
|
package/config-overrides.js
DELETED
package/public/index.html
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8" />
|
|
5
|
-
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
-
<meta name="theme-color" content="#000000" />
|
|
8
|
-
<meta name="description" content="A lightweight WYSIWYG markdown editor, derivated from Milkdown editor" />
|
|
9
|
-
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
|
10
|
-
<!--
|
|
11
|
-
manifest.json provides metadata used when your web app is installed on a
|
|
12
|
-
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
|
13
|
-
-->
|
|
14
|
-
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
|
15
|
-
<!--
|
|
16
|
-
Notice the use of %PUBLIC_URL% in the tags above.
|
|
17
|
-
It will be replaced with the URL of the `public` folder during the build.
|
|
18
|
-
Only files inside the `public` folder can be referenced from the HTML.
|
|
19
|
-
|
|
20
|
-
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
|
21
|
-
work correctly both with client-side routing and a non-root public URL.
|
|
22
|
-
Learn how to configure a non-root public URL by running `npm run build`.
|
|
23
|
-
-->
|
|
24
|
-
<title>Markdown Visual</title>
|
|
25
|
-
</head>
|
|
26
|
-
|
|
27
|
-
<body>
|
|
28
|
-
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
29
|
-
<div id="root"></div>
|
|
30
|
-
</body>
|
|
31
|
-
</html>
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import './styles.scss'
|
|
2
|
-
|
|
3
|
-
import { basicSetup } from '@codemirror/basic-setup'
|
|
4
|
-
import { markdown } from '@codemirror/lang-markdown'
|
|
5
|
-
import CodeMirrorReact, { EditorView, ReactCodeMirrorRef } from '@uiw/react-codemirror'
|
|
6
|
-
import { forwardRef, useImperativeHandle, useRef, useState } from 'react'
|
|
7
|
-
|
|
8
|
-
export type CodeMirrorRef = {
|
|
9
|
-
update: (markdown: string) => void
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
type CodeMirrorProps = {
|
|
13
|
-
onChange: (text: string) => void
|
|
14
|
-
value?: string
|
|
15
|
-
editable: boolean
|
|
16
|
-
spellcheck: boolean
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const CodeMirror = (
|
|
20
|
-
{ onChange, value, editable, spellcheck }: CodeMirrorProps,
|
|
21
|
-
ref: React.ForwardedRef<CodeMirrorRef>,
|
|
22
|
-
) => {
|
|
23
|
-
const [hasFocus, setFocus] = useState(false)
|
|
24
|
-
const editorRef = useRef<ReactCodeMirrorRef>(null)
|
|
25
|
-
const extensions = [
|
|
26
|
-
basicSetup,
|
|
27
|
-
markdown(),
|
|
28
|
-
EditorView.lineWrapping,
|
|
29
|
-
EditorView.updateListener.of((update) => {
|
|
30
|
-
if (update.focusChanged) {
|
|
31
|
-
setFocus(update.view.hasFocus)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (update.docChanged) {
|
|
35
|
-
const text = update.state.doc.toString()
|
|
36
|
-
onChange(text)
|
|
37
|
-
}
|
|
38
|
-
}),
|
|
39
|
-
]
|
|
40
|
-
|
|
41
|
-
useImperativeHandle(ref, () => ({
|
|
42
|
-
update: (markdown: string) => {
|
|
43
|
-
/**
|
|
44
|
-
* This will prevent the CodeMirror editor from being updated again when an update
|
|
45
|
-
* is sent back from the Milkdown editor.
|
|
46
|
-
*/
|
|
47
|
-
if (hasFocus) {
|
|
48
|
-
return
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (!editable || !editorRef.current) {
|
|
52
|
-
return
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const view = editorRef.current.view
|
|
56
|
-
if (!view) {
|
|
57
|
-
return
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const { state } = view
|
|
61
|
-
if (!state) {
|
|
62
|
-
return
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const document = state.doc
|
|
66
|
-
if (!document) {
|
|
67
|
-
return
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
view.dispatch({
|
|
71
|
-
changes: {
|
|
72
|
-
from: 0,
|
|
73
|
-
to: document.toString().length,
|
|
74
|
-
insert: markdown,
|
|
75
|
-
},
|
|
76
|
-
})
|
|
77
|
-
},
|
|
78
|
-
}))
|
|
79
|
-
|
|
80
|
-
return (
|
|
81
|
-
<div className="codemirror-container">
|
|
82
|
-
<CodeMirrorReact
|
|
83
|
-
ref={editorRef}
|
|
84
|
-
extensions={extensions}
|
|
85
|
-
value={value}
|
|
86
|
-
editable={editable}
|
|
87
|
-
spellCheck={spellcheck}
|
|
88
|
-
indentWithTab
|
|
89
|
-
/>
|
|
90
|
-
</div>
|
|
91
|
-
)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export default forwardRef<CodeMirrorRef, CodeMirrorProps>(CodeMirror)
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
.container {
|
|
2
|
-
.codemirror-container {
|
|
3
|
-
overflow-y: auto;
|
|
4
|
-
max-height: 100%;
|
|
5
|
-
|
|
6
|
-
.cm-theme-light {
|
|
7
|
-
.cm-editor {
|
|
8
|
-
background-color: var(--sn-stylekit-editor-background-color) !important;
|
|
9
|
-
color: var(--sn-stylekit-editor-foreground-color) !important;
|
|
10
|
-
font-family: var(--sn-stylekit-monospace-font);
|
|
11
|
-
-webkit-overflow-scrolling: touch;
|
|
12
|
-
font-size: calc(var(--sn-stylekit-font-size-editor) - 0.3rem);
|
|
13
|
-
|
|
14
|
-
@media only screen and (min-width: 768px) {
|
|
15
|
-
font-size: calc(var(--sn-stylekit-font-size-editor) - 0.1rem);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.cm-content {
|
|
19
|
-
caret-color: var(--sn-stylekit-editor-foreground-color) !important;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.cm-lineNumbers {
|
|
23
|
-
color: var(--sn-stylekit-neutral-color) !important;
|
|
24
|
-
opacity: 0.5;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.cm-cursor {
|
|
28
|
-
border-color: var(--sn-stylekit-info-color) !important;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.cm-gutters {
|
|
32
|
-
background-color: var(--sn-stylekit-background-color) !important;
|
|
33
|
-
color: var(--sn-stylekit-editor-foreground-color) !important;
|
|
34
|
-
border-color: var(--sn-stylekit-border-color) !important;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.ͼb {
|
|
38
|
-
color: var(--sn-stylekit-info-color) !important;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.cm-selectionBackground {
|
|
42
|
-
background: var(--sn-stylekit-info-color) !important;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.cm-activeLine {
|
|
46
|
-
background-color: var(--sn-stylekit-secondary-contrast-background-color) !important;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.cm-activeLineGutter {
|
|
50
|
-
background-color: var(--sn-stylekit-contrast-background-color) !important;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { defaultValueCtx, Editor, editorViewOptionsCtx, rootCtx } from '@milkdown/core'
|
|
2
|
-
import { clipboard } from '@milkdown/plugin-clipboard'
|
|
3
|
-
import { cursor } from '@milkdown/plugin-cursor'
|
|
4
|
-
import { diagram } from '@milkdown/plugin-diagram'
|
|
5
|
-
import { history } from '@milkdown/plugin-history'
|
|
6
|
-
import { indent } from '@milkdown/plugin-indent'
|
|
7
|
-
import { listener, listenerCtx } from '@milkdown/plugin-listener'
|
|
8
|
-
import { math } from '@milkdown/plugin-math'
|
|
9
|
-
import { prism } from '@milkdown/plugin-prism'
|
|
10
|
-
import { slash } from '@milkdown/plugin-slash'
|
|
11
|
-
import { tooltip } from '@milkdown/plugin-tooltip'
|
|
12
|
-
import { gfm } from '@milkdown/preset-gfm'
|
|
13
|
-
import { nord } from '@milkdown/theme-nord'
|
|
14
|
-
|
|
15
|
-
import { menu } from './plugins/advanced-menu'
|
|
16
|
-
import { MenuConfig } from './plugins/advanced-menu/config'
|
|
17
|
-
|
|
18
|
-
export type CreateEditorParams = {
|
|
19
|
-
root: HTMLElement | null
|
|
20
|
-
onChange: (text: string) => void
|
|
21
|
-
value?: string
|
|
22
|
-
menuConfig: MenuConfig
|
|
23
|
-
editable: boolean
|
|
24
|
-
spellcheck: boolean
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const createEditor = ({ root, onChange, value, menuConfig, editable, spellcheck }: CreateEditorParams) => {
|
|
28
|
-
const editor = Editor.make()
|
|
29
|
-
.config((ctx) => {
|
|
30
|
-
ctx.set(rootCtx, root)
|
|
31
|
-
value && ctx.set(defaultValueCtx, value)
|
|
32
|
-
|
|
33
|
-
ctx.get(listenerCtx).markdownUpdated((_, markdown) => {
|
|
34
|
-
onChange(markdown)
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
ctx.set(editorViewOptionsCtx, {
|
|
38
|
-
editable: () => editable,
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
root?.setAttribute('spellcheck', JSON.stringify(spellcheck))
|
|
42
|
-
})
|
|
43
|
-
.use(nord)
|
|
44
|
-
.use(clipboard)
|
|
45
|
-
.use(gfm)
|
|
46
|
-
.use(listener)
|
|
47
|
-
.use(math)
|
|
48
|
-
.use(indent)
|
|
49
|
-
.use(prism)
|
|
50
|
-
.use(slash)
|
|
51
|
-
.use(tooltip)
|
|
52
|
-
.use(diagram)
|
|
53
|
-
.use(cursor)
|
|
54
|
-
.use(history)
|
|
55
|
-
.use(
|
|
56
|
-
menu({
|
|
57
|
-
config: menuConfig,
|
|
58
|
-
}),
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
return editor
|
|
62
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import './styles.scss'
|
|
2
|
-
|
|
3
|
-
import { editorViewCtx, parserCtx } from '@milkdown/core'
|
|
4
|
-
import { Slice } from '@milkdown/prose'
|
|
5
|
-
import { EditorRef, ReactEditor, useEditor } from '@milkdown/react'
|
|
6
|
-
import { forwardRef, useImperativeHandle, useRef } from 'react'
|
|
7
|
-
|
|
8
|
-
import { createEditor, CreateEditorParams } from './editor'
|
|
9
|
-
import { MenuConfig } from './plugins/advanced-menu/config'
|
|
10
|
-
|
|
11
|
-
export type MilkdownRef = {
|
|
12
|
-
update: (markdown: string) => void
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
type MilkdownProps = {
|
|
16
|
-
onChange: CreateEditorParams['onChange']
|
|
17
|
-
value?: CreateEditorParams['value']
|
|
18
|
-
menuConfig: MenuConfig
|
|
19
|
-
editable: CreateEditorParams['editable']
|
|
20
|
-
spellcheck: CreateEditorParams['spellcheck']
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const Milkdown = (
|
|
24
|
-
{ onChange, value, menuConfig, editable, spellcheck }: MilkdownProps,
|
|
25
|
-
ref: React.ForwardedRef<MilkdownRef>,
|
|
26
|
-
) => {
|
|
27
|
-
const editorRef = useRef<EditorRef>(null)
|
|
28
|
-
|
|
29
|
-
useImperativeHandle(ref, () => ({
|
|
30
|
-
update: (markdown: string) => {
|
|
31
|
-
if (!editable || !editorRef.current) {
|
|
32
|
-
return
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const editor = editorRef.current.get()
|
|
36
|
-
if (!editor) {
|
|
37
|
-
return
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
editor.action((ctx) => {
|
|
41
|
-
const view = ctx.get(editorViewCtx)
|
|
42
|
-
const parser = ctx.get(parserCtx)
|
|
43
|
-
const document = parser(markdown)
|
|
44
|
-
if (!document) {
|
|
45
|
-
return
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const state = view.state
|
|
49
|
-
view.dispatch(
|
|
50
|
-
state.tr.replace(0, state.doc.content.size, new Slice(document.content, 0, 0)).setMeta('addToHistory', false),
|
|
51
|
-
)
|
|
52
|
-
})
|
|
53
|
-
},
|
|
54
|
-
}))
|
|
55
|
-
|
|
56
|
-
const editor = useEditor(
|
|
57
|
-
(root) => {
|
|
58
|
-
return createEditor({
|
|
59
|
-
root,
|
|
60
|
-
onChange,
|
|
61
|
-
value,
|
|
62
|
-
menuConfig,
|
|
63
|
-
editable,
|
|
64
|
-
spellcheck,
|
|
65
|
-
})
|
|
66
|
-
},
|
|
67
|
-
[value, onChange, value, menuConfig, editable, spellcheck],
|
|
68
|
-
)
|
|
69
|
-
|
|
70
|
-
return (
|
|
71
|
-
<div className="milkdown-container">
|
|
72
|
-
<ReactEditor ref={editorRef} editor={editor} />
|
|
73
|
-
</div>
|
|
74
|
-
)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export default forwardRef<MilkdownRef, MilkdownProps>(Milkdown)
|