x-star-editor 0.4.0 → 0.4.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.
@@ -8,6 +8,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
8
8
  var _excluded = ["checked"];
9
9
  import { toJsxRuntime } from 'hast-util-to-jsx-runtime';
10
10
  import { toText as hastToText } from 'hast-util-to-text';
11
+ import { toString } from 'mdast-util-to-string';
11
12
  import { Fragment, jsx, jsxs } from 'react/jsx-runtime';
12
13
  import rehypeKatex from 'rehype-katex';
13
14
  import rehypeMermaid from 'rehype-mermaidjs';
@@ -22,7 +23,6 @@ import remarkMath from 'remark-math';
22
23
  import remarkParse from 'remark-parse';
23
24
  import remarkRehype from 'remark-rehype';
24
25
  import remarkStringify from 'remark-stringify';
25
- import strip from 'strip-markdown';
26
26
  import { unified } from 'unified';
27
27
  import { prefix } from "./global";
28
28
  import rehypeCustom from "./rehype/rehype-custom";
@@ -430,14 +430,6 @@ var toMarkdownProcessor = unified().use(rehypeRemark, {
430
430
  export var toMarkdown = function toMarkdown(sourceCode) {
431
431
  return toMarkdownProcessor.stringify(toMarkdownProcessor.runSync(toHTMLProcessor.runSync(toHTMLProcessor.parse(sourceCode))));
432
432
  };
433
- var toTextProcessor = unified().use(remarkParse).use(remarkGfm).use(remarkMath).use(strip, {
434
- remove: ['math', ['inlineMath', function (node) {
435
- return {
436
- type: 'text',
437
- value: node.value
438
- };
439
- }]]
440
- }).use(remarkStringify).freeze();
441
433
 
442
434
  /**
443
435
  * 将 Markdown 文本转成纯文本
@@ -446,5 +438,5 @@ var toTextProcessor = unified().use(remarkParse).use(remarkGfm).use(remarkMath).
446
438
  * @returns 纯文本
447
439
  */
448
440
  export var toText = function toText(sourceCode) {
449
- return toTextProcessor.processSync(sourceCode).toString();
441
+ return toString(toMdastProcessor.parse(sourceCode));
450
442
  };
@@ -235,7 +235,7 @@ var XStarEditor = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
235
235
  };
236
236
  }
237
237
  }, [fullscreen]);
238
- var _useState5 = useState(initialValue),
238
+ var _useState5 = useState(value !== null && value !== void 0 ? value : initialValue),
239
239
  _useState6 = _slicedToArray(_useState5, 2),
240
240
  sourceCode = _useState6[0],
241
241
  setSourceCode = _useState6[1];
@@ -25,7 +25,7 @@ var XStarMdEditor = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
25
25
  onInsertFile = _ref.onInsertFile;
26
26
  var containerRef = useRef(null);
27
27
  var container = useContainer(containerRef);
28
- var _useHistory = useHistory(initialValue, readOnly),
28
+ var _useHistory = useHistory(value !== null && value !== void 0 ? value : initialValue, readOnly),
29
29
  history = _useHistory.history,
30
30
  sourceCode = _useHistory.sourceCode,
31
31
  selection = _useHistory.selection,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x-star-editor",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "An editor developed by turingstar",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",
@@ -48,6 +48,7 @@
48
48
  "classnames": "^2.3.2",
49
49
  "hast-util-to-jsx-runtime": "^1.2.0",
50
50
  "hast-util-to-text": "^3.0.0",
51
+ "mdast-util-to-string": "^3.2.0",
51
52
  "rehype-katex": "^6.0.3",
52
53
  "rehype-mermaidjs": "^1.0.1",
53
54
  "rehype-prism-plus": "^1.6.1",
@@ -61,7 +62,6 @@
61
62
  "remark-parse": "^10.0.2",
62
63
  "remark-rehype": "^10.1.0",
63
64
  "remark-stringify": "^10.0.3",
64
- "strip-markdown": "^5.0.1",
65
65
  "tinykeys": "^2.1.0",
66
66
  "unified": "^10.1.2",
67
67
  "unist-util-visit": "^4.0.0"