@mdxeditor/editor 3.4.0 → 3.4.1

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.
@@ -5,6 +5,7 @@ import { $setBlocksType } from "@lexical/selection";
5
5
  import { $findMatchingParent, $wrapNodeInElement, $insertNodeToNearestRoot } from "@lexical/utils";
6
6
  import { Cell, withLatestFrom, Signal, filter, map, useCellValue, scan } from "@mdxeditor/gurx";
7
7
  import { createCommand, FORMAT_TEXT_COMMAND, $isRootOrShadowRoot, $getRoot, $setSelection, $getSelection, $insertNodes, SELECTION_CHANGE_COMMAND, COMMAND_PRIORITY_CRITICAL, DecoratorNode, $createParagraphNode, FOCUS_COMMAND, KEY_DOWN_COMMAND, $isDecoratorNode, BLUR_COMMAND, $isRangeSelection, ParagraphNode, TextNode, createEditor } from "lexical";
8
+ import { gfmStrikethrough } from "micromark-extension-gfm-strikethrough";
8
9
  import { gfmStrikethroughFromMarkdown, gfmStrikethroughToMarkdown } from "mdast-util-gfm-strikethrough";
9
10
  import { mdxJsxToMarkdown, mdxJsxFromMarkdown } from "mdast-util-mdx-jsx";
10
11
  import { mdxJsx } from "micromark-extension-mdx-jsx";
@@ -29,7 +30,6 @@ import { MdastTextVisitor } from "./MdastTextVisitor.js";
29
30
  import { SharedHistoryPlugin } from "./SharedHistoryPlugin.js";
30
31
  import { commentFromMarkdown, comment } from "../../mdastUtilHtmlComment.js";
31
32
  import { lexicalTheme } from "../../styles/lexicalTheme.js";
32
- import { gfmStrikethrough } from "../../node_modules/micromark-extension-gfm-strikethrough/lib/syntax.js";
33
33
  const NESTED_EDITOR_UPDATED_COMMAND = createCommand("NESTED_EDITOR_UPDATED_COMMAND");
34
34
  const rootEditor$ = Cell(null);
35
35
  const activeEditor$ = Cell(null);
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "*.css"
12
12
  ],
13
13
  "type": "module",
14
- "version": "3.4.0",
14
+ "version": "3.4.1",
15
15
  "description": "React component for rich text markdown editing",
16
16
  "scripts": {
17
17
  "build": "vite build",
@@ -78,6 +78,7 @@
78
78
  "mdast-util-to-markdown": "^2.1.0",
79
79
  "micromark-extension-directive": "^3.0.0",
80
80
  "micromark-extension-frontmatter": "^2.0.0",
81
+ "micromark-extension-gfm-strikethrough": "^2.0.0",
81
82
  "micromark-extension-gfm-table": "^2.0.0",
82
83
  "micromark-extension-gfm-task-list-item": "^2.0.1",
83
84
  "micromark-extension-mdx-jsx": "^3.0.0",
@@ -1,114 +0,0 @@
1
- import { splice } from "../../micromark-util-chunked/index.js";
2
- import { classifyCharacter } from "../../micromark-util-classify-character/index.js";
3
- import { resolveAll } from "../../micromark-util-resolve-all/index.js";
4
- function gfmStrikethrough(options) {
5
- const options_ = options || {};
6
- let single = options_.singleTilde;
7
- const tokenizer = {
8
- tokenize: tokenizeStrikethrough,
9
- resolveAll: resolveAllStrikethrough
10
- };
11
- if (single === null || single === void 0) {
12
- single = true;
13
- }
14
- return {
15
- text: {
16
- [126]: tokenizer
17
- },
18
- insideSpan: {
19
- null: [tokenizer]
20
- },
21
- attentionMarkers: {
22
- null: [126]
23
- }
24
- };
25
- function resolveAllStrikethrough(events, context) {
26
- let index = -1;
27
- while (++index < events.length) {
28
- if (events[index][0] === "enter" && events[index][1].type === "strikethroughSequenceTemporary" && events[index][1]._close) {
29
- let open = index;
30
- while (open--) {
31
- if (events[open][0] === "exit" && events[open][1].type === "strikethroughSequenceTemporary" && events[open][1]._open && // If the sizes are the same:
32
- events[index][1].end.offset - events[index][1].start.offset === events[open][1].end.offset - events[open][1].start.offset) {
33
- events[index][1].type = "strikethroughSequence";
34
- events[open][1].type = "strikethroughSequence";
35
- const strikethrough = {
36
- type: "strikethrough",
37
- start: Object.assign({}, events[open][1].start),
38
- end: Object.assign({}, events[index][1].end)
39
- };
40
- const text = {
41
- type: "strikethroughText",
42
- start: Object.assign({}, events[open][1].end),
43
- end: Object.assign({}, events[index][1].start)
44
- };
45
- const nextEvents = [
46
- ["enter", strikethrough, context],
47
- ["enter", events[open][1], context],
48
- ["exit", events[open][1], context],
49
- ["enter", text, context]
50
- ];
51
- const insideSpan = context.parser.constructs.insideSpan.null;
52
- if (insideSpan) {
53
- splice(
54
- nextEvents,
55
- nextEvents.length,
56
- 0,
57
- resolveAll(insideSpan, events.slice(open + 1, index), context)
58
- );
59
- }
60
- splice(nextEvents, nextEvents.length, 0, [
61
- ["exit", text, context],
62
- ["enter", events[index][1], context],
63
- ["exit", events[index][1], context],
64
- ["exit", strikethrough, context]
65
- ]);
66
- splice(events, open - 1, index - open + 3, nextEvents);
67
- index = open + nextEvents.length - 2;
68
- break;
69
- }
70
- }
71
- }
72
- }
73
- index = -1;
74
- while (++index < events.length) {
75
- if (events[index][1].type === "strikethroughSequenceTemporary") {
76
- events[index][1].type = "data";
77
- }
78
- }
79
- return events;
80
- }
81
- function tokenizeStrikethrough(effects, ok, nok) {
82
- const previous = this.previous;
83
- const events = this.events;
84
- let size = 0;
85
- return start;
86
- function start(code) {
87
- if (previous === 126 && events[events.length - 1][1].type !== "characterEscape") {
88
- return nok(code);
89
- }
90
- effects.enter("strikethroughSequenceTemporary");
91
- return more(code);
92
- }
93
- function more(code) {
94
- const before = classifyCharacter(previous);
95
- if (code === 126) {
96
- if (size > 1)
97
- return nok(code);
98
- effects.consume(code);
99
- size++;
100
- return more;
101
- }
102
- if (size < 2 && !single)
103
- return nok(code);
104
- const token = effects.exit("strikethroughSequenceTemporary");
105
- const after = classifyCharacter(code);
106
- token._open = !after || after === 2 && Boolean(before);
107
- token._close = !before || before === 2 && Boolean(after);
108
- return ok(code);
109
- }
110
- }
111
- }
112
- export {
113
- gfmStrikethrough
114
- };
@@ -1,29 +0,0 @@
1
- function splice(list, start, remove, items) {
2
- const end = list.length;
3
- let chunkStart = 0;
4
- let parameters;
5
- if (start < 0) {
6
- start = -start > end ? 0 : end + start;
7
- } else {
8
- start = start > end ? end : start;
9
- }
10
- remove = remove > 0 ? remove : 0;
11
- if (items.length < 1e4) {
12
- parameters = Array.from(items);
13
- parameters.unshift(start, remove);
14
- list.splice(...parameters);
15
- } else {
16
- if (remove)
17
- list.splice(start, remove);
18
- while (chunkStart < items.length) {
19
- parameters = items.slice(chunkStart, chunkStart + 1e4);
20
- parameters.unshift(start, 0);
21
- list.splice(...parameters);
22
- chunkStart += 1e4;
23
- start += 1e4;
24
- }
25
- }
26
- }
27
- export {
28
- splice
29
- };
@@ -1,12 +0,0 @@
1
- import { markdownLineEndingOrSpace, unicodeWhitespace, unicodePunctuation } from "micromark-util-character";
2
- function classifyCharacter(code) {
3
- if (code === null || markdownLineEndingOrSpace(code) || unicodeWhitespace(code)) {
4
- return 1;
5
- }
6
- if (unicodePunctuation(code)) {
7
- return 2;
8
- }
9
- }
10
- export {
11
- classifyCharacter
12
- };
@@ -1,15 +0,0 @@
1
- function resolveAll(constructs, events, context) {
2
- const called = [];
3
- let index = -1;
4
- while (++index < constructs.length) {
5
- const resolve = constructs[index].resolveAll;
6
- if (resolve && !called.includes(resolve)) {
7
- events = resolve(events, context);
8
- called.push(resolve);
9
- }
10
- }
11
- return events;
12
- }
13
- export {
14
- resolveAll
15
- };