x-star-editor 0.2.4 → 0.2.5
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/components/Toolbar.d.ts +3 -3
- package/dist/components/Toolbar.js +53 -9
- package/dist/icons/EditOnly.d.ts +4 -0
- package/dist/icons/EditOnly.js +15 -0
- package/dist/icons/Help.d.ts +4 -0
- package/dist/icons/Help.js +26 -0
- package/dist/icons/Mermaid.d.ts +4 -0
- package/dist/icons/Mermaid.js +15 -0
- package/dist/icons/TaskList.d.ts +4 -0
- package/dist/icons/TaskList.js +24 -0
- package/dist/icons/ViewOnly.d.ts +4 -0
- package/dist/icons/ViewOnly.js +15 -0
- package/dist/index.d.ts +2 -1
- package/dist/locales/en_US.d.ts +5 -0
- package/dist/locales/en_US.js +6 -1
- package/dist/locales/index.d.ts +20 -0
- package/dist/locales/zh_CN.d.ts +5 -0
- package/dist/locales/zh_CN.js +6 -1
- package/dist/utils/container.js +14 -14
- package/dist/utils/history.d.ts +3 -1
- package/dist/utils/history.js +17 -13
- package/dist/utils/markdown.d.ts +3 -11
- package/dist/utils/markdown.js +61 -55
- package/dist/utils/rehype/rehype-line.d.ts +6 -0
- package/dist/utils/rehype/rehype-line.js +17 -0
- package/dist/utils/rehype/rehype-math.d.ts +13 -0
- package/dist/utils/rehype/rehype-math.js +167 -0
- package/dist/utils/rehype/rehype-raw-positions.d.ts +6 -0
- package/dist/utils/rehype/rehype-raw-positions.js +30 -0
- package/dist/x-star-md-editor/index.js +2 -5
- package/dist/x-star-md-viewer/index.js +6 -8
- package/package.json +4 -2
|
@@ -7,7 +7,7 @@ interface ToolbarItemProps {
|
|
|
7
7
|
popoverRender?: (exec: Executor, close: () => void) => React.ReactNode;
|
|
8
8
|
onClick?: (exec: Executor) => void;
|
|
9
9
|
}
|
|
10
|
-
type ToolbarItem = ToolbarItemProps | Handler<ToolbarItemProps>;
|
|
10
|
+
export type ToolbarItem = ToolbarItemProps | Handler<ToolbarItemProps>;
|
|
11
11
|
export type ToolbarItemMap = Partial<Record<string, ToolbarItem>>;
|
|
12
12
|
export declare const getDefaultToolbarItemMap: (locale?: string, onInsertFile?: ((file: File, options: {
|
|
13
13
|
description: string;
|
|
@@ -18,8 +18,8 @@ export declare const getDefaultToolbarItems: () => ToolbarItems;
|
|
|
18
18
|
interface ToolbarProps {
|
|
19
19
|
className?: string;
|
|
20
20
|
style?: React.CSSProperties;
|
|
21
|
-
itemMap:
|
|
22
|
-
items:
|
|
21
|
+
itemMap: ToolbarItemMap;
|
|
22
|
+
items: ToolbarItems;
|
|
23
23
|
exec: Executor;
|
|
24
24
|
}
|
|
25
25
|
declare const Toolbar: ({ className, style, itemMap, items, exec }: ToolbarProps) => React.JSX.Element;
|
|
@@ -5,26 +5,30 @@ import React, { useEffect, useRef, useState } from 'react';
|
|
|
5
5
|
import SvgBlockquote from "../icons/Blockquote";
|
|
6
6
|
import SvgCode from "../icons/Code";
|
|
7
7
|
import SvgDelete from "../icons/Delete";
|
|
8
|
+
import SvgEditOnly from "../icons/EditOnly";
|
|
8
9
|
import SvgEmphasis from "../icons/Emphasis";
|
|
9
10
|
import SvgEnterFullscreen from "../icons/EnterFullscreen";
|
|
10
11
|
import SvgExitFullscreen from "../icons/ExitFullscreen";
|
|
11
12
|
import SvgHeading from "../icons/Heading";
|
|
13
|
+
import SvgHelp from "../icons/Help";
|
|
12
14
|
import SvgImage from "../icons/Image";
|
|
13
15
|
import SvgInlineCode from "../icons/InlineCode";
|
|
14
16
|
import SvgInlineMath from "../icons/InlineMath";
|
|
15
17
|
import SvgLink from "../icons/Link";
|
|
16
18
|
import SvgMath from "../icons/Math";
|
|
19
|
+
import SvgMermaid from "../icons/Mermaid";
|
|
17
20
|
import SvgOrderedList from "../icons/OrderedList";
|
|
18
21
|
import SvgRedo from "../icons/Redo";
|
|
19
22
|
import SvgStrong from "../icons/Strong";
|
|
20
23
|
import SvgTable from "../icons/Table";
|
|
24
|
+
import SvgTaskList from "../icons/TaskList";
|
|
21
25
|
import SvgThematicBreak from "../icons/ThematicBreak";
|
|
22
26
|
import SvgToHTML from "../icons/ToHtml";
|
|
23
27
|
import SvgToMarkdown from "../icons/ToMarkdown";
|
|
24
28
|
import SvgUndo from "../icons/Undo";
|
|
25
29
|
import SvgUnorderedList from "../icons/UnorderedList";
|
|
30
|
+
import SvgViewOnly from "../icons/ViewOnly";
|
|
26
31
|
import { getFormat } from "../locales";
|
|
27
|
-
import { createSelection } from "../utils/container";
|
|
28
32
|
import { prefix } from "../utils/global";
|
|
29
33
|
import { redoHandler, toggleHandler, undoHandler } from "../utils/handler";
|
|
30
34
|
import { toHTML, toMarkdown } from "../utils/markdown";
|
|
@@ -131,13 +135,15 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap() {
|
|
|
131
135
|
}),
|
|
132
136
|
tooltip: t('code'),
|
|
133
137
|
popoverRender: function popoverRender(exec, close) {
|
|
134
|
-
var optionRender = function optionRender(label,
|
|
138
|
+
var optionRender = function optionRender(label, lang) {
|
|
135
139
|
return /*#__PURE__*/React.createElement("div", {
|
|
136
140
|
className: classNames("".concat(prefix, "option")),
|
|
137
141
|
onClick: function onClick() {
|
|
138
142
|
exec(toggleHandler({
|
|
139
143
|
type: 'code',
|
|
140
|
-
|
|
144
|
+
lang: lang,
|
|
145
|
+
value: '',
|
|
146
|
+
showLineNumbers: true
|
|
141
147
|
}));
|
|
142
148
|
close();
|
|
143
149
|
}
|
|
@@ -157,6 +163,12 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap() {
|
|
|
157
163
|
}));
|
|
158
164
|
}
|
|
159
165
|
},
|
|
166
|
+
editOnly: {
|
|
167
|
+
children: /*#__PURE__*/React.createElement(SvgEditOnly, {
|
|
168
|
+
className: classNames("".concat(prefix, "icon"))
|
|
169
|
+
}),
|
|
170
|
+
tooltip: t('editOnly')
|
|
171
|
+
},
|
|
160
172
|
emphasis: {
|
|
161
173
|
children: /*#__PURE__*/React.createElement(SvgEmphasis, {
|
|
162
174
|
className: classNames("".concat(prefix, "icon"))
|
|
@@ -200,6 +212,12 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap() {
|
|
|
200
212
|
return /*#__PURE__*/React.createElement(React.Fragment, null, optionRender(1, '1.6em'), optionRender(2, '1.3em'), optionRender(3, '1.2em'), optionRender(4, '1.1em'), optionRender(5, '1em'), optionRender(6, '0.9em'));
|
|
201
213
|
}
|
|
202
214
|
},
|
|
215
|
+
help: {
|
|
216
|
+
children: /*#__PURE__*/React.createElement(SvgHelp, {
|
|
217
|
+
className: classNames("".concat(prefix, "icon"))
|
|
218
|
+
}),
|
|
219
|
+
tooltip: t('help')
|
|
220
|
+
},
|
|
203
221
|
image: {
|
|
204
222
|
children: /*#__PURE__*/React.createElement(SvgImage, {
|
|
205
223
|
className: classNames("".concat(prefix, "icon"))
|
|
@@ -285,6 +303,20 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap() {
|
|
|
285
303
|
}));
|
|
286
304
|
}
|
|
287
305
|
},
|
|
306
|
+
mermaid: {
|
|
307
|
+
children: /*#__PURE__*/React.createElement(SvgMermaid, {
|
|
308
|
+
className: classNames("".concat(prefix, "icon"))
|
|
309
|
+
}),
|
|
310
|
+
tooltip: t('mermaid'),
|
|
311
|
+
onClick: function onClick(exec) {
|
|
312
|
+
return exec(toggleHandler({
|
|
313
|
+
type: 'code',
|
|
314
|
+
lang: 'mermaid',
|
|
315
|
+
value: "flowchart TB\n A --> C\n A --> D\n B --> C\n B --> D",
|
|
316
|
+
showLineNumbers: false
|
|
317
|
+
}));
|
|
318
|
+
}
|
|
319
|
+
},
|
|
288
320
|
orderedList: {
|
|
289
321
|
children: /*#__PURE__*/React.createElement(SvgOrderedList, {
|
|
290
322
|
className: classNames("".concat(prefix, "icon"))
|
|
@@ -321,6 +353,12 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap() {
|
|
|
321
353
|
}),
|
|
322
354
|
tooltip: t('table')
|
|
323
355
|
},
|
|
356
|
+
taskList: {
|
|
357
|
+
children: /*#__PURE__*/React.createElement(SvgTaskList, {
|
|
358
|
+
className: classNames("".concat(prefix, "icon"))
|
|
359
|
+
}),
|
|
360
|
+
tooltip: t('taskList')
|
|
361
|
+
},
|
|
324
362
|
thematicBreak: {
|
|
325
363
|
children: /*#__PURE__*/React.createElement(SvgThematicBreak, {
|
|
326
364
|
className: classNames("".concat(prefix, "icon"))
|
|
@@ -346,7 +384,7 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap() {
|
|
|
346
384
|
type: 'set',
|
|
347
385
|
payload: {
|
|
348
386
|
sourceCode: toHTML(sourceCode),
|
|
349
|
-
selection:
|
|
387
|
+
selection: selection
|
|
350
388
|
},
|
|
351
389
|
selection: selection
|
|
352
390
|
});
|
|
@@ -367,7 +405,7 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap() {
|
|
|
367
405
|
type: 'set',
|
|
368
406
|
payload: {
|
|
369
407
|
sourceCode: toMarkdown(sourceCode),
|
|
370
|
-
selection:
|
|
408
|
+
selection: selection
|
|
371
409
|
},
|
|
372
410
|
selection: selection
|
|
373
411
|
});
|
|
@@ -392,14 +430,20 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap() {
|
|
|
392
430
|
className: classNames("".concat(prefix, "icon"))
|
|
393
431
|
}),
|
|
394
432
|
tooltip: t('unorderedList')
|
|
433
|
+
},
|
|
434
|
+
viewOnly: {
|
|
435
|
+
children: /*#__PURE__*/React.createElement(SvgViewOnly, {
|
|
436
|
+
className: classNames("".concat(prefix, "icon"))
|
|
437
|
+
}),
|
|
438
|
+
tooltip: t('viewOnly')
|
|
395
439
|
}
|
|
396
440
|
};
|
|
397
441
|
};
|
|
398
442
|
export var getDefaultToolbarItems = function getDefaultToolbarItems() {
|
|
399
|
-
return [['heading', 'strong', 'emphasis', 'delete'], ['thematicBreak', 'blockquote'],
|
|
400
|
-
// ['
|
|
401
|
-
['
|
|
402
|
-
// ['fullscreen'],
|
|
443
|
+
return [['heading', 'strong', 'emphasis', 'delete'], ['thematicBreak', 'blockquote' /** 'table' */], ['link', 'image', 'mermaid'], ['inlineCode', 'code', 'inlineMath', 'math'], ['undo', 'redo'],
|
|
444
|
+
// ['orderedList', 'unorderedList', 'taskList'],
|
|
445
|
+
['toMarkdown', 'toHTML']
|
|
446
|
+
// ['help', 'editOnly', 'viewOnly', 'fullscreen'],
|
|
403
447
|
];
|
|
404
448
|
};
|
|
405
449
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
var SvgEditOnly = function SvgEditOnly(props) {
|
|
4
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
5
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
6
|
+
width: "1em",
|
|
7
|
+
height: "1em",
|
|
8
|
+
viewBox: "0 0 24 24"
|
|
9
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
|
10
|
+
fill: "currentColor",
|
|
11
|
+
fillRule: "nonzero",
|
|
12
|
+
d: "M15.992 6.531h.916c.05 0 .092.05.092.11v10.718c0 .06-.041.11-.092.11h-.916c-.05 0-.092-.05-.092-.11V6.641c0-.06.041-.11.092-.11Zm-1.859 0c.255 0 .46.204.46.456v10.025a.458.458 0 0 1-.46.455H7.454a.458.458 0 0 1-.46-.455V6.987c0-.252.206-.456.46-.456h6.68ZM7.998 16.49h5.6v-9h-5.6v9Z"
|
|
13
|
+
}));
|
|
14
|
+
};
|
|
15
|
+
export default SvgEditOnly;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
var SvgHelp = function SvgHelp(props) {
|
|
4
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
5
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
6
|
+
width: "1em",
|
|
7
|
+
height: "1em",
|
|
8
|
+
viewBox: "0 0 24 24"
|
|
9
|
+
}, props), /*#__PURE__*/React.createElement("g", {
|
|
10
|
+
fill: "none",
|
|
11
|
+
fillRule: "evenodd",
|
|
12
|
+
transform: "translate(5 5)"
|
|
13
|
+
}, /*#__PURE__*/React.createElement("rect", {
|
|
14
|
+
width: 10,
|
|
15
|
+
height: 10,
|
|
16
|
+
x: 2,
|
|
17
|
+
y: 2,
|
|
18
|
+
stroke: "currentColor",
|
|
19
|
+
rx: 1
|
|
20
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
21
|
+
fill: "currentColor",
|
|
22
|
+
fillRule: "nonzero",
|
|
23
|
+
d: "M8.526 4.33A2.305 2.305 0 0 0 7 3.773c-.574 0-1.116.199-1.526.557a1.864 1.864 0 0 0-.662 1.412v.104c0 .06.05.11.11.11h.656c.06 0 .11-.05.11-.11v-.104c0-.603.589-1.094 1.312-1.094.723 0 1.313.491 1.313 1.094 0 .425-.301.815-.767.994a1.528 1.528 0 0 0-.985 1.447v.294c0 .06.05.109.11.109h.656c.06 0 .11-.05.11-.11v-.31c0-.27.169-.515.422-.612.806-.31 1.327-1.022 1.327-1.812a1.858 1.858 0 0 0-.66-1.412Zm-2.073 5.678a.547.547 0 1 0 1.094 0 .547.547 0 0 0-1.094 0Z"
|
|
24
|
+
})));
|
|
25
|
+
};
|
|
26
|
+
export default SvgHelp;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
var SvgMermaid = function SvgMermaid(props) {
|
|
4
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
5
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
6
|
+
width: "1em",
|
|
7
|
+
height: "1em",
|
|
8
|
+
viewBox: "0 0 24 24"
|
|
9
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
|
10
|
+
fill: "currentColor",
|
|
11
|
+
fillRule: "nonzero",
|
|
12
|
+
d: "M16.936 13.576h-1.295v-1.894a.1.1 0 0 0-.1-.1h-3.09v-1.195h1.346a.2.2 0 0 0 .2-.2V6.6a.2.2 0 0 0-.2-.199h-3.588a.2.2 0 0 0-.2.2v3.587c0 .11.09.2.2.2h1.345v1.196h-3.09a.1.1 0 0 0-.099.1v1.893H7.069a.2.2 0 0 0-.199.2v3.587c0 .11.09.2.2.2h3.587a.2.2 0 0 0 .2-.2v-3.588a.2.2 0 0 0-.2-.199H9.262V12.48h5.482v1.096h-1.396a.2.2 0 0 0-.199.2v3.587c0 .11.09.2.2.2h3.587a.2.2 0 0 0 .2-.2v-3.588a.2.2 0 0 0-.2-.199Zm-7.026.947v2.093H7.817v-2.093H9.91Zm1.046-5.083V7.347h2.093V9.44h-2.093Zm5.233 7.176h-2.093v-2.093h2.093v2.093Z"
|
|
13
|
+
}));
|
|
14
|
+
};
|
|
15
|
+
export default SvgMermaid;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
var SvgTaskList = function SvgTaskList(props) {
|
|
4
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
5
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
6
|
+
width: "1em",
|
|
7
|
+
height: "1em",
|
|
8
|
+
viewBox: "0 0 24 24"
|
|
9
|
+
}, props), /*#__PURE__*/React.createElement("g", {
|
|
10
|
+
fill: "none",
|
|
11
|
+
fillRule: "evenodd"
|
|
12
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
13
|
+
fill: "currentColor",
|
|
14
|
+
fillRule: "nonzero",
|
|
15
|
+
d: "M17.869 7.625H9.884a.11.11 0 0 0-.109.11V8.5c0 .06.05.11.11.11h7.984c.06 0 .11-.05.11-.11v-.766a.11.11 0 0 0-.11-.109ZM17.869 11.508H9.884a.11.11 0 0 0-.109.11v.765c0 .06.05.11.11.11h7.984c.06 0 .11-.05.11-.11v-.766a.11.11 0 0 0-.11-.11ZM17.869 15.39H9.884a.11.11 0 0 0-.109.11v.766c0 .06.05.109.11.109h7.984c.06 0 .11-.05.11-.11V15.5a.11.11 0 0 0-.11-.11Z"
|
|
16
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
17
|
+
stroke: "currentColor",
|
|
18
|
+
strokeLinecap: "square",
|
|
19
|
+
strokeLinejoin: "round",
|
|
20
|
+
strokeWidth: 0.75,
|
|
21
|
+
d: "m6.4 8.25.75.75 1.5-1.5M6.4 11.75l.75.75 1.5-1.5M6.4 15.75l.75.75 1.5-1.5"
|
|
22
|
+
})));
|
|
23
|
+
};
|
|
24
|
+
export default SvgTaskList;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
var SvgViewOnly = function SvgViewOnly(props) {
|
|
4
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
5
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
6
|
+
width: "1em",
|
|
7
|
+
height: "1em",
|
|
8
|
+
viewBox: "0 0 24 24"
|
|
9
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
|
10
|
+
fill: "currentColor",
|
|
11
|
+
fillRule: "nonzero",
|
|
12
|
+
d: "M8.008 6.531h-.916c-.05 0-.092.05-.092.11v10.718c0 .06.041.11.092.11h.916c.05 0 .092-.05.092-.11V6.641c0-.06-.041-.11-.092-.11Zm1.859 0a.458.458 0 0 0-.46.456v10.025c0 .252.205.455.46.455h6.679c.254 0 .46-.203.46-.455V6.987a.458.458 0 0 0-.46-.456h-6.68Zm6.135 9.959h-5.6v-9h5.6v9Z"
|
|
13
|
+
}));
|
|
14
|
+
};
|
|
15
|
+
export default SvgViewOnly;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
export type { ToolbarItem } from './components/Toolbar';
|
|
1
2
|
export { createSelection, getRange } from './utils/container';
|
|
2
3
|
export { deleteHandler, insertHandler, redoHandler, selectHandler, setHandler, toggleHandler, undoHandler, } from './utils/handler';
|
|
3
|
-
export type { Handler } from './utils/handler';
|
|
4
|
+
export type { Executor, Handler, KeyboardEventHandler } from './utils/handler';
|
|
4
5
|
export { toHTML, toMarkdown, toText } from './utils/markdown';
|
|
5
6
|
export { default as XStarEditor, useEditorRef } from './x-star-editor';
|
|
6
7
|
export type { XStarEditorHandle, XStarEditorProps } from './x-star-editor';
|
package/dist/locales/en_US.d.ts
CHANGED
|
@@ -11,24 +11,29 @@ declare const _default: {
|
|
|
11
11
|
readonly blockquote: "Blockquote";
|
|
12
12
|
readonly code: "Code Block";
|
|
13
13
|
readonly delete: "Strikethrough";
|
|
14
|
+
readonly editOnly: "Edit Only";
|
|
14
15
|
readonly emphasis: "Italic";
|
|
15
16
|
readonly enterFullscreen: "Enter Fullscreen";
|
|
16
17
|
readonly exitFullscreen: "Exit Fullscreen";
|
|
17
18
|
readonly heading: "Heading";
|
|
19
|
+
readonly help: "Help";
|
|
18
20
|
readonly image: "Image";
|
|
19
21
|
readonly inlineCode: "Inline Code";
|
|
20
22
|
readonly inlineMath: "Inline Formula";
|
|
21
23
|
readonly link: "Link";
|
|
22
24
|
readonly math: "Formula Block";
|
|
25
|
+
readonly mermaid: "Mermaid";
|
|
23
26
|
readonly orderedList: "Ordered List";
|
|
24
27
|
readonly redo: "Redo";
|
|
25
28
|
readonly strong: "Bold";
|
|
26
29
|
readonly table: "Table";
|
|
30
|
+
readonly taskList: "Task List";
|
|
27
31
|
readonly thematicBreak: "Thematic Break";
|
|
28
32
|
readonly toHTML: "To HTML";
|
|
29
33
|
readonly toMarkdown: "To Markdown";
|
|
30
34
|
readonly undo: "Undo";
|
|
31
35
|
readonly unorderedList: "Unordered List";
|
|
36
|
+
readonly viewOnly: "View Only";
|
|
32
37
|
};
|
|
33
38
|
};
|
|
34
39
|
export default _default;
|
package/dist/locales/en_US.js
CHANGED
|
@@ -11,23 +11,28 @@ export default {
|
|
|
11
11
|
blockquote: 'Blockquote',
|
|
12
12
|
code: 'Code Block',
|
|
13
13
|
delete: 'Strikethrough',
|
|
14
|
+
editOnly: 'Edit Only',
|
|
14
15
|
emphasis: 'Italic',
|
|
15
16
|
enterFullscreen: 'Enter Fullscreen',
|
|
16
17
|
exitFullscreen: 'Exit Fullscreen',
|
|
17
18
|
heading: 'Heading',
|
|
19
|
+
help: 'Help',
|
|
18
20
|
image: 'Image',
|
|
19
21
|
inlineCode: 'Inline Code',
|
|
20
22
|
inlineMath: 'Inline Formula',
|
|
21
23
|
link: 'Link',
|
|
22
24
|
math: 'Formula Block',
|
|
25
|
+
mermaid: 'Mermaid',
|
|
23
26
|
orderedList: 'Ordered List',
|
|
24
27
|
redo: 'Redo',
|
|
25
28
|
strong: 'Bold',
|
|
26
29
|
table: 'Table',
|
|
30
|
+
taskList: 'Task List',
|
|
27
31
|
thematicBreak: 'Thematic Break',
|
|
28
32
|
toHTML: 'To HTML',
|
|
29
33
|
toMarkdown: 'To Markdown',
|
|
30
34
|
undo: 'Undo',
|
|
31
|
-
unorderedList: 'Unordered List'
|
|
35
|
+
unorderedList: 'Unordered List',
|
|
36
|
+
viewOnly: 'View Only'
|
|
32
37
|
}
|
|
33
38
|
};
|
package/dist/locales/index.d.ts
CHANGED
|
@@ -22,24 +22,29 @@ export declare const useLocale: <T extends "fileInput" | "toolbarItem">(slice: T
|
|
|
22
22
|
readonly blockquote: "引用";
|
|
23
23
|
readonly code: "代码块";
|
|
24
24
|
readonly delete: "删除线";
|
|
25
|
+
readonly editOnly: "仅编辑";
|
|
25
26
|
readonly emphasis: "斜体";
|
|
26
27
|
readonly enterFullscreen: "进入全屏";
|
|
27
28
|
readonly exitFullscreen: "退出全屏";
|
|
28
29
|
readonly heading: "标题";
|
|
30
|
+
readonly help: "帮助";
|
|
29
31
|
readonly image: "图片";
|
|
30
32
|
readonly inlineCode: "行内代码";
|
|
31
33
|
readonly inlineMath: "行内公式";
|
|
32
34
|
readonly link: "链接";
|
|
33
35
|
readonly math: "公式块";
|
|
36
|
+
readonly mermaid: "Mermaid";
|
|
34
37
|
readonly orderedList: "有序列表";
|
|
35
38
|
readonly redo: "恢复";
|
|
36
39
|
readonly strong: "粗体";
|
|
37
40
|
readonly table: "表格";
|
|
41
|
+
readonly taskList: "任务列表";
|
|
38
42
|
readonly thematicBreak: "分隔线";
|
|
39
43
|
readonly toHTML: "转成 HTML";
|
|
40
44
|
readonly toMarkdown: "转成 Markdown";
|
|
41
45
|
readonly undo: "撤销";
|
|
42
46
|
readonly unorderedList: "无序列表";
|
|
47
|
+
readonly viewOnly: "仅查看";
|
|
43
48
|
};
|
|
44
49
|
} | {
|
|
45
50
|
readonly fileInput: {
|
|
@@ -54,24 +59,29 @@ export declare const useLocale: <T extends "fileInput" | "toolbarItem">(slice: T
|
|
|
54
59
|
readonly blockquote: "Blockquote";
|
|
55
60
|
readonly code: "Code Block";
|
|
56
61
|
readonly delete: "Strikethrough";
|
|
62
|
+
readonly editOnly: "Edit Only";
|
|
57
63
|
readonly emphasis: "Italic";
|
|
58
64
|
readonly enterFullscreen: "Enter Fullscreen";
|
|
59
65
|
readonly exitFullscreen: "Exit Fullscreen";
|
|
60
66
|
readonly heading: "Heading";
|
|
67
|
+
readonly help: "Help";
|
|
61
68
|
readonly image: "Image";
|
|
62
69
|
readonly inlineCode: "Inline Code";
|
|
63
70
|
readonly inlineMath: "Inline Formula";
|
|
64
71
|
readonly link: "Link";
|
|
65
72
|
readonly math: "Formula Block";
|
|
73
|
+
readonly mermaid: "Mermaid";
|
|
66
74
|
readonly orderedList: "Ordered List";
|
|
67
75
|
readonly redo: "Redo";
|
|
68
76
|
readonly strong: "Bold";
|
|
69
77
|
readonly table: "Table";
|
|
78
|
+
readonly taskList: "Task List";
|
|
70
79
|
readonly thematicBreak: "Thematic Break";
|
|
71
80
|
readonly toHTML: "To HTML";
|
|
72
81
|
readonly toMarkdown: "To Markdown";
|
|
73
82
|
readonly undo: "Undo";
|
|
74
83
|
readonly unorderedList: "Unordered List";
|
|
84
|
+
readonly viewOnly: "View Only";
|
|
75
85
|
};
|
|
76
86
|
})[T][U];
|
|
77
87
|
};
|
|
@@ -88,24 +98,29 @@ export declare const getFormat: <T extends "fileInput" | "toolbarItem">(locale:
|
|
|
88
98
|
readonly blockquote: "引用";
|
|
89
99
|
readonly code: "代码块";
|
|
90
100
|
readonly delete: "删除线";
|
|
101
|
+
readonly editOnly: "仅编辑";
|
|
91
102
|
readonly emphasis: "斜体";
|
|
92
103
|
readonly enterFullscreen: "进入全屏";
|
|
93
104
|
readonly exitFullscreen: "退出全屏";
|
|
94
105
|
readonly heading: "标题";
|
|
106
|
+
readonly help: "帮助";
|
|
95
107
|
readonly image: "图片";
|
|
96
108
|
readonly inlineCode: "行内代码";
|
|
97
109
|
readonly inlineMath: "行内公式";
|
|
98
110
|
readonly link: "链接";
|
|
99
111
|
readonly math: "公式块";
|
|
112
|
+
readonly mermaid: "Mermaid";
|
|
100
113
|
readonly orderedList: "有序列表";
|
|
101
114
|
readonly redo: "恢复";
|
|
102
115
|
readonly strong: "粗体";
|
|
103
116
|
readonly table: "表格";
|
|
117
|
+
readonly taskList: "任务列表";
|
|
104
118
|
readonly thematicBreak: "分隔线";
|
|
105
119
|
readonly toHTML: "转成 HTML";
|
|
106
120
|
readonly toMarkdown: "转成 Markdown";
|
|
107
121
|
readonly undo: "撤销";
|
|
108
122
|
readonly unorderedList: "无序列表";
|
|
123
|
+
readonly viewOnly: "仅查看";
|
|
109
124
|
};
|
|
110
125
|
} | {
|
|
111
126
|
readonly fileInput: {
|
|
@@ -120,24 +135,29 @@ export declare const getFormat: <T extends "fileInput" | "toolbarItem">(locale:
|
|
|
120
135
|
readonly blockquote: "Blockquote";
|
|
121
136
|
readonly code: "Code Block";
|
|
122
137
|
readonly delete: "Strikethrough";
|
|
138
|
+
readonly editOnly: "Edit Only";
|
|
123
139
|
readonly emphasis: "Italic";
|
|
124
140
|
readonly enterFullscreen: "Enter Fullscreen";
|
|
125
141
|
readonly exitFullscreen: "Exit Fullscreen";
|
|
126
142
|
readonly heading: "Heading";
|
|
143
|
+
readonly help: "Help";
|
|
127
144
|
readonly image: "Image";
|
|
128
145
|
readonly inlineCode: "Inline Code";
|
|
129
146
|
readonly inlineMath: "Inline Formula";
|
|
130
147
|
readonly link: "Link";
|
|
131
148
|
readonly math: "Formula Block";
|
|
149
|
+
readonly mermaid: "Mermaid";
|
|
132
150
|
readonly orderedList: "Ordered List";
|
|
133
151
|
readonly redo: "Redo";
|
|
134
152
|
readonly strong: "Bold";
|
|
135
153
|
readonly table: "Table";
|
|
154
|
+
readonly taskList: "Task List";
|
|
136
155
|
readonly thematicBreak: "Thematic Break";
|
|
137
156
|
readonly toHTML: "To HTML";
|
|
138
157
|
readonly toMarkdown: "To Markdown";
|
|
139
158
|
readonly undo: "Undo";
|
|
140
159
|
readonly unorderedList: "Unordered List";
|
|
160
|
+
readonly viewOnly: "View Only";
|
|
141
161
|
};
|
|
142
162
|
})[T][U];
|
|
143
163
|
export {};
|
package/dist/locales/zh_CN.d.ts
CHANGED
|
@@ -11,24 +11,29 @@ declare const _default: {
|
|
|
11
11
|
readonly blockquote: "引用";
|
|
12
12
|
readonly code: "代码块";
|
|
13
13
|
readonly delete: "删除线";
|
|
14
|
+
readonly editOnly: "仅编辑";
|
|
14
15
|
readonly emphasis: "斜体";
|
|
15
16
|
readonly enterFullscreen: "进入全屏";
|
|
16
17
|
readonly exitFullscreen: "退出全屏";
|
|
17
18
|
readonly heading: "标题";
|
|
19
|
+
readonly help: "帮助";
|
|
18
20
|
readonly image: "图片";
|
|
19
21
|
readonly inlineCode: "行内代码";
|
|
20
22
|
readonly inlineMath: "行内公式";
|
|
21
23
|
readonly link: "链接";
|
|
22
24
|
readonly math: "公式块";
|
|
25
|
+
readonly mermaid: "Mermaid";
|
|
23
26
|
readonly orderedList: "有序列表";
|
|
24
27
|
readonly redo: "恢复";
|
|
25
28
|
readonly strong: "粗体";
|
|
26
29
|
readonly table: "表格";
|
|
30
|
+
readonly taskList: "任务列表";
|
|
27
31
|
readonly thematicBreak: "分隔线";
|
|
28
32
|
readonly toHTML: "转成 HTML";
|
|
29
33
|
readonly toMarkdown: "转成 Markdown";
|
|
30
34
|
readonly undo: "撤销";
|
|
31
35
|
readonly unorderedList: "无序列表";
|
|
36
|
+
readonly viewOnly: "仅查看";
|
|
32
37
|
};
|
|
33
38
|
};
|
|
34
39
|
export default _default;
|
package/dist/locales/zh_CN.js
CHANGED
|
@@ -11,23 +11,28 @@ export default {
|
|
|
11
11
|
blockquote: '引用',
|
|
12
12
|
code: '代码块',
|
|
13
13
|
delete: '删除线',
|
|
14
|
+
editOnly: '仅编辑',
|
|
14
15
|
emphasis: '斜体',
|
|
15
16
|
enterFullscreen: '进入全屏',
|
|
16
17
|
exitFullscreen: '退出全屏',
|
|
17
18
|
heading: '标题',
|
|
19
|
+
help: '帮助',
|
|
18
20
|
image: '图片',
|
|
19
21
|
inlineCode: '行内代码',
|
|
20
22
|
inlineMath: '行内公式',
|
|
21
23
|
link: '链接',
|
|
22
24
|
math: '公式块',
|
|
25
|
+
mermaid: 'Mermaid',
|
|
23
26
|
orderedList: '有序列表',
|
|
24
27
|
redo: '恢复',
|
|
25
28
|
strong: '粗体',
|
|
26
29
|
table: '表格',
|
|
30
|
+
taskList: '任务列表',
|
|
27
31
|
thematicBreak: '分隔线',
|
|
28
32
|
toHTML: '转成 HTML',
|
|
29
33
|
toMarkdown: '转成 Markdown',
|
|
30
34
|
undo: '撤销',
|
|
31
|
-
unorderedList: '无序列表'
|
|
35
|
+
unorderedList: '无序列表',
|
|
36
|
+
viewOnly: '仅查看'
|
|
32
37
|
}
|
|
33
38
|
};
|
package/dist/utils/container.js
CHANGED
|
@@ -141,28 +141,28 @@ export var useContainer = function useContainer(ref) {
|
|
|
141
141
|
/**
|
|
142
142
|
* 将一棵 DOM 树更新为另一棵 DOM 树
|
|
143
143
|
*
|
|
144
|
-
* @param newNode 新节点
|
|
145
144
|
* @param oldNode 旧节点
|
|
145
|
+
* @param newNode 新节点
|
|
146
146
|
*/
|
|
147
|
-
var diff = function diff(
|
|
148
|
-
var newChild = newNode.firstChild;
|
|
147
|
+
var diff = function diff(oldNode, newNode) {
|
|
149
148
|
var oldChild = oldNode.firstChild;
|
|
149
|
+
var newChild = newNode.firstChild;
|
|
150
150
|
|
|
151
151
|
// 依次更新子节点
|
|
152
|
-
for (;
|
|
153
|
-
var newNext = newChild.nextSibling;
|
|
152
|
+
for (; oldChild && newChild;) {
|
|
154
153
|
var oldNext = oldChild.nextSibling;
|
|
155
|
-
|
|
154
|
+
var newNext = newChild.nextSibling;
|
|
155
|
+
if (oldChild.nodeName !== newChild.nodeName) {
|
|
156
156
|
// 节点名称不同,直接替换
|
|
157
157
|
oldChild.replaceWith(newChild);
|
|
158
|
-
} else if (
|
|
158
|
+
} else if (oldChild.nodeType === Node.TEXT_NODE) {
|
|
159
159
|
// 节点均为文本类型,更新文本内容
|
|
160
|
-
if (
|
|
160
|
+
if (oldChild.nodeValue !== newChild.nodeValue) {
|
|
161
161
|
oldChild.nodeValue = newChild.nodeValue;
|
|
162
162
|
}
|
|
163
163
|
} else {
|
|
164
164
|
// 节点名称相同,更新属性和子节点
|
|
165
|
-
if (
|
|
165
|
+
if (oldChild instanceof HTMLElement && newChild instanceof HTMLElement) {
|
|
166
166
|
var _iterator = _createForOfIteratorHelper(oldChild.getAttributeNames()),
|
|
167
167
|
_step;
|
|
168
168
|
try {
|
|
@@ -183,9 +183,9 @@ export var useContainer = function useContainer(ref) {
|
|
|
183
183
|
try {
|
|
184
184
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
185
185
|
var newAttrName = _step2.value;
|
|
186
|
-
var newAttrValue = newChild.getAttribute(newAttrName);
|
|
187
186
|
var oldAttrValue = oldChild.getAttribute(newAttrName);
|
|
188
|
-
|
|
187
|
+
var newAttrValue = newChild.getAttribute(newAttrName);
|
|
188
|
+
if (oldAttrValue !== newAttrValue && newAttrValue !== null) {
|
|
189
189
|
oldChild.setAttribute(newAttrName, newAttrValue);
|
|
190
190
|
}
|
|
191
191
|
}
|
|
@@ -195,10 +195,10 @@ export var useContainer = function useContainer(ref) {
|
|
|
195
195
|
_iterator2.f();
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
|
-
diff(
|
|
198
|
+
diff(oldChild, newChild);
|
|
199
199
|
}
|
|
200
|
-
newChild = newNext;
|
|
201
200
|
oldChild = oldNext;
|
|
201
|
+
newChild = newNext;
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
// 移除节点
|
|
@@ -215,7 +215,7 @@ export var useContainer = function useContainer(ref) {
|
|
|
215
215
|
newChild = _newNext;
|
|
216
216
|
}
|
|
217
217
|
};
|
|
218
|
-
diff(editorRender(text)
|
|
218
|
+
diff(ref.current, editorRender(text));
|
|
219
219
|
};
|
|
220
220
|
|
|
221
221
|
/**
|
package/dist/utils/history.d.ts
CHANGED
|
@@ -28,7 +28,9 @@ export interface ToggleAction {
|
|
|
28
28
|
type: 'blockquote' | 'delete' | 'emphasis' | 'inlineCode' | 'inlineMath' | 'math' | 'strong' | 'thematicBreak';
|
|
29
29
|
} | {
|
|
30
30
|
type: 'code';
|
|
31
|
-
|
|
31
|
+
lang: string;
|
|
32
|
+
value: string;
|
|
33
|
+
showLineNumbers: boolean;
|
|
32
34
|
} | {
|
|
33
35
|
type: 'heading';
|
|
34
36
|
depth: 1 | 2 | 3 | 4 | 5 | 6;
|