x-star-editor 0.1.0 → 0.1.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.
@@ -1,9 +1,4 @@
1
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
- 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
- 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
- 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
- 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
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
7
2
  import React, { useEffect, useState } from 'react';
8
3
  var Fade = function Fade(_ref) {
9
4
  var children = _ref.children,
@@ -32,7 +27,7 @@ var Fade = function Fade(_ref) {
32
27
  return window.clearTimeout(timer);
33
28
  };
34
29
  }
35
- }, [appear, timeout]);
30
+ }, [appear]);
36
31
  return /*#__PURE__*/React.createElement(React.Fragment, null, (appear || mount) && children);
37
32
  };
38
33
  export default Fade;
@@ -1,13 +1,5 @@
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); }
5
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
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."); }
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); }
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; }
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; } }
10
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
11
3
  import classNames from 'classnames';
12
4
  import React, { useState } from 'react';
13
5
  import { useLocale } from "../locales";
@@ -1,13 +1,5 @@
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); }
5
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
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."); }
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); }
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; }
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; } }
10
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
11
3
  import classNames from 'classnames';
12
4
  import React, { useEffect, useRef, useState } from 'react';
13
5
  import { getFormat } from "../locales";
@@ -96,11 +88,12 @@ var Button = function Button(_ref) {
96
88
  export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap() {
97
89
  var locale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
98
90
  var onInsertFile = arguments.length > 1 ? arguments[1] : undefined;
91
+ var iconPrefix = "".concat(prefix, "icon-");
99
92
  var t = getFormat(locale, 'toolbarItem');
100
93
  return {
101
94
  blockquote: {
102
95
  children: /*#__PURE__*/React.createElement("div", {
103
- className: classNames("".concat(prefix, "icon"), "".concat(prefix, "blockquote"))
96
+ className: classNames("".concat(prefix, "icon"), "".concat(iconPrefix, "blockquote"))
104
97
  }),
105
98
  tooltip: t('blockquote'),
106
99
  onClick: function onClick(exec) {
@@ -111,7 +104,7 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap() {
111
104
  },
112
105
  code: {
113
106
  children: /*#__PURE__*/React.createElement("div", {
114
- className: classNames("".concat(prefix, "icon"), "".concat(prefix, "code"))
107
+ className: classNames("".concat(prefix, "icon"), "".concat(iconPrefix, "code"))
115
108
  }),
116
109
  tooltip: t('code'),
117
110
  popoverRender: function popoverRender(exec, close) {
@@ -132,7 +125,7 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap() {
132
125
  },
133
126
  delete: {
134
127
  children: /*#__PURE__*/React.createElement("div", {
135
- className: classNames("".concat(prefix, "icon"), "".concat(prefix, "delete"))
128
+ className: classNames("".concat(prefix, "icon"), "".concat(iconPrefix, "delete"))
136
129
  }),
137
130
  tooltip: t('delete'),
138
131
  onClick: function onClick(exec) {
@@ -143,7 +136,7 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap() {
143
136
  },
144
137
  emphasis: {
145
138
  children: /*#__PURE__*/React.createElement("div", {
146
- className: classNames("".concat(prefix, "icon"), "".concat(prefix, "emphasis"))
139
+ className: classNames("".concat(prefix, "icon"), "".concat(iconPrefix, "emphasis"))
147
140
  }),
148
141
  tooltip: t('emphasis'),
149
142
  onClick: function onClick(exec) {
@@ -154,7 +147,7 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap() {
154
147
  },
155
148
  heading: {
156
149
  children: /*#__PURE__*/React.createElement("div", {
157
- className: classNames("".concat(prefix, "icon"), "".concat(prefix, "heading"))
150
+ className: classNames("".concat(prefix, "icon"), "".concat(iconPrefix, "heading"))
158
151
  }),
159
152
  tooltip: t('heading'),
160
153
  popoverRender: function popoverRender(exec, close) {
@@ -178,7 +171,7 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap() {
178
171
  },
179
172
  image: {
180
173
  children: /*#__PURE__*/React.createElement("div", {
181
- className: classNames("".concat(prefix, "icon"), "".concat(prefix, "image"))
174
+ className: classNames("".concat(prefix, "icon"), "".concat(iconPrefix, "image"))
182
175
  }),
183
176
  tooltip: t('image'),
184
177
  popoverRender: function popoverRender(exec, close) {
@@ -204,7 +197,7 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap() {
204
197
  },
205
198
  inlineCode: {
206
199
  children: /*#__PURE__*/React.createElement("div", {
207
- className: classNames("".concat(prefix, "icon"), "".concat(prefix, "inline-code"))
200
+ className: classNames("".concat(prefix, "icon"), "".concat(iconPrefix, "inline-code"))
208
201
  }),
209
202
  tooltip: t('inlineCode'),
210
203
  onClick: function onClick(exec) {
@@ -215,7 +208,7 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap() {
215
208
  },
216
209
  inlineMath: {
217
210
  children: /*#__PURE__*/React.createElement("div", {
218
- className: classNames("".concat(prefix, "icon"), "".concat(prefix, "inline-math"))
211
+ className: classNames("".concat(prefix, "icon"), "".concat(iconPrefix, "inline-math"))
219
212
  }),
220
213
  tooltip: t('inlineMath'),
221
214
  onClick: function onClick(exec) {
@@ -226,7 +219,7 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap() {
226
219
  },
227
220
  link: {
228
221
  children: /*#__PURE__*/React.createElement("div", {
229
- className: classNames("".concat(prefix, "icon"), "".concat(prefix, "link"))
222
+ className: classNames("".concat(prefix, "icon"), "".concat(iconPrefix, "link"))
230
223
  }),
231
224
  tooltip: t('link'),
232
225
  popoverRender: function popoverRender(exec, close) {
@@ -252,7 +245,7 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap() {
252
245
  },
253
246
  math: {
254
247
  children: /*#__PURE__*/React.createElement("div", {
255
- className: classNames("".concat(prefix, "icon"), "".concat(prefix, "math"))
248
+ className: classNames("".concat(prefix, "icon"), "".concat(iconPrefix, "math"))
256
249
  }),
257
250
  tooltip: t('math'),
258
251
  onClick: function onClick(exec) {
@@ -265,7 +258,7 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap() {
265
258
  var history = _ref2.history;
266
259
  return {
267
260
  children: /*#__PURE__*/React.createElement("div", {
268
- className: classNames("".concat(prefix, "icon"), "".concat(prefix, "redo"))
261
+ className: classNames("".concat(prefix, "icon"), "".concat(iconPrefix, "redo"))
269
262
  }),
270
263
  disabled: history.index === history.states.length - 1,
271
264
  tooltip: t('redo'),
@@ -276,7 +269,7 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap() {
276
269
  },
277
270
  strong: {
278
271
  children: /*#__PURE__*/React.createElement("div", {
279
- className: classNames("".concat(prefix, "icon"), "".concat(prefix, "strong"))
272
+ className: classNames("".concat(prefix, "icon"), "".concat(iconPrefix, "strong"))
280
273
  }),
281
274
  tooltip: t('strong'),
282
275
  onClick: function onClick(exec) {
@@ -287,7 +280,7 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap() {
287
280
  },
288
281
  thematicBreak: {
289
282
  children: /*#__PURE__*/React.createElement("div", {
290
- className: classNames("".concat(prefix, "icon"), "".concat(prefix, "thematic-break"))
283
+ className: classNames("".concat(prefix, "icon"), "".concat(iconPrefix, "thematic-break"))
291
284
  }),
292
285
  tooltip: t('thematicBreak'),
293
286
  onClick: function onClick(exec) {
@@ -300,7 +293,7 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap() {
300
293
  var history = _ref3.history;
301
294
  return {
302
295
  children: /*#__PURE__*/React.createElement("div", {
303
- className: classNames("".concat(prefix, "icon"), "".concat(prefix, "undo"))
296
+ className: classNames("".concat(prefix, "icon"), "".concat(iconPrefix, "undo"))
304
297
  }),
305
298
  disabled: !history.index,
306
299
  tooltip: t('undo'),
@@ -31,11 +31,12 @@ export var useLocale = function useLocale(slice) {
31
31
  };
32
32
  };
33
33
  export var getFormat = function getFormat(locale, slice) {
34
+ var _zh_CN$en_US$locale2;
35
+ var message = ((_zh_CN$en_US$locale2 = {
36
+ zh_CN: zh_CN,
37
+ en_US: en_US
38
+ }[locale]) !== null && _zh_CN$en_US$locale2 !== void 0 ? _zh_CN$en_US$locale2 : zh_CN)[slice];
34
39
  return function (key) {
35
- var _zh_CN$en_US$locale2;
36
- return ((_zh_CN$en_US$locale2 = {
37
- zh_CN: zh_CN,
38
- en_US: en_US
39
- }[locale]) !== null && _zh_CN$en_US$locale2 !== void 0 ? _zh_CN$en_US$locale2 : zh_CN)[slice][key];
40
+ return message[key];
40
41
  };
41
42
  };
@@ -9,11 +9,10 @@
9
9
  padding: 0.4em 1em;
10
10
  border-bottom: 1px solid #dedede;
11
11
  cursor: pointer;
12
- user-select: none;
13
12
  }
14
13
  .x-star-editor-file-input .x-star-editor-tabs .x-star-editor-tab:hover {
15
14
  color: #40a9ff;
16
- border-bottom: 1px solid #1890ff;
15
+ border-bottom: 1px solid #40a9ff;
17
16
  }
18
17
  .x-star-editor-file-input .x-star-editor-tabs .x-star-editor-tab.x-star-editor-active {
19
18
  color: #1890ff;
@@ -69,10 +68,10 @@
69
68
  opacity: 0;
70
69
  }
71
70
  .x-star-editor-file-input .x-star-editor-field .x-star-editor-file-container .x-star-editor-input {
72
- width: 12em;
71
+ width: 11.5em;
73
72
  }
74
73
  .x-star-editor-file-input .x-star-editor-field .x-star-editor-file-container .x-star-editor-button {
75
- width: 7.5em;
74
+ width: 8em;
76
75
  }
77
76
 
78
77
  .x-star-editor-toolbar {
@@ -111,46 +110,46 @@
111
110
  height: 100%;
112
111
  background-size: contain;
113
112
  }
114
- .x-star-editor-toolbar .x-star-editor-button-container > .x-star-editor-button .x-star-editor-icon.x-star-editor-blockquote {
113
+ .x-star-editor-toolbar .x-star-editor-button-container > .x-star-editor-button .x-star-editor-icon.x-star-editor-icon-blockquote {
115
114
  background-image: url(icons/blockquote.svg);
116
115
  }
117
- .x-star-editor-toolbar .x-star-editor-button-container > .x-star-editor-button .x-star-editor-icon.x-star-editor-code {
116
+ .x-star-editor-toolbar .x-star-editor-button-container > .x-star-editor-button .x-star-editor-icon.x-star-editor-icon-code {
118
117
  background-image: url(icons/code.svg);
119
118
  }
120
- .x-star-editor-toolbar .x-star-editor-button-container > .x-star-editor-button .x-star-editor-icon.x-star-editor-delete {
119
+ .x-star-editor-toolbar .x-star-editor-button-container > .x-star-editor-button .x-star-editor-icon.x-star-editor-icon-delete {
121
120
  background-image: url(icons/delete.svg);
122
121
  }
123
- .x-star-editor-toolbar .x-star-editor-button-container > .x-star-editor-button .x-star-editor-icon.x-star-editor-emphasis {
122
+ .x-star-editor-toolbar .x-star-editor-button-container > .x-star-editor-button .x-star-editor-icon.x-star-editor-icon-emphasis {
124
123
  background-image: url(icons/emphasis.svg);
125
124
  }
126
- .x-star-editor-toolbar .x-star-editor-button-container > .x-star-editor-button .x-star-editor-icon.x-star-editor-heading {
125
+ .x-star-editor-toolbar .x-star-editor-button-container > .x-star-editor-button .x-star-editor-icon.x-star-editor-icon-heading {
127
126
  background-image: url(icons/heading.svg);
128
127
  }
129
- .x-star-editor-toolbar .x-star-editor-button-container > .x-star-editor-button .x-star-editor-icon.x-star-editor-image {
128
+ .x-star-editor-toolbar .x-star-editor-button-container > .x-star-editor-button .x-star-editor-icon.x-star-editor-icon-image {
130
129
  background-image: url(icons/image.svg);
131
130
  }
132
- .x-star-editor-toolbar .x-star-editor-button-container > .x-star-editor-button .x-star-editor-icon.x-star-editor-inline-code {
131
+ .x-star-editor-toolbar .x-star-editor-button-container > .x-star-editor-button .x-star-editor-icon.x-star-editor-icon-inline-code {
133
132
  background-image: url(icons/inline-code.svg);
134
133
  }
135
- .x-star-editor-toolbar .x-star-editor-button-container > .x-star-editor-button .x-star-editor-icon.x-star-editor-inline-math {
134
+ .x-star-editor-toolbar .x-star-editor-button-container > .x-star-editor-button .x-star-editor-icon.x-star-editor-icon-inline-math {
136
135
  background-image: url(icons/inline-math.svg);
137
136
  }
138
- .x-star-editor-toolbar .x-star-editor-button-container > .x-star-editor-button .x-star-editor-icon.x-star-editor-link {
137
+ .x-star-editor-toolbar .x-star-editor-button-container > .x-star-editor-button .x-star-editor-icon.x-star-editor-icon-link {
139
138
  background-image: url(icons/link.svg);
140
139
  }
141
- .x-star-editor-toolbar .x-star-editor-button-container > .x-star-editor-button .x-star-editor-icon.x-star-editor-math {
140
+ .x-star-editor-toolbar .x-star-editor-button-container > .x-star-editor-button .x-star-editor-icon.x-star-editor-icon-math {
142
141
  background-image: url(icons/math.svg);
143
142
  }
144
- .x-star-editor-toolbar .x-star-editor-button-container > .x-star-editor-button .x-star-editor-icon.x-star-editor-redo {
143
+ .x-star-editor-toolbar .x-star-editor-button-container > .x-star-editor-button .x-star-editor-icon.x-star-editor-icon-redo {
145
144
  background-image: url(icons/redo.svg);
146
145
  }
147
- .x-star-editor-toolbar .x-star-editor-button-container > .x-star-editor-button .x-star-editor-icon.x-star-editor-strong {
146
+ .x-star-editor-toolbar .x-star-editor-button-container > .x-star-editor-button .x-star-editor-icon.x-star-editor-icon-strong {
148
147
  background-image: url(icons/strong.svg);
149
148
  }
150
- .x-star-editor-toolbar .x-star-editor-button-container > .x-star-editor-button .x-star-editor-icon.x-star-editor-thematic-break {
149
+ .x-star-editor-toolbar .x-star-editor-button-container > .x-star-editor-button .x-star-editor-icon.x-star-editor-icon-thematic-break {
151
150
  background-image: url(icons/thematic-break.svg);
152
151
  }
153
- .x-star-editor-toolbar .x-star-editor-button-container > .x-star-editor-button .x-star-editor-icon.x-star-editor-undo {
152
+ .x-star-editor-toolbar .x-star-editor-button-container > .x-star-editor-button .x-star-editor-icon.x-star-editor-icon-undo {
154
153
  background-image: url(icons/undo.svg);
155
154
  }
156
155
  .x-star-editor-toolbar .x-star-editor-button-container .x-star-editor-tooltip {
@@ -201,6 +200,14 @@
201
200
  margin: 0.4em;
202
201
  border: 1px solid #dedede;
203
202
  }
203
+ .x-star-editor-toolbar *,
204
+ .x-star-editor-toolbar ::before,
205
+ .x-star-editor-toolbar ::after {
206
+ box-sizing: border-box;
207
+ }
208
+ .x-star-editor-toolbar ::selection {
209
+ background-color: #c1def1;
210
+ }
204
211
 
205
212
  .x-star-editor-editor {
206
213
  display: flex;
@@ -217,7 +224,7 @@
217
224
  .x-star-editor-editor .x-star-editor-md-viewer {
218
225
  padding: 0 1em;
219
226
  flex: 1;
220
- background-color: white;
227
+ background-color: #fff;
221
228
  border: 1px solid #dedede;
222
229
  border-top: none;
223
230
  border-bottom-right-radius: 0.3em;
@@ -225,12 +232,12 @@
225
232
  }
226
233
 
227
234
  .x-star-editor-md-editor {
228
- padding: 0 1em;
229
235
  position: relative;
236
+ padding: 0 1em;
230
237
  line-height: 1.6em;
231
238
  white-space: break-spaces;
232
239
  color: rgba(0, 0, 0, 0.88);
233
- background-color: white;
240
+ background-color: #fff;
234
241
  border: 1px solid #dedede;
235
242
  border-top: none;
236
243
  border-bottom-right-radius: 0.3em;
@@ -244,6 +251,11 @@
244
251
  .x-star-editor-md-editor > :last-child {
245
252
  margin-bottom: 1em;
246
253
  }
254
+ .x-star-editor-md-editor *,
255
+ .x-star-editor-md-editor ::before,
256
+ .x-star-editor-md-editor ::after {
257
+ box-sizing: border-box;
258
+ }
247
259
  .x-star-editor-md-editor ::selection {
248
260
  background-color: #c1def1;
249
261
  }
@@ -252,6 +264,11 @@
252
264
  position: relative;
253
265
  color: rgba(0, 0, 0, 0.88);
254
266
  }
267
+ .x-star-editor-md-viewer *,
268
+ .x-star-editor-md-viewer ::before,
269
+ .x-star-editor-md-viewer ::after {
270
+ box-sizing: border-box;
271
+ }
255
272
  .x-star-editor-md-viewer ::selection {
256
273
  background-color: #c1def1;
257
274
  }
@@ -390,7 +407,7 @@
390
407
  }
391
408
 
392
409
  .katex .katex-version::after {
393
- content: "0.16.6";
410
+ content: "0.16.8";
394
411
  }
395
412
 
396
413
  .katex .katex-mathml {
@@ -1563,19 +1580,21 @@ body {
1563
1580
  counter-reset: katexEqnNo mmlEqnNo;
1564
1581
  }
1565
1582
 
1566
- .x-star-editor-md-editor .x-star-editor-md-delimiter,
1567
- .x-star-editor-md-editor .x-star-editor-md-break {
1583
+ .x-star-editor-md-editor .x-star-editor-md-break,
1584
+ .x-star-editor-md-editor .x-star-editor-md-delimiter {
1568
1585
  color: rgba(0, 0, 0, 0.28);
1569
1586
  }
1570
1587
  .x-star-editor-md-editor .x-star-editor-md-code,
1571
- .x-star-editor-md-editor .x-star-editor-md-html {
1588
+ .x-star-editor-md-editor .x-star-editor-md-html,
1589
+ .x-star-editor-md-editor .x-star-editor-md-inlineCode {
1572
1590
  tab-size: 4;
1573
1591
  font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace;
1574
1592
  }
1575
1593
  .x-star-editor-md-editor .x-star-editor-md-code,
1576
1594
  .x-star-editor-md-editor .x-star-editor-md-html,
1595
+ .x-star-editor-md-editor .x-star-editor-md-inlineCode,
1596
+ .x-star-editor-md-editor .x-star-editor-md-inlineMath,
1577
1597
  .x-star-editor-md-editor .x-star-editor-md-math {
1578
- position: relative;
1579
1598
  color: #1d39c4;
1580
1599
  }
1581
1600
  .x-star-editor-md-editor .x-star-editor-md-definition,
@@ -1596,43 +1615,31 @@ body {
1596
1615
  font-style: italic;
1597
1616
  }
1598
1617
  .x-star-editor-md-editor .x-star-editor-md-heading {
1599
- font-weight: bold;
1600
1618
  line-height: 1.6em;
1619
+ font-weight: bold;
1601
1620
  }
1602
- .x-star-editor-md-editor .x-star-editor-md-heading.x-star-editor-md-heading1 {
1621
+ .x-star-editor-md-editor .x-star-editor-md-heading.x-star-editor-md-heading-1 {
1603
1622
  font-size: 1.6em;
1604
1623
  }
1605
- .x-star-editor-md-editor .x-star-editor-md-heading.x-star-editor-md-heading2 {
1624
+ .x-star-editor-md-editor .x-star-editor-md-heading.x-star-editor-md-heading-2 {
1606
1625
  font-size: 1.3em;
1607
1626
  }
1608
- .x-star-editor-md-editor .x-star-editor-md-heading.x-star-editor-md-heading3 {
1627
+ .x-star-editor-md-editor .x-star-editor-md-heading.x-star-editor-md-heading-3 {
1609
1628
  font-size: 1.2em;
1610
1629
  }
1611
- .x-star-editor-md-editor .x-star-editor-md-heading.x-star-editor-md-heading4 {
1630
+ .x-star-editor-md-editor .x-star-editor-md-heading.x-star-editor-md-heading-4 {
1612
1631
  font-size: 1.1em;
1613
1632
  }
1614
- .x-star-editor-md-editor .x-star-editor-md-heading.x-star-editor-md-heading5 {
1633
+ .x-star-editor-md-editor .x-star-editor-md-heading.x-star-editor-md-heading-5 {
1615
1634
  font-size: 1em;
1616
1635
  }
1617
- .x-star-editor-md-editor .x-star-editor-md-heading.x-star-editor-md-heading6 {
1636
+ .x-star-editor-md-editor .x-star-editor-md-heading.x-star-editor-md-heading-6 {
1618
1637
  font-size: 0.9em;
1619
1638
  }
1620
- .x-star-editor-md-editor .x-star-editor-md-inlineCode {
1621
- tab-size: 4;
1622
- font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace;
1623
- }
1624
- .x-star-editor-md-editor .x-star-editor-md-inlineCode,
1625
- .x-star-editor-md-editor .x-star-editor-md-inlineMath {
1626
- color: #1d39c4;
1627
- }
1628
1639
  .x-star-editor-md-editor .x-star-editor-md-strong {
1629
1640
  font-weight: bold;
1630
1641
  }
1631
1642
 
1632
- /**
1633
- * VS theme by Andrew Lock (https://andrewlock.net)
1634
- * Inspired by Visual Studio syntax coloring
1635
- */
1636
1643
  .x-star-editor-md-viewer.x-star-editor-md-viewer {
1637
1644
  /* Code blocks */
1638
1645
  /* Inline code */
@@ -1,6 +1,4 @@
1
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
- 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); }
3
- 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; }
1
+ import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
4
2
  import { useEffect, useRef } from 'react';
5
3
  import { editorRender } from "./markdown";
6
4
 
@@ -1,6 +1,4 @@
1
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
- 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); }
3
- 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; }
1
+ import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
4
2
  import { createSelection, getRange } from "./container";
5
3
 
6
4
  /**
@@ -1,19 +1,6 @@
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 _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
- 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."); }
4
- 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; } }
5
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
6
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
- 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; }
9
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
10
- 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); }
11
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
12
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
- 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); }
14
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
15
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
16
- 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; }
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
17
4
  import { useReducer } from 'react';
18
5
  import { createSelection, getRange } from "./container";
19
6
 
@@ -1,16 +1,6 @@
1
1
  /// <reference types="react" />
2
- import type { Components } from 'hast-util-to-jsx-runtime';
3
2
  import { defaultSchema } from 'rehype-sanitize';
4
- type Schema = typeof defaultSchema;
5
- export declare const getDefaultSchema: () => Schema;
6
- /**
7
- * 将 Markdown 文本解析为 Mdast 树并转换为 Hast 树的处理器
8
- */
9
- declare const processor: import("unified").FrozenProcessor<import("mdast").Root, import("hast").Root, import("hast").Root, void>;
10
- /**
11
- * Mdast 节点
12
- */
13
- export type MdastNode = ReturnType<(typeof processor)['parse']>['children'][number];
3
+ import type { ViewerOptions } from '../x-star-md-viewer';
14
4
  /**
15
5
  * 将 Markdown 文本映射到 DOM 树,第一层为 `<div>` 块元素,第二层为 `<div>` 行元素,之后均为 `<span>` 元素
16
6
  *
@@ -18,30 +8,42 @@ export type MdastNode = ReturnType<(typeof processor)['parse']>['children'][numb
18
8
  * @returns DOM 树
19
9
  */
20
10
  export declare const editorRender: (sourceCode: string) => HTMLDivElement;
21
- export interface ViewerOptions {
22
- /**
23
- * 自定义过滤模式
24
- */
25
- customSchema: Schema;
26
- /**
27
- * 自定义 HTML 元素
28
- */
29
- customHTMLElements: Partial<Components>;
30
- /**
31
- * 自定义块
32
- */
33
- customBlocks: Partial<Record<string, React.ComponentType<{
34
- children: string;
35
- }>>>;
36
- }
37
11
  /**
38
- * 将 Markdown 文本映射到 React 虚拟 DOM 树
12
+ * 将 Mdast 树转成 Hast 树的处理器
13
+ */
14
+ declare const toHastProcessor: import("unified").FrozenProcessor<import("mdast").Root, import("hast").Root, import("hast").Root, void>;
15
+ /**
16
+ * Hast 根节点
17
+ */
18
+ export type HastRoot = ReturnType<(typeof toHastProcessor)['runSync']>;
19
+ /**
20
+ * 将 Markdown 文本转成 Hast 树
39
21
  *
40
22
  * @param sourceCode Markdown 文本
23
+ * @returns Hast 树
24
+ */
25
+ export declare const preViewerRender: (sourceCode: string) => import("hast").Root;
26
+ /**
27
+ * 过滤模式
28
+ */
29
+ export type Schema = typeof defaultSchema;
30
+ export declare const getDefaultSchema: () => Schema;
31
+ /**
32
+ * 将 Hast 树转成新的 Hast 树
33
+ *
34
+ * @param root Hast 树
35
+ * @param schema 过滤模式
36
+ * @returns 新的 Hast 树
37
+ */
38
+ export declare const viewerRender: (root: HastRoot, schema: Schema) => import("hast").Root;
39
+ /**
40
+ * 将 Hast 树映射到 React 虚拟 DOM 树
41
+ *
42
+ * @param root Hast 树
41
43
  * @param options 配置项
42
44
  * @returns React 虚拟 DOM 树
43
45
  */
44
- export declare const viewerRender: (sourceCode: string, options: ViewerOptions) => JSX.Element;
46
+ export declare const postViewerRender: (root: HastRoot, options: ViewerOptions) => JSX.Element;
45
47
  /**
46
48
  * 将 Markdown 文本转成 HTML 文本
47
49
  *