@standardnotes/markdown-visual 1.3.1 → 1.3.3

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.
Files changed (108) hide show
  1. package/build/asset-manifest.json +83 -0
  2. package/build/index.html +1 -0
  3. package/build/static/css/main.ea19efe4.css +3 -0
  4. package/build/static/css/main.ea19efe4.css.map +1 -0
  5. package/build/static/js/main.js +3 -0
  6. package/build/static/js/main.js.LICENSE.txt +59 -0
  7. package/build/static/js/main.js.map +1 -0
  8. package/build/static/media/KaTeX_AMS-Regular..ttf +0 -0
  9. package/build/static/media/KaTeX_AMS-Regular..woff +0 -0
  10. package/build/static/media/KaTeX_AMS-Regular..woff2 +0 -0
  11. package/build/static/media/KaTeX_Caligraphic-Bold..ttf +0 -0
  12. package/build/static/media/KaTeX_Caligraphic-Bold..woff +0 -0
  13. package/build/static/media/KaTeX_Caligraphic-Bold..woff2 +0 -0
  14. package/build/static/media/KaTeX_Caligraphic-Regular..ttf +0 -0
  15. package/build/static/media/KaTeX_Caligraphic-Regular..woff +0 -0
  16. package/build/static/media/KaTeX_Caligraphic-Regular..woff2 +0 -0
  17. package/build/static/media/KaTeX_Fraktur-Bold..ttf +0 -0
  18. package/build/static/media/KaTeX_Fraktur-Bold..woff +0 -0
  19. package/build/static/media/KaTeX_Fraktur-Bold..woff2 +0 -0
  20. package/build/static/media/KaTeX_Fraktur-Regular..ttf +0 -0
  21. package/build/static/media/KaTeX_Fraktur-Regular..woff +0 -0
  22. package/build/static/media/KaTeX_Fraktur-Regular..woff2 +0 -0
  23. package/build/static/media/KaTeX_Main-Bold..ttf +0 -0
  24. package/build/static/media/KaTeX_Main-Bold..woff +0 -0
  25. package/build/static/media/KaTeX_Main-Bold..woff2 +0 -0
  26. package/build/static/media/KaTeX_Main-BoldItalic..ttf +0 -0
  27. package/build/static/media/KaTeX_Main-BoldItalic..woff +0 -0
  28. package/build/static/media/KaTeX_Main-BoldItalic..woff2 +0 -0
  29. package/build/static/media/KaTeX_Main-Italic..ttf +0 -0
  30. package/build/static/media/KaTeX_Main-Italic..woff +0 -0
  31. package/build/static/media/KaTeX_Main-Italic..woff2 +0 -0
  32. package/build/static/media/KaTeX_Main-Regular..ttf +0 -0
  33. package/build/static/media/KaTeX_Main-Regular..woff +0 -0
  34. package/build/static/media/KaTeX_Main-Regular..woff2 +0 -0
  35. package/build/static/media/KaTeX_Math-BoldItalic..ttf +0 -0
  36. package/build/static/media/KaTeX_Math-BoldItalic..woff +0 -0
  37. package/build/static/media/KaTeX_Math-BoldItalic..woff2 +0 -0
  38. package/build/static/media/KaTeX_Math-Italic..ttf +0 -0
  39. package/build/static/media/KaTeX_Math-Italic..woff +0 -0
  40. package/build/static/media/KaTeX_Math-Italic..woff2 +0 -0
  41. package/build/static/media/KaTeX_SansSerif-Bold..ttf +0 -0
  42. package/build/static/media/KaTeX_SansSerif-Bold..woff +0 -0
  43. package/build/static/media/KaTeX_SansSerif-Bold..woff2 +0 -0
  44. package/build/static/media/KaTeX_SansSerif-Italic..ttf +0 -0
  45. package/build/static/media/KaTeX_SansSerif-Italic..woff +0 -0
  46. package/build/static/media/KaTeX_SansSerif-Italic..woff2 +0 -0
  47. package/build/static/media/KaTeX_SansSerif-Regular..ttf +0 -0
  48. package/build/static/media/KaTeX_SansSerif-Regular..woff +0 -0
  49. package/build/static/media/KaTeX_SansSerif-Regular..woff2 +0 -0
  50. package/build/static/media/KaTeX_Script-Regular..ttf +0 -0
  51. package/build/static/media/KaTeX_Script-Regular..woff +0 -0
  52. package/build/static/media/KaTeX_Script-Regular..woff2 +0 -0
  53. package/build/static/media/KaTeX_Size1-Regular..ttf +0 -0
  54. package/build/static/media/KaTeX_Size1-Regular..woff +0 -0
  55. package/build/static/media/KaTeX_Size1-Regular..woff2 +0 -0
  56. package/build/static/media/KaTeX_Size2-Regular..ttf +0 -0
  57. package/build/static/media/KaTeX_Size2-Regular..woff +0 -0
  58. package/build/static/media/KaTeX_Size2-Regular..woff2 +0 -0
  59. package/build/static/media/KaTeX_Size3-Regular..ttf +0 -0
  60. package/build/static/media/KaTeX_Size3-Regular..woff +0 -0
  61. package/build/static/media/KaTeX_Size3-Regular..woff2 +0 -0
  62. package/build/static/media/KaTeX_Size4-Regular..ttf +0 -0
  63. package/build/static/media/KaTeX_Size4-Regular..woff +0 -0
  64. package/build/static/media/KaTeX_Size4-Regular..woff2 +0 -0
  65. package/build/static/media/KaTeX_Typewriter-Regular..ttf +0 -0
  66. package/build/static/media/KaTeX_Typewriter-Regular..woff +0 -0
  67. package/build/static/media/KaTeX_Typewriter-Regular..woff2 +0 -0
  68. package/build/static/media/material-icons-outlined..woff +0 -0
  69. package/build/static/media/material-icons-outlined..woff2 +0 -0
  70. package/build/static/media/material-icons-round..woff +0 -0
  71. package/build/static/media/material-icons-round..woff2 +0 -0
  72. package/build/static/media/material-icons-sharp..woff +0 -0
  73. package/build/static/media/material-icons-sharp..woff2 +0 -0
  74. package/build/static/media/material-icons-two-tone..woff +0 -0
  75. package/build/static/media/material-icons-two-tone..woff2 +0 -0
  76. package/build/static/media/material-icons..woff +0 -0
  77. package/build/static/media/material-icons..woff2 +0 -0
  78. package/package.json +7 -3
  79. package/CHANGELOG.md +0 -114
  80. package/config-overrides.js +0 -2
  81. package/public/index.html +0 -31
  82. package/src/components/CodeMirror/index.tsx +0 -94
  83. package/src/components/CodeMirror/styles.scss +0 -55
  84. package/src/components/Milkdown/editor.ts +0 -62
  85. package/src/components/Milkdown/index.tsx +0 -77
  86. package/src/components/Milkdown/plugins/advanced-menu/README.md +0 -3
  87. package/src/components/Milkdown/plugins/advanced-menu/button.ts +0 -102
  88. package/src/components/Milkdown/plugins/advanced-menu/config.ts +0 -94
  89. package/src/components/Milkdown/plugins/advanced-menu/divider.ts +0 -37
  90. package/src/components/Milkdown/plugins/advanced-menu/index.ts +0 -64
  91. package/src/components/Milkdown/plugins/advanced-menu/manager.ts +0 -122
  92. package/src/components/Milkdown/plugins/advanced-menu/menuBar.ts +0 -108
  93. package/src/components/Milkdown/plugins/advanced-menu/select.ts +0 -163
  94. package/src/components/Milkdown/styles.scss +0 -209
  95. package/src/components/SplitView/index.tsx +0 -42
  96. package/src/components/SplitView/styles.scss +0 -51
  97. package/src/index.tsx +0 -223
  98. package/src/react-app-env.d.ts +0 -1
  99. package/src/setupTests.ts +0 -5
  100. package/src/stylesheets/main.scss +0 -45
  101. package/src/stylesheets/prism/material-light.css +0 -207
  102. package/tsconfig.json +0 -21
  103. /package/{public → build}/favicon.ico +0 -0
  104. /package/{public → build}/logo192.png +0 -0
  105. /package/{public → build}/logo512.png +0 -0
  106. /package/{public → build}/manifest.json +0 -0
  107. /package/{public → build}/robots.txt +0 -0
  108. /package/{public → build}/sample.ext.json +0 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@standardnotes/markdown-visual",
3
- "version": "1.3.1",
4
- "author": "Standard Notes.",
3
+ "version": "1.3.3",
4
+ "author": "Standard Notes Retired",
5
5
  "description": "A lightweight WYSIWYG markdown editor for Standard Notes, derived from Milkdown.",
6
6
  "keywords": [
7
7
  "Standard Notes",
@@ -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": "088dd04552f474d9e0a61cb86f1d75f9d405906e"
109
+ "gitHead": "d31cb7d0c3571e8e820b1ce0534b6f37868ea733"
106
110
  }
package/CHANGELOG.md DELETED
@@ -1,114 +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.1](https://github.com/standardnotes/plugins/compare/@standardnotes/markdown-visual@1.3.0...@standardnotes/markdown-visual@1.3.1) (2023-02-13)
7
-
8
- ### Bug Fixes
9
-
10
- * markdown alternative width issue on mobile ([94a080a](https://github.com/standardnotes/plugins/commit/94a080a381e4e7c1acea95ebe7824e947ce3834b))
11
-
12
- # [1.3.0](https://github.com/standardnotes/plugins/compare/@standardnotes/markdown-visual@1.2.3...@standardnotes/markdown-visual@1.3.0) (2023-01-20)
13
-
14
- ### Features
15
-
16
- * designate markdown visual as community ([25c2b06](https://github.com/standardnotes/plugins/commit/25c2b0691c56c0eb96d5c2989ff2a9362dac37c2))
17
-
18
- ## [1.2.3](https://github.com/standardnotes/plugins/compare/@standardnotes/markdown-visual@1.2.2...@standardnotes/markdown-visual@1.2.3) (2022-11-04)
19
-
20
- **Note:** Version bump only for package @standardnotes/markdown-visual
21
-
22
- ## [1.2.2](https://github.com/standardnotes/plugins/compare/@standardnotes/markdown-visual@1.2.1...@standardnotes/markdown-visual@1.2.2) (2022-11-04)
23
-
24
- **Note:** Version bump only for package @standardnotes/markdown-visual
25
-
26
- ## [1.2.1](https://github.com/standardnotes/plugins/compare/@standardnotes/markdown-visual@1.2.0...@standardnotes/markdown-visual@1.2.1) (2022-11-04)
27
-
28
- **Note:** Version bump only for package @standardnotes/markdown-visual
29
-
30
- # 1.2.0 (2022-11-04)
31
-
32
- ### Features
33
-
34
- * add core plugins ([b607787](https://github.com/standardnotes/plugins/commit/b60778762306f5647cb715102eab23083b266718))
35
-
36
- ## [1.1.5](https://github.com/standardnotes/app/compare/@standardnotes/markdown-visual@1.1.4...@standardnotes/markdown-visual@1.1.5) (2022-11-01)
37
-
38
- **Note:** Version bump only for package @standardnotes/markdown-visual
39
-
40
- ## [1.1.4](https://github.com/standardnotes/app/compare/@standardnotes/markdown-visual@1.1.3...@standardnotes/markdown-visual@1.1.4) (2022-10-27)
41
-
42
- **Note:** Version bump only for package @standardnotes/markdown-visual
43
-
44
- ## [1.1.3](https://github.com/standardnotes/app/compare/@standardnotes/markdown-visual@1.1.2...@standardnotes/markdown-visual@1.1.3) (2022-10-05)
45
-
46
- **Note:** Version bump only for package @standardnotes/markdown-visual
47
-
48
- ## [1.1.2](https://github.com/standardnotes/app/compare/@standardnotes/markdown-visual@1.1.1...@standardnotes/markdown-visual@1.1.2) (2022-07-13)
49
-
50
- ### Bug Fixes
51
-
52
- * upgrade jest with types to latest version ([09e08ca](https://github.com/standardnotes/app/commit/09e08ca899ba8694cf43292e918c4c204c0d2cb9))
53
-
54
- ## [1.1.1](https://github.com/standardnotes/app/compare/@standardnotes/markdown-visual@1.1.0...@standardnotes/markdown-visual@1.1.1) (2022-06-30)
55
-
56
- **Note:** Version bump only for package @standardnotes/markdown-visual
57
-
58
- # [1.1.0](https://github.com/standardnotes/app/compare/@standardnotes/markdown-visual@1.0.12...@standardnotes/markdown-visual@1.1.0) (2022-06-29)
59
-
60
- ### Features
61
-
62
- * deprecated editors ([#1166](https://github.com/standardnotes/app/issues/1166)) ([60ca415](https://github.com/standardnotes/app/commit/60ca4150446f9a14bb6a31416686c6d07a7d0cd9))
63
-
64
- ## [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)
65
-
66
- **Note:** Version bump only for package @standardnotes/markdown-visual
67
-
68
- ## [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)
69
-
70
- **Note:** Version bump only for package @standardnotes/markdown-visual
71
-
72
- ## [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)
73
-
74
- **Note:** Version bump only for package @standardnotes/markdown-visual
75
-
76
- ## [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)
77
-
78
- ### Bug Fixes
79
-
80
- * components scripts ([#1136](https://github.com/standardnotes/app/issues/1136)) ([e80b4d0](https://github.com/standardnotes/app/commit/e80b4d0ffad495c758b593c30e1c4c754dda9b7e))
81
-
82
- ## [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)
83
-
84
- ### Bug Fixes
85
-
86
- * markdown visual font size ([#1127](https://github.com/standardnotes/app/issues/1127)) ([f4b9b5b](https://github.com/standardnotes/app/commit/f4b9b5b566e8d4104de71a87ee041cdc77c3ce6c))
87
-
88
- ## 1.0.10 (2022-06-16)
89
-
90
- **Note:** Version bump only for package @standardnotes/markdown-visual
91
-
92
- ## 1.0.9 (2022-06-16)
93
-
94
- **Note:** Version bump only for package @standardnotes/markdown-visual
95
-
96
- ## [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)
97
-
98
- **Note:** Version bump only for package @standardnotes/markdown-visual
99
-
100
- ## [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)
101
-
102
- **Note:** Version bump only for package @standardnotes/markdown-visual
103
-
104
- ## 1.0.8-alpha.2 (2022-06-16)
105
-
106
- **Note:** Version bump only for package @standardnotes/markdown-visual
107
-
108
- ## 1.0.8-alpha.1 (2022-06-16)
109
-
110
- **Note:** Version bump only for package @standardnotes/markdown-visual
111
-
112
- ## 1.0.8-alpha.0 (2022-06-15)
113
-
114
- **Note:** Version bump only for package @standardnotes/markdown-visual
@@ -1,2 +0,0 @@
1
- const override = require('../cra-app.override')
2
- module.exports = override
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)
@@ -1,3 +0,0 @@
1
- # advanced-menu
2
-
3
- An advanced menu plugin for [Milkdown editor](https://saul-mirone.github.io/milkdown/), which is heavily inspired on [@milkdown/plugin-menu](https://github.com/Saul-Mirone/milkdown/tree/main/packages/plugin-menu).