x-star-editor 0.0.2 → 0.0.4
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/XStarEditor/index.d.ts +10 -4
- package/dist/XStarEditor/index.js +82 -31
- package/dist/XStarEditor/index.less +24 -0
- package/dist/XStarMdEditor/index.d.ts +12 -1
- package/dist/XStarMdEditor/index.js +10 -7
- package/dist/XStarMdEditor/{index.module.css → index.less} +7 -2
- package/dist/XStarMdViewer/index.d.ts +3 -1
- package/dist/XStarMdViewer/index.js +11 -7
- package/dist/XStarMdViewer/{index.module.css → index.less} +7 -2
- package/dist/components/FileInput.d.ts +1 -0
- package/dist/components/FileInput.js +23 -23
- package/dist/components/FileInput.less +83 -0
- package/dist/components/Toolbar.d.ts +1 -0
- package/dist/components/Toolbar.js +21 -19
- package/dist/components/Toolbar.less +118 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +3 -3
- package/dist/styles/global.less +1 -0
- package/dist/styles/{markdown.css → markdown.less} +38 -32
- package/dist/styles/prism.less +171 -0
- package/dist/utils/container.js +2 -2
- package/dist/utils/global.d.ts +1 -0
- package/dist/utils/global.js +1 -0
- package/dist/utils/markdown.d.ts +7 -0
- package/dist/utils/markdown.js +86 -56
- package/package.json +38 -33
- package/dist/XStarEditor/index.module.css +0 -19
- package/dist/components/FileInput.module.css +0 -81
- package/dist/components/Toolbar.module.css +0 -116
- package/dist/styles/prism.css +0 -182
- package/dist/utils/module-css.d.ts +0 -3
|
@@ -1,15 +1,19 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
3
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
4
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
1
5
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
6
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
7
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
8
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
9
|
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
6
10
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
-
import classNames from 'classnames
|
|
11
|
+
import classNames from 'classnames';
|
|
8
12
|
import React, { useEffect, useRef, useState } from 'react';
|
|
13
|
+
import { prefix } from "../utils/global";
|
|
9
14
|
import { toggleHandler } from "../utils/handler";
|
|
10
15
|
import FileInput from "./FileInput";
|
|
11
|
-
import
|
|
12
|
-
var cx = classNames.bind(styles);
|
|
16
|
+
import "./Toolbar.less";
|
|
13
17
|
var Button = function Button(_ref) {
|
|
14
18
|
var toolbarRef = _ref.toolbarRef,
|
|
15
19
|
children = _ref.children,
|
|
@@ -55,11 +59,9 @@ var Button = function Button(_ref) {
|
|
|
55
59
|
}
|
|
56
60
|
}, [popoverMount]);
|
|
57
61
|
return /*#__PURE__*/React.createElement("div", {
|
|
58
|
-
className:
|
|
62
|
+
className: classNames("".concat(prefix, "button-container"))
|
|
59
63
|
}, /*#__PURE__*/React.createElement("div", {
|
|
60
|
-
className:
|
|
61
|
-
'button-hover': tooltipOpen || popoverMount
|
|
62
|
-
}),
|
|
64
|
+
className: classNames("".concat(prefix, "button"), _defineProperty({}, "".concat(prefix, "active"), tooltipOpen || popoverMount)),
|
|
63
65
|
onClick: function onClick() {
|
|
64
66
|
setPopoverOpen(true);
|
|
65
67
|
_onClick === null || _onClick === void 0 ? void 0 : _onClick();
|
|
@@ -74,10 +76,10 @@ var Button = function Button(_ref) {
|
|
|
74
76
|
return setTooltipOpen(false);
|
|
75
77
|
}
|
|
76
78
|
}, children, tooltipMount && /*#__PURE__*/React.createElement("div", {
|
|
77
|
-
className:
|
|
79
|
+
className: classNames("".concat(prefix, "tooltip"))
|
|
78
80
|
}, tooltip)), popoverMount && /*#__PURE__*/React.createElement("div", {
|
|
79
81
|
ref: popoverRef,
|
|
80
|
-
className:
|
|
82
|
+
className: classNames("".concat(prefix, "popover"))
|
|
81
83
|
}, popover));
|
|
82
84
|
};
|
|
83
85
|
export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap(onInsertFile) {
|
|
@@ -88,7 +90,7 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap(onInsert
|
|
|
88
90
|
popoverRender: function popoverRender(exec, close) {
|
|
89
91
|
var optionRender = function optionRender(depth, fontSize) {
|
|
90
92
|
return /*#__PURE__*/React.createElement("div", {
|
|
91
|
-
className:
|
|
93
|
+
className: classNames("".concat(prefix, "option")),
|
|
92
94
|
style: {
|
|
93
95
|
fontSize: fontSize
|
|
94
96
|
},
|
|
@@ -124,7 +126,7 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap(onInsert
|
|
|
124
126
|
},
|
|
125
127
|
code: {
|
|
126
128
|
children: /*#__PURE__*/React.createElement("div", {
|
|
127
|
-
className:
|
|
129
|
+
className: classNames("".concat(prefix, "icon"), "".concat(prefix, "code-library"))
|
|
128
130
|
}),
|
|
129
131
|
tooltip: '代码块',
|
|
130
132
|
onClick: function onClick(exec) {
|
|
@@ -135,7 +137,7 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap(onInsert
|
|
|
135
137
|
},
|
|
136
138
|
emphasis: {
|
|
137
139
|
children: /*#__PURE__*/React.createElement("div", {
|
|
138
|
-
className:
|
|
140
|
+
className: classNames("".concat(prefix, "icon"), "".concat(prefix, "italic"))
|
|
139
141
|
}),
|
|
140
142
|
tooltip: '斜体',
|
|
141
143
|
onClick: function onClick(exec) {
|
|
@@ -146,7 +148,7 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap(onInsert
|
|
|
146
148
|
},
|
|
147
149
|
strong: {
|
|
148
150
|
children: /*#__PURE__*/React.createElement("div", {
|
|
149
|
-
className:
|
|
151
|
+
className: classNames("".concat(prefix, "icon"), "".concat(prefix, "bold"))
|
|
150
152
|
}),
|
|
151
153
|
tooltip: '粗体',
|
|
152
154
|
onClick: function onClick(exec) {
|
|
@@ -157,7 +159,7 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap(onInsert
|
|
|
157
159
|
},
|
|
158
160
|
inlineCode: {
|
|
159
161
|
children: /*#__PURE__*/React.createElement("div", {
|
|
160
|
-
className:
|
|
162
|
+
className: classNames("".concat(prefix, "icon"), "".concat(prefix, "code"))
|
|
161
163
|
}),
|
|
162
164
|
tooltip: '行内代码',
|
|
163
165
|
onClick: function onClick(exec) {
|
|
@@ -168,7 +170,7 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap(onInsert
|
|
|
168
170
|
},
|
|
169
171
|
link: {
|
|
170
172
|
children: /*#__PURE__*/React.createElement("div", {
|
|
171
|
-
className:
|
|
173
|
+
className: classNames("".concat(prefix, "icon"), "".concat(prefix, "link"))
|
|
172
174
|
}),
|
|
173
175
|
tooltip: '链接',
|
|
174
176
|
popoverRender: function popoverRender(exec, close) {
|
|
@@ -194,7 +196,7 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap(onInsert
|
|
|
194
196
|
},
|
|
195
197
|
image: {
|
|
196
198
|
children: /*#__PURE__*/React.createElement("div", {
|
|
197
|
-
className:
|
|
199
|
+
className: classNames("".concat(prefix, "icon"), "".concat(prefix, "image"))
|
|
198
200
|
}),
|
|
199
201
|
tooltip: '图片',
|
|
200
202
|
popoverRender: function popoverRender(exec, close) {
|
|
@@ -220,7 +222,7 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap(onInsert
|
|
|
220
222
|
},
|
|
221
223
|
delete: {
|
|
222
224
|
children: /*#__PURE__*/React.createElement("div", {
|
|
223
|
-
className:
|
|
225
|
+
className: classNames("".concat(prefix, "icon"), "".concat(prefix, "strikethrough"))
|
|
224
226
|
}),
|
|
225
227
|
tooltip: '删除线',
|
|
226
228
|
onClick: function onClick(exec) {
|
|
@@ -261,13 +263,13 @@ var Toolbar = function Toolbar(_ref2) {
|
|
|
261
263
|
var toolbarRef = useRef(null);
|
|
262
264
|
return /*#__PURE__*/React.createElement("div", {
|
|
263
265
|
ref: toolbarRef,
|
|
264
|
-
className:
|
|
266
|
+
className: classNames("".concat(prefix, "toolbar"), className),
|
|
265
267
|
style: style
|
|
266
268
|
}, items.map(function (group, index) {
|
|
267
269
|
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
268
270
|
key: index
|
|
269
271
|
}, !!index && /*#__PURE__*/React.createElement("div", {
|
|
270
|
-
className:
|
|
272
|
+
className: classNames("".concat(prefix, "divider"))
|
|
271
273
|
}), group.map(function (item, index) {
|
|
272
274
|
var toolbarItem = typeof item === 'string' ? itemMap[item] : item;
|
|
273
275
|
if (!toolbarItem) {
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
@import '../styles/global.less';
|
|
2
|
+
|
|
3
|
+
.@{prefix}toolbar {
|
|
4
|
+
padding: 0.2em;
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-wrap: wrap;
|
|
7
|
+
gap: 0.2em;
|
|
8
|
+
font-size: 1.1em;
|
|
9
|
+
background-color: #f5771210;
|
|
10
|
+
border: 1px solid #f5771220;
|
|
11
|
+
border-top-left-radius: 0.2em;
|
|
12
|
+
border-top-right-radius: 0.2em;
|
|
13
|
+
|
|
14
|
+
.@{prefix}button-container {
|
|
15
|
+
position: relative;
|
|
16
|
+
|
|
17
|
+
> .@{prefix}button {
|
|
18
|
+
width: 2em;
|
|
19
|
+
height: 2em;
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
justify-content: center;
|
|
23
|
+
font-family: Consolas;
|
|
24
|
+
border: 1px solid transparent;
|
|
25
|
+
cursor: pointer;
|
|
26
|
+
user-select: none;
|
|
27
|
+
|
|
28
|
+
&.@{prefix}active {
|
|
29
|
+
background-color: #f8f8f8;
|
|
30
|
+
border: 1px solid #f5771280;
|
|
31
|
+
border-radius: 0.2em;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.@{prefix}icon {
|
|
35
|
+
width: 45%;
|
|
36
|
+
height: 45%;
|
|
37
|
+
background-size: contain;
|
|
38
|
+
|
|
39
|
+
&.@{prefix}code-library {
|
|
40
|
+
background-image: url('icons/code-library.svg');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&.@{prefix}italic {
|
|
44
|
+
background-image: url('icons/italic.svg');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&.@{prefix}bold {
|
|
48
|
+
background-image: url('icons/bold.svg');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
&.@{prefix}code {
|
|
52
|
+
background-image: url('icons/code.svg');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
&.@{prefix}link {
|
|
56
|
+
background-image: url('icons/link.svg');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
&.@{prefix}image {
|
|
60
|
+
background-image: url('icons/image.svg');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
&.@{prefix}strikethrough {
|
|
64
|
+
background-image: url('icons/strikethrough.svg');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.@{prefix}tooltip {
|
|
69
|
+
position: absolute;
|
|
70
|
+
top: 3em;
|
|
71
|
+
width: max-content;
|
|
72
|
+
padding: 0.4em;
|
|
73
|
+
font-size: 0.8em;
|
|
74
|
+
color: #f8f8f8;
|
|
75
|
+
background-color: #022679;
|
|
76
|
+
border-radius: 0.2em;
|
|
77
|
+
z-index: 2;
|
|
78
|
+
|
|
79
|
+
&::before {
|
|
80
|
+
content: '';
|
|
81
|
+
position: absolute;
|
|
82
|
+
top: -0.3em;
|
|
83
|
+
left: 50%;
|
|
84
|
+
border-top: 0.6em solid #022679;
|
|
85
|
+
border-right: 0.6em solid transparent;
|
|
86
|
+
transform-origin: 0 0;
|
|
87
|
+
transform: rotate(45deg);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.@{prefix}popover {
|
|
93
|
+
position: absolute;
|
|
94
|
+
width: max-content;
|
|
95
|
+
background-color: #f8f8f8;
|
|
96
|
+
border: 1px solid #f5771280;
|
|
97
|
+
border-radius: 0.2em;
|
|
98
|
+
box-shadow: 0 2px 4px #00000020;
|
|
99
|
+
opacity: 0;
|
|
100
|
+
z-index: 1;
|
|
101
|
+
|
|
102
|
+
.@{prefix}option {
|
|
103
|
+
padding: 4px 8px;
|
|
104
|
+
cursor: pointer;
|
|
105
|
+
user-select: none;
|
|
106
|
+
|
|
107
|
+
&:hover {
|
|
108
|
+
background-color: #f0f0f0;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.@{prefix}divider {
|
|
115
|
+
margin: 0.4em;
|
|
116
|
+
border: 1px solid #f5771280;
|
|
117
|
+
}
|
|
118
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { default as XStarEditor } from './XStarEditor';
|
|
2
|
-
export type {
|
|
3
|
-
export { default as XStarMdEditor } from './XStarMdEditor';
|
|
1
|
+
export { default as XStarEditor, useEditorRef } from './XStarEditor';
|
|
2
|
+
export type { XStarEditorHandle, XStarEditorProps } from './XStarEditor';
|
|
3
|
+
export { default as XStarMdEditor, useMdEditorRef } from './XStarMdEditor';
|
|
4
4
|
export type { XStarMdEditorHandle, XStarMdEditorPlugin, XStarMdEditorProps, } from './XStarMdEditor';
|
|
5
|
-
export { default as XStarMdViewer } from './XStarMdViewer';
|
|
5
|
+
export { default as XStarMdViewer, useMdViewerRef } from './XStarMdViewer';
|
|
6
6
|
export type { XStarMdViewerHandle, XStarMdViewerPlugin, XStarMdViewerProps, } from './XStarMdViewer';
|
|
7
7
|
export { createSelection, getRange } from './utils/container';
|
|
8
8
|
export { deleteHandler, insertHandler, redoHandler, selectHandler, setHandler, toggleHandler, undoHandler, } from './utils/handler';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { default as XStarEditor } from "./XStarEditor";
|
|
2
|
-
export { default as XStarMdEditor } from "./XStarMdEditor";
|
|
3
|
-
export { default as XStarMdViewer } from "./XStarMdViewer";
|
|
1
|
+
export { default as XStarEditor, useEditorRef } from "./XStarEditor";
|
|
2
|
+
export { default as XStarMdEditor, useMdEditorRef } from "./XStarMdEditor";
|
|
3
|
+
export { default as XStarMdViewer, useMdViewerRef } from "./XStarMdViewer";
|
|
4
4
|
export { createSelection, getRange } from "./utils/container";
|
|
5
5
|
export { deleteHandler, insertHandler, redoHandler, selectHandler, setHandler, toggleHandler, undoHandler } from "./utils/handler";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@prefix: x-star-;
|
|
@@ -1,60 +1,64 @@
|
|
|
1
|
-
.
|
|
1
|
+
@import './global.less';
|
|
2
|
+
|
|
3
|
+
@md-prefix: ~'@{prefix}md-editor-';
|
|
4
|
+
|
|
5
|
+
.@{md-prefix}block {
|
|
2
6
|
margin: 0.2em;
|
|
3
7
|
padding: 0.2em;
|
|
4
8
|
border-radius: 0.2em;
|
|
5
9
|
}
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
.@{md-prefix}block:hover {
|
|
8
12
|
background-color: #f8f8f8;
|
|
9
13
|
}
|
|
10
14
|
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
.@{md-prefix}delimiter,
|
|
16
|
+
.@{md-prefix}break {
|
|
13
17
|
color: #f5771280;
|
|
14
18
|
}
|
|
15
19
|
|
|
16
|
-
|
|
20
|
+
.@{md-prefix}heading {
|
|
17
21
|
font-weight: bold;
|
|
18
22
|
}
|
|
19
23
|
|
|
20
|
-
|
|
24
|
+
.@{md-prefix}heading1 {
|
|
21
25
|
font-size: 1.6em;
|
|
22
26
|
}
|
|
23
27
|
|
|
24
|
-
|
|
28
|
+
.@{md-prefix}heading2 {
|
|
25
29
|
font-size: 1.3em;
|
|
26
30
|
}
|
|
27
31
|
|
|
28
|
-
|
|
32
|
+
.@{md-prefix}heading3 {
|
|
29
33
|
font-size: 1.2em;
|
|
30
34
|
}
|
|
31
35
|
|
|
32
|
-
|
|
36
|
+
.@{md-prefix}heading4 {
|
|
33
37
|
font-size: 1.1em;
|
|
34
38
|
}
|
|
35
39
|
|
|
36
|
-
|
|
40
|
+
.@{md-prefix}heading5 {
|
|
37
41
|
font-size: 1em;
|
|
38
42
|
}
|
|
39
43
|
|
|
40
|
-
|
|
44
|
+
.@{md-prefix}heading6 {
|
|
41
45
|
font-size: 0.9em;
|
|
42
46
|
}
|
|
43
47
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
.@{md-prefix}thematicBreak,
|
|
49
|
+
.@{md-prefix}listItem > .@{md-prefix}delimiter,
|
|
50
|
+
.@{md-prefix}definition,
|
|
51
|
+
.@{md-prefix}link,
|
|
52
|
+
.@{md-prefix}image,
|
|
53
|
+
.@{md-prefix}linkReference,
|
|
54
|
+
.@{md-prefix}imageReference,
|
|
55
|
+
.@{md-prefix}footnoteDefinition,
|
|
56
|
+
.@{md-prefix}footnoteReference {
|
|
53
57
|
color: #f57712;
|
|
54
58
|
}
|
|
55
59
|
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
.@{md-prefix}html,
|
|
61
|
+
.@{md-prefix}code {
|
|
58
62
|
padding: 0 0.2em;
|
|
59
63
|
tab-size: 4;
|
|
60
64
|
font-family: Consolas;
|
|
@@ -64,19 +68,21 @@
|
|
|
64
68
|
border-left: 1px solid #02267920;
|
|
65
69
|
}
|
|
66
70
|
|
|
67
|
-
|
|
71
|
+
.@{md-prefix}html.@{md-prefix}first,
|
|
72
|
+
.@{md-prefix}code.@{md-prefix}first {
|
|
68
73
|
border-top: 1px solid #02267920;
|
|
69
74
|
border-top-left-radius: 0.2em;
|
|
70
75
|
border-top-right-radius: 0.2em;
|
|
71
76
|
}
|
|
72
77
|
|
|
73
|
-
|
|
78
|
+
.@{md-prefix}html.@{md-prefix}last,
|
|
79
|
+
.@{md-prefix}code.@{md-prefix}last {
|
|
74
80
|
border-bottom: 1px solid #02267920;
|
|
75
81
|
border-bottom-right-radius: 0.2em;
|
|
76
82
|
border-bottom-left-radius: 0.2em;
|
|
77
83
|
}
|
|
78
84
|
|
|
79
|
-
|
|
85
|
+
.@{md-prefix}inlineCode {
|
|
80
86
|
margin: 0 0.2em;
|
|
81
87
|
padding: 0 0.2em;
|
|
82
88
|
tab-size: 4;
|
|
@@ -87,19 +93,19 @@
|
|
|
87
93
|
border-radius: 0.2em;
|
|
88
94
|
}
|
|
89
95
|
|
|
90
|
-
|
|
96
|
+
.@{md-prefix}emphasis {
|
|
91
97
|
font-style: italic;
|
|
92
98
|
}
|
|
93
99
|
|
|
94
|
-
|
|
100
|
+
.@{md-prefix}strong {
|
|
95
101
|
font-weight: bold;
|
|
96
102
|
}
|
|
97
103
|
|
|
98
|
-
|
|
104
|
+
.@{md-prefix}delete > :not(.@{md-prefix}delimiter) {
|
|
99
105
|
text-decoration: line-through;
|
|
100
106
|
}
|
|
101
107
|
|
|
102
|
-
|
|
108
|
+
.@{md-prefix}math {
|
|
103
109
|
padding: 0 0.2em;
|
|
104
110
|
color: #f57712;
|
|
105
111
|
background-color: #f5771210;
|
|
@@ -107,19 +113,19 @@
|
|
|
107
113
|
border-left: 1px solid #f5771220;
|
|
108
114
|
}
|
|
109
115
|
|
|
110
|
-
|
|
116
|
+
.@{md-prefix}math.@{md-prefix}first {
|
|
111
117
|
border-top: 1px solid #f5771220;
|
|
112
118
|
border-top-left-radius: 0.2em;
|
|
113
119
|
border-top-right-radius: 0.2em;
|
|
114
120
|
}
|
|
115
121
|
|
|
116
|
-
|
|
122
|
+
.@{md-prefix}math.@{md-prefix}last {
|
|
117
123
|
border-bottom: 1px solid #f5771220;
|
|
118
124
|
border-bottom-right-radius: 0.2em;
|
|
119
125
|
border-bottom-left-radius: 0.2em;
|
|
120
126
|
}
|
|
121
127
|
|
|
122
|
-
|
|
128
|
+
.@{md-prefix}inlineMath {
|
|
123
129
|
margin: 0 0.2em;
|
|
124
130
|
padding: 0 0.2em;
|
|
125
131
|
color: #f57712;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VS theme by Andrew Lock (https://andrewlock.net)
|
|
3
|
+
* Inspired by Visual Studio syntax coloring
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
@import './global.less';
|
|
7
|
+
|
|
8
|
+
.@{prefix}md-viewer.@{prefix}md-viewer {
|
|
9
|
+
code,
|
|
10
|
+
pre {
|
|
11
|
+
color: #393a34;
|
|
12
|
+
font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier,
|
|
13
|
+
monospace;
|
|
14
|
+
direction: ltr;
|
|
15
|
+
text-align: left;
|
|
16
|
+
white-space: pre;
|
|
17
|
+
word-spacing: normal;
|
|
18
|
+
word-break: normal;
|
|
19
|
+
font-size: 1em;
|
|
20
|
+
line-height: 1.2em;
|
|
21
|
+
tab-size: 4;
|
|
22
|
+
tab-size: 4;
|
|
23
|
+
tab-size: 4;
|
|
24
|
+
hyphens: none;
|
|
25
|
+
hyphens: none;
|
|
26
|
+
hyphens: none;
|
|
27
|
+
hyphens: none;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
pre > code {
|
|
31
|
+
font-size: 1.1em;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/* Code blocks */
|
|
35
|
+
pre {
|
|
36
|
+
padding: 1em;
|
|
37
|
+
margin: 0.5em 0;
|
|
38
|
+
overflow: auto;
|
|
39
|
+
border: 1px solid #ddd;
|
|
40
|
+
background-color: white;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/* Inline code */
|
|
44
|
+
:not(pre) > code {
|
|
45
|
+
padding: 0.2em;
|
|
46
|
+
padding-top: 1px;
|
|
47
|
+
padding-bottom: 1px;
|
|
48
|
+
background: #f8f8f8;
|
|
49
|
+
border: 1px solid #ddd;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.token.comment,
|
|
53
|
+
.token.prolog,
|
|
54
|
+
.token.doctype,
|
|
55
|
+
.token.cdata {
|
|
56
|
+
color: #008000;
|
|
57
|
+
font-style: italic;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.token.namespace {
|
|
61
|
+
opacity: 0.7;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.token.string {
|
|
65
|
+
color: #a31515;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.token.punctuation,
|
|
69
|
+
.token.operator {
|
|
70
|
+
color: #393a34; /* no highlight */
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.token.url,
|
|
74
|
+
.token.symbol,
|
|
75
|
+
.token.number,
|
|
76
|
+
.token.boolean,
|
|
77
|
+
.token.variable,
|
|
78
|
+
.token.constant,
|
|
79
|
+
.token.inserted {
|
|
80
|
+
color: #36acaa;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.token.atrule,
|
|
84
|
+
.token.keyword,
|
|
85
|
+
.token.attr-value,
|
|
86
|
+
.language-autohotkey .token.selector,
|
|
87
|
+
.language-json .token.boolean,
|
|
88
|
+
.language-json .token.number,
|
|
89
|
+
code[class*='language-css'] {
|
|
90
|
+
color: #00f;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.token.function {
|
|
94
|
+
color: #393a34;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.token.deleted,
|
|
98
|
+
.language-autohotkey .token.tag {
|
|
99
|
+
color: #9a050f;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.token.selector,
|
|
103
|
+
.language-autohotkey .token.keyword {
|
|
104
|
+
color: #00009f;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.token.important {
|
|
108
|
+
color: #e90;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.token.important,
|
|
112
|
+
.token.bold {
|
|
113
|
+
font-weight: bold;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.token.italic {
|
|
117
|
+
font-style: italic;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.token.class-name,
|
|
121
|
+
.language-json .token.property {
|
|
122
|
+
color: #2b91af;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.token.tag,
|
|
126
|
+
.token.selector {
|
|
127
|
+
color: #800000;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.token.attr-name,
|
|
131
|
+
.token.property,
|
|
132
|
+
.token.regex,
|
|
133
|
+
.token.entity {
|
|
134
|
+
color: #f00;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.token.directive.tag .tag {
|
|
138
|
+
background: #ff0;
|
|
139
|
+
color: #393a34;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.line-number::before {
|
|
143
|
+
content: attr(line);
|
|
144
|
+
width: 1.6em;
|
|
145
|
+
margin-right: 0.8em;
|
|
146
|
+
display: inline-block;
|
|
147
|
+
text-align: right;
|
|
148
|
+
color: #2b91af;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.code-line {
|
|
152
|
+
padding-left: 0.4em;
|
|
153
|
+
display: block;
|
|
154
|
+
border-left: 4px solid transparent;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.highlight-line {
|
|
158
|
+
background: rgba(193, 222, 241, 20%);
|
|
159
|
+
background: linear-gradient(
|
|
160
|
+
left,
|
|
161
|
+
rgba(193, 222, 241, 20%) 70%,
|
|
162
|
+
rgba(221, 222, 241, 0%)
|
|
163
|
+
);
|
|
164
|
+
background: linear-gradient(
|
|
165
|
+
to right,
|
|
166
|
+
rgba(193, 222, 241, 20%) 70%,
|
|
167
|
+
rgba(221, 222, 241, 0%)
|
|
168
|
+
);
|
|
169
|
+
border-left: 4px solid rgb(59, 130, 246);
|
|
170
|
+
}
|
|
171
|
+
}
|
package/dist/utils/container.js
CHANGED
|
@@ -238,7 +238,7 @@ export var useContainer = function useContainer() {
|
|
|
238
238
|
if (node.nodeType === Node.TEXT_NODE) {
|
|
239
239
|
if (node.nodeValue) {
|
|
240
240
|
offset += targetOffset;
|
|
241
|
-
if (node.nodeValue
|
|
241
|
+
if (targetOffset === node.nodeValue.length && node.nodeValue.endsWith("\u200B")) {
|
|
242
242
|
offset--;
|
|
243
243
|
}
|
|
244
244
|
}
|
|
@@ -298,7 +298,7 @@ export var useContainer = function useContainer() {
|
|
|
298
298
|
var traverse = function traverse(node) {
|
|
299
299
|
if (node.nodeType === Node.TEXT_NODE) {
|
|
300
300
|
if (node.nodeValue) {
|
|
301
|
-
if (offset < node.nodeValue.length) {
|
|
301
|
+
if (offset < node.nodeValue.length || offset === node.nodeValue.length && !node.nodeValue.endsWith("\u200B")) {
|
|
302
302
|
return node;
|
|
303
303
|
}
|
|
304
304
|
offset -= node.nodeValue.length;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const prefix = "x-star-";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export var prefix = 'x-star-';
|
package/dist/utils/markdown.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { Components } from 'hast-util-to-jsx-runtime';
|
|
3
|
+
import { defaultSchema } from 'rehype-sanitize';
|
|
4
|
+
type Schema = typeof defaultSchema;
|
|
5
|
+
export declare const getDefaultSchema: () => Schema;
|
|
3
6
|
/**
|
|
4
7
|
* 将 Markdown 文本解析为 Mdast 树并转换为 Hast 树的处理器
|
|
5
8
|
*/
|
|
@@ -16,6 +19,10 @@ export type MdastNode = ReturnType<(typeof processor)['parse']>['children'][numb
|
|
|
16
19
|
*/
|
|
17
20
|
export declare const editorRender: (sourceCode: string) => HTMLDivElement;
|
|
18
21
|
export interface ViewerOptions {
|
|
22
|
+
/**
|
|
23
|
+
* 自定义过滤模式
|
|
24
|
+
*/
|
|
25
|
+
customSchema: Schema;
|
|
19
26
|
/**
|
|
20
27
|
* 自定义 HTML 元素
|
|
21
28
|
*/
|