@meowdown/react 0.0.2 → 0.2.0
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/dist/index.d.ts +25 -6
- package/dist/index.js +1 -1
- package/dist/style.css +194 -0
- package/package.json +14 -11
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { MarkMode, MarkMode as MarkMode$1, TypedEditor, TypedEditor as TypedEditor$1 } from "@meowdown/core";
|
|
2
|
+
|
|
3
|
+
//#region src/editor.d.ts
|
|
4
|
+
interface ChangeHandlerOptions {
|
|
5
|
+
editor: TypedEditor$1;
|
|
6
|
+
getMarkdown: () => string;
|
|
7
|
+
}
|
|
8
|
+
interface EditorProps {
|
|
9
|
+
markMode?: MarkMode$1;
|
|
10
|
+
/**
|
|
11
|
+
* The initial content of the editor, as a Markdown string. Only the value provided on
|
|
12
|
+
* the first render is used; later changes are ignored.
|
|
13
|
+
*/
|
|
14
|
+
initialContent?: string;
|
|
15
|
+
/**
|
|
16
|
+
* A callback function that is called whenever the content of the editor changes. This function should be memoized.
|
|
17
|
+
*/
|
|
18
|
+
onChange?: (options: ChangeHandlerOptions) => void;
|
|
19
|
+
}
|
|
20
|
+
declare function Editor({
|
|
21
|
+
markMode,
|
|
22
|
+
initialContent,
|
|
23
|
+
onChange
|
|
24
|
+
}: EditorProps): import("react").JSX.Element;
|
|
3
25
|
//#endregion
|
|
4
|
-
|
|
5
|
-
declare const b: number;
|
|
6
|
-
//#endregion
|
|
7
|
-
export { MyReactComponent, b };
|
|
26
|
+
export { type ChangeHandlerOptions, Editor, type EditorProps, type MarkMode, type TypedEditor };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{defineEditorExtension as e,defineMarkMode as t,docToMarkdown as n,markdownToDoc as r}from"@meowdown/core";import{createEditor as i,defineDocChangeHandler as a}from"@prosekit/core";import{ProseKit as o,useExtension as s}from"@prosekit/react";import{useMemo as c,useState as l}from"react";import{jsx as u}from"react/jsx-runtime";function d({markMode:d=`focus`,initialContent:f,onChange:p}){let[m]=l(()=>{let t=i({extension:e()});return f&&t.setContent(r(t,f)),t});s(c(()=>t(d),[d]),{editor:m});let h=c(()=>({editor:m,getMarkdown:()=>n(m.state.doc)}),[m]);return s(c(()=>p?a(()=>{p(h)}):null,[p,h]),{editor:m}),u(o,{editor:m,children:u(`div`,{ref:m.mount})})}export{d as Editor};
|
package/dist/style.css
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
.ProseMirror {
|
|
2
|
+
word-wrap: break-word;
|
|
3
|
+
white-space: pre-wrap;
|
|
4
|
+
white-space: break-spaces;
|
|
5
|
+
-webkit-font-variant-ligatures: none;
|
|
6
|
+
font-variant-ligatures: none;
|
|
7
|
+
font-feature-settings: "liga" 0;
|
|
8
|
+
position: relative;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.ProseMirror pre {
|
|
12
|
+
white-space: pre-wrap;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.ProseMirror li {
|
|
16
|
+
position: relative;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.ProseMirror-hideselection ::selection {
|
|
20
|
+
background: none;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.ProseMirror-hideselection {
|
|
24
|
+
caret-color: #0000;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.ProseMirror [draggable][contenteditable="false"] {
|
|
28
|
+
user-select: text;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.ProseMirror-selectednode {
|
|
32
|
+
outline: 2px solid #8cf;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
li.ProseMirror-selectednode {
|
|
36
|
+
outline: none;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
li.ProseMirror-selectednode:after {
|
|
40
|
+
content: "";
|
|
41
|
+
pointer-events: none;
|
|
42
|
+
border: 2px solid #8cf;
|
|
43
|
+
position: absolute;
|
|
44
|
+
inset: -2px -2px -2px -32px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
img.ProseMirror-separator {
|
|
48
|
+
border: none !important;
|
|
49
|
+
margin: 0 !important;
|
|
50
|
+
display: inline !important;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
:root {
|
|
54
|
+
--prosekit-list-bullet-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='2.5' fill='currentColor'/%3E%3C/svg%3E");
|
|
55
|
+
--prosekit-list-toggle-open-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpolygon points='8,10 12,14 16,10' fill='currentColor'/%3E%3C/svg%3E");
|
|
56
|
+
--prosekit-list-toggle-closed-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpolygon points='10,8 14,12 10,16' fill='currentColor'/%3E%3C/svg%3E");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.prosemirror-flat-list {
|
|
60
|
+
margin: 0;
|
|
61
|
+
padding: 0;
|
|
62
|
+
list-style: none;
|
|
63
|
+
position: relative;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.prosemirror-flat-list > .list-marker {
|
|
67
|
+
text-align: center;
|
|
68
|
+
width: 1lh;
|
|
69
|
+
height: 1lh;
|
|
70
|
+
position: absolute;
|
|
71
|
+
inset-inline-start: 0;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.prosemirror-flat-list > .list-content {
|
|
75
|
+
margin-inline-start: 1lh;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.prosemirror-flat-list[data-list-kind="bullet"] > .list-marker, .prosemirror-flat-list[data-list-kind="toggle"] > .list-marker {
|
|
79
|
+
background-color: currentColor;
|
|
80
|
+
mask-position: center;
|
|
81
|
+
mask-size: contain;
|
|
82
|
+
mask-repeat: no-repeat;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.prosemirror-flat-list[data-list-kind="bullet"] > .list-marker {
|
|
86
|
+
mask-image: var(--prosekit-list-bullet-icon);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.prosemirror-flat-list[data-list-kind="toggle"] > .list-marker {
|
|
90
|
+
mask-image: var(--prosekit-list-toggle-open-icon);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.prosemirror-flat-list[data-list-kind="toggle"][data-list-collapsable][data-list-collapsed] > .list-marker {
|
|
94
|
+
mask-image: var(--prosekit-list-toggle-closed-icon);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.prosemirror-flat-list[data-list-kind="ordered"] > * {
|
|
98
|
+
contain: style;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.prosemirror-flat-list[data-list-kind="ordered"]:before {
|
|
102
|
+
content: counter(prosemirror-flat-list-counter, decimal) ". ";
|
|
103
|
+
font-variant-numeric: tabular-nums;
|
|
104
|
+
position: absolute;
|
|
105
|
+
inset-inline-end: calc(100% - 1lh);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.prosemirror-flat-list[data-list-kind="ordered"] {
|
|
109
|
+
counter-increment: prosemirror-flat-list-counter;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.prosemirror-flat-list[data-list-kind="ordered"]:first-child, :not(.prosemirror-flat-list[data-list-kind="ordered"]) + .prosemirror-flat-list[data-list-kind="ordered"] {
|
|
113
|
+
counter-reset: prosemirror-flat-list-counter;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@supports (counter-set: prosemirror-flat-list-counter 1) {
|
|
117
|
+
:is(.prosemirror-flat-list[data-list-kind="ordered"]:first-child, :not(.prosemirror-flat-list[data-list-kind="ordered"]) + .prosemirror-flat-list[data-list-kind="ordered"])[data-list-order] {
|
|
118
|
+
counter-set: prosemirror-flat-list-counter var(--prosemirror-flat-list-order);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
@supports not (counter-set: prosemirror-flat-list-counter 1) {
|
|
123
|
+
:is(.prosemirror-flat-list[data-list-kind="ordered"]:first-child, :not(.prosemirror-flat-list[data-list-kind="ordered"]) + .prosemirror-flat-list[data-list-kind="ordered"])[data-list-order] {
|
|
124
|
+
counter-increment: prosemirror-flat-list-counter var(--prosemirror-flat-list-order);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.prosemirror-flat-list[data-list-kind="task"] > .list-marker, .prosemirror-flat-list[data-list-kind="task"] > .list-marker * {
|
|
129
|
+
cursor: pointer;
|
|
130
|
+
justify-content: center;
|
|
131
|
+
align-items: center;
|
|
132
|
+
margin: 0;
|
|
133
|
+
padding: 0;
|
|
134
|
+
display: flex;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.prosemirror-flat-list[data-list-kind="toggle"][data-list-collapsable] > .list-marker {
|
|
138
|
+
cursor: pointer;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.prosemirror-flat-list[data-list-kind="toggle"]:not([data-list-collapsable]) > .list-marker {
|
|
142
|
+
opacity: .4;
|
|
143
|
+
pointer-events: none;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.prosemirror-flat-list[data-list-kind="toggle"][data-list-collapsable][data-list-collapsed] > .list-content > :nth-child(n+2) {
|
|
147
|
+
display: none;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.ProseMirror .tableWrapper {
|
|
151
|
+
overflow-x: auto;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.ProseMirror table {
|
|
155
|
+
border-collapse: collapse;
|
|
156
|
+
table-layout: fixed;
|
|
157
|
+
width: 100%;
|
|
158
|
+
overflow: hidden;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.ProseMirror td, .ProseMirror th {
|
|
162
|
+
box-sizing: border-box;
|
|
163
|
+
vertical-align: top;
|
|
164
|
+
border-width: 1px;
|
|
165
|
+
padding-left: .75rem;
|
|
166
|
+
padding-right: .75rem;
|
|
167
|
+
position: relative;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
prosekit-table-handle-drop-indicator {
|
|
171
|
+
background-color: highlighttext;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.ProseMirror .column-resize-handle {
|
|
175
|
+
z-index: 20;
|
|
176
|
+
pointer-events: none;
|
|
177
|
+
background-color: highlighttext;
|
|
178
|
+
width: 4px;
|
|
179
|
+
position: absolute;
|
|
180
|
+
top: 0;
|
|
181
|
+
bottom: 0;
|
|
182
|
+
right: -2px;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.ProseMirror.resize-cursor {
|
|
186
|
+
cursor: ew-resize;
|
|
187
|
+
cursor: col-resize;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.ProseMirror .selectedCell {
|
|
191
|
+
--color: 210, 100%, 56%;
|
|
192
|
+
border: 1px double hsl(var(--color));
|
|
193
|
+
background-color: hsla(var(--color), 20%);
|
|
194
|
+
}
|
package/package.json
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meowdown/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"license": "GPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/prosekit/meowdown"
|
|
9
9
|
},
|
|
10
10
|
"exports": {
|
|
11
|
-
".":
|
|
12
|
-
|
|
13
|
-
"default": "./dist/index.js"
|
|
14
|
-
}
|
|
11
|
+
".": "./dist/index.js",
|
|
12
|
+
"./style.css": "./dist/style.css"
|
|
15
13
|
},
|
|
16
14
|
"files": [
|
|
17
15
|
"./dist/**/*.js",
|
|
18
|
-
"./dist/**/*.d.ts"
|
|
16
|
+
"./dist/**/*.d.ts",
|
|
17
|
+
"./dist/**/*.css"
|
|
19
18
|
],
|
|
20
19
|
"dependencies": {
|
|
21
|
-
"@
|
|
20
|
+
"@prosekit/core": "^0.12.3",
|
|
21
|
+
"@prosekit/react": "^0.7.6",
|
|
22
|
+
"@meowdown/core": "0.2.0"
|
|
22
23
|
},
|
|
23
24
|
"peerDependencies": {
|
|
24
25
|
"react": "*",
|
|
@@ -33,14 +34,16 @@
|
|
|
33
34
|
}
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
|
-
"@ocavue/tsconfig": "^0.7.
|
|
37
|
+
"@ocavue/tsconfig": "^0.7.1",
|
|
38
|
+
"@tsdown/css": "^0.22.2",
|
|
37
39
|
"@types/react": "^19.2.17",
|
|
38
40
|
"@types/react-dom": "^19.2.3",
|
|
39
|
-
"@vitest/browser-playwright": "^4.
|
|
41
|
+
"@vitest/browser-playwright": "^4.1.8",
|
|
40
42
|
"react": "^19.2.7",
|
|
41
43
|
"react-dom": "^19.2.7",
|
|
42
|
-
"tsdown": "^0.22.
|
|
43
|
-
"vitest": "^4.
|
|
44
|
+
"tsdown": "^0.22.2",
|
|
45
|
+
"vitest": "^4.1.8",
|
|
46
|
+
"vitest-browser-react": "^2.2.0"
|
|
44
47
|
},
|
|
45
48
|
"publishConfig": {
|
|
46
49
|
"access": "public"
|