@mdxeditor/editor 1.14.3 → 2.0.0
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/MDXEditor.js +19 -25
- package/dist/RealmWithPlugins.js +36 -0
- package/dist/directive-editors/GenericDirectiveEditor.js +7 -4
- package/dist/index.d.ts +2590 -62
- package/dist/index.js +138 -66
- package/dist/jsx-editors/GenericJsxEditor.js +12 -9
- package/dist/plugins/codeblock/CodeBlockNode.js +5 -5
- package/dist/plugins/codeblock/index.js +37 -63
- package/dist/plugins/codemirror/CodeMirrorEditor.js +3 -2
- package/dist/plugins/codemirror/index.js +28 -45
- package/dist/plugins/core/GenericHTMLNode.js +9 -1
- package/dist/plugins/core/MdastHTMLNode.js +0 -1
- package/dist/plugins/core/NestedLexicalEditor.js +11 -10
- package/dist/plugins/core/PropertyPopover.js +3 -2
- package/dist/plugins/core/SharedHistoryPlugin.js +3 -3
- package/dist/plugins/core/index.js +426 -385
- package/dist/plugins/core/ui/DownshiftAutoComplete.js +3 -2
- package/dist/plugins/core/ui/PopoverUtils.js +3 -2
- package/dist/plugins/diff-source/DiffSourceWrapper.js +3 -4
- package/dist/plugins/diff-source/DiffViewer.js +7 -7
- package/dist/plugins/diff-source/SourceEditor.js +6 -6
- package/dist/plugins/diff-source/index.js +17 -52
- package/dist/plugins/directives/DirectiveNode.js +28 -5
- package/dist/plugins/directives/index.js +36 -43
- package/dist/plugins/frontmatter/FrontmatterEditor.js +20 -16
- package/dist/plugins/frontmatter/index.js +51 -62
- package/dist/plugins/headings/index.js +43 -49
- package/dist/plugins/image/ImageDialog.js +11 -7
- package/dist/plugins/image/ImageEditor.js +10 -7
- package/dist/plugins/image/ImageNode.js +27 -5
- package/dist/plugins/image/index.js +65 -72
- package/dist/plugins/jsx/LexicalJsxNode.js +3 -2
- package/dist/plugins/jsx/index.js +48 -60
- package/dist/plugins/link/index.js +15 -20
- package/dist/plugins/link-dialog/LinkDialog.js +17 -16
- package/dist/plugins/link-dialog/index.js +194 -216
- package/dist/plugins/lists/index.js +50 -65
- package/dist/plugins/markdown-shortcut/index.js +12 -15
- package/dist/plugins/quote/index.js +11 -19
- package/dist/plugins/sandpack/SandpackEditor.js +3 -2
- package/dist/plugins/sandpack/index.js +34 -50
- package/dist/plugins/sandpack/useCodeMirrorRef.js +7 -6
- package/dist/plugins/table/TableEditor.js +12 -13
- package/dist/plugins/table/TableNode.js +28 -0
- package/dist/plugins/table/index.js +32 -39
- package/dist/plugins/thematic-break/index.js +19 -32
- package/dist/plugins/toolbar/components/BlockTypeSelect.js +9 -8
- package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.js +4 -4
- package/dist/plugins/toolbar/components/ChangeAdmonitionType.js +3 -2
- package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.js +5 -5
- package/dist/plugins/toolbar/components/CodeToggle.js +4 -3
- package/dist/plugins/toolbar/components/CreateLink.js +6 -4
- package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.js +5 -5
- package/dist/plugins/toolbar/components/InsertAdmonition.js +5 -3
- package/dist/plugins/toolbar/components/InsertCodeBlock.js +5 -3
- package/dist/plugins/toolbar/components/InsertFrontmatter.js +6 -5
- package/dist/plugins/toolbar/components/InsertImage.js +6 -5
- package/dist/plugins/toolbar/components/InsertSandpack.js +5 -4
- package/dist/plugins/toolbar/components/InsertTable.js +5 -3
- package/dist/plugins/toolbar/components/InsertThematicBreak.js +6 -4
- package/dist/plugins/toolbar/components/ListsToggle.js +5 -4
- package/dist/plugins/toolbar/components/ShowSandpackInfo.js +9 -4
- package/dist/plugins/toolbar/components/UndoRedo.js +3 -3
- package/dist/plugins/toolbar/index.js +15 -31
- package/dist/plugins/toolbar/primitives/DialogButton.js +23 -24
- package/dist/plugins/toolbar/primitives/TooltipWrap.js +3 -2
- package/dist/plugins/toolbar/primitives/select.js +5 -4
- package/dist/plugins/toolbar/primitives/toolbar.js +10 -4
- package/dist/style.css +935 -571
- package/dist/styles/globals.css.js +1 -4
- package/dist/styles/lexical-theme.module.css.js +25 -19
- package/dist/styles/ui.module.css.js +103 -103
- package/package.json +64 -317
- package/dist/FormatConstants.d.ts +0 -9
- package/dist/MDXEditor.d.ts +0 -103
- package/dist/directive-editors/AdmonitionDirectiveDescriptor.d.ts +0 -17
- package/dist/directive-editors/GenericDirectiveEditor.d.ts +0 -8
- package/dist/exportMarkdownFromLexical.d.ts +0 -138
- package/dist/gurx/index.d.ts +0 -3
- package/dist/gurx/react.d.ts +0 -152
- package/dist/gurx/react.js +0 -206
- package/dist/gurx/realm.d.ts +0 -148
- package/dist/gurx/realm.js +0 -489
- package/dist/gurx/realmFactory.d.ts +0 -79
- package/dist/gurx/realmFactory.js +0 -32
- package/dist/importMarkdownToLexical.d.ts +0 -101
- package/dist/jsx-editors/GenericJsxEditor.d.ts +0 -8
- package/dist/plugins/codeblock/CodeBlockNode.d.ts +0 -100
- package/dist/plugins/codeblock/CodeBlockVisitor.d.ts +0 -4
- package/dist/plugins/codeblock/MdastCodeVisitor.d.ts +0 -3
- package/dist/plugins/codeblock/index.d.ts +0 -787
- package/dist/plugins/codemirror/CodeMirrorEditor.d.ts +0 -3
- package/dist/plugins/codemirror/index.d.ts +0 -1038
- package/dist/plugins/core/GenericHTMLNode.d.ts +0 -38
- package/dist/plugins/core/Icon.d.ts +0 -6
- package/dist/plugins/core/LexicalGenericHTMLNodeVisitor.d.ts +0 -4
- package/dist/plugins/core/LexicalLinebreakVisitor.d.ts +0 -4
- package/dist/plugins/core/LexicalParagraphVisitor.d.ts +0 -4
- package/dist/plugins/core/LexicalRootVisitor.d.ts +0 -4
- package/dist/plugins/core/LexicalTextVisitor.d.ts +0 -5
- package/dist/plugins/core/MdastBreakVisitor.d.ts +0 -3
- package/dist/plugins/core/MdastFormattingVisitor.d.ts +0 -4
- package/dist/plugins/core/MdastHTMLNode.d.ts +0 -13
- package/dist/plugins/core/MdastHTMLVisitor.d.ts +0 -3
- package/dist/plugins/core/MdastInlineCodeVisitor.d.ts +0 -3
- package/dist/plugins/core/MdastParagraphVisitor.d.ts +0 -3
- package/dist/plugins/core/MdastRootVisitor.d.ts +0 -3
- package/dist/plugins/core/MdastTextVisitor.d.ts +0 -3
- package/dist/plugins/core/NestedLexicalEditor.d.ts +0 -92
- package/dist/plugins/core/PropertyPopover.d.ts +0 -23
- package/dist/plugins/core/SharedHistoryPlugin.d.ts +0 -2
- package/dist/plugins/core/index.d.ts +0 -583
- package/dist/plugins/core/ui/DownshiftAutoComplete.d.ts +0 -15
- package/dist/plugins/core/ui/PopoverUtils.d.ts +0 -4
- package/dist/plugins/diff-source/DiffSourceWrapper.d.ts +0 -4
- package/dist/plugins/diff-source/DiffViewer.d.ts +0 -2
- package/dist/plugins/diff-source/SourceEditor.d.ts +0 -4
- package/dist/plugins/diff-source/index.d.ts +0 -725
- package/dist/plugins/directives/DirectiveNode.d.ts +0 -51
- package/dist/plugins/directives/DirectiveVisitor.d.ts +0 -4
- package/dist/plugins/directives/MdastDirectiveVisitor.d.ts +0 -3
- package/dist/plugins/directives/index.d.ts +0 -773
- package/dist/plugins/frontmatter/FrontmatterEditor.d.ts +0 -6
- package/dist/plugins/frontmatter/FrontmatterNode.d.ts +0 -35
- package/dist/plugins/frontmatter/LexicalFrontmatterVisitor.d.ts +0 -4
- package/dist/plugins/frontmatter/MdastFrontmatterVisitor.d.ts +0 -3
- package/dist/plugins/frontmatter/index.d.ts +0 -717
- package/dist/plugins/headings/LexicalHeadingVisitor.d.ts +0 -4
- package/dist/plugins/headings/MdastHeadingVisitor.d.ts +0 -3
- package/dist/plugins/headings/index.d.ts +0 -707
- package/dist/plugins/image/ImageDialog.d.ts +0 -2
- package/dist/plugins/image/ImageEditor.d.ts +0 -10
- package/dist/plugins/image/ImageNode.d.ts +0 -65
- package/dist/plugins/image/ImageResizer.d.ts +0 -18
- package/dist/plugins/image/LexicalImageVisitor.d.ts +0 -4
- package/dist/plugins/image/MdastImageVisitor.d.ts +0 -6
- package/dist/plugins/image/index.d.ts +0 -804
- package/dist/plugins/jsx/LexicalJsxNode.d.ts +0 -54
- package/dist/plugins/jsx/LexicalJsxVisitor.d.ts +0 -4
- package/dist/plugins/jsx/MdastMdxJsEsmVisitor.d.ts +0 -3
- package/dist/plugins/jsx/MdastMdxJsxElementVisitor.d.ts +0 -3
- package/dist/plugins/jsx/index.d.ts +0 -779
- package/dist/plugins/link/AutoLinkPlugin.d.ts +0 -9
- package/dist/plugins/link/LexicalLinkVisitor.d.ts +0 -4
- package/dist/plugins/link/MdastLinkVisitor.d.ts +0 -3
- package/dist/plugins/link/index.d.ts +0 -101
- package/dist/plugins/link-dialog/LinkDialog.d.ts +0 -16
- package/dist/plugins/link-dialog/index.d.ts +0 -670
- package/dist/plugins/lists/LexicalListItemVisitor.d.ts +0 -4
- package/dist/plugins/lists/LexicalListVisitor.d.ts +0 -4
- package/dist/plugins/lists/MdastListItemVisitor.d.ts +0 -3
- package/dist/plugins/lists/MdastListVisitor.d.ts +0 -3
- package/dist/plugins/lists/index.d.ts +0 -703
- package/dist/plugins/markdown-shortcut/index.d.ts +0 -80
- package/dist/plugins/quote/LexicalQuoteVisitor.d.ts +0 -4
- package/dist/plugins/quote/MdastBlockQuoteVisitor.d.ts +0 -3
- package/dist/plugins/quote/index.d.ts +0 -480
- package/dist/plugins/sandpack/SandpackEditor.d.ts +0 -7
- package/dist/plugins/sandpack/index.d.ts +0 -1077
- package/dist/plugins/sandpack/useCodeMirrorRef.d.ts +0 -4
- package/dist/plugins/table/LexicalTableVisitor.d.ts +0 -4
- package/dist/plugins/table/MdastTableVisitor.d.ts +0 -3
- package/dist/plugins/table/TableEditor.d.ts +0 -21
- package/dist/plugins/table/TableNode.d.ts +0 -52
- package/dist/plugins/table/index.d.ts +0 -704
- package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.d.ts +0 -4
- package/dist/plugins/thematic-break/MdastThematicBreakVisitor.d.ts +0 -3
- package/dist/plugins/thematic-break/index.d.ts +0 -693
- package/dist/plugins/toolbar/components/BlockTypeSelect.d.ts +0 -6
- package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.d.ts +0 -5
- package/dist/plugins/toolbar/components/ChangeAdmonitionType.d.ts +0 -6
- package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.d.ts +0 -7
- package/dist/plugins/toolbar/components/CodeToggle.d.ts +0 -6
- package/dist/plugins/toolbar/components/CreateLink.d.ts +0 -6
- package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.d.ts +0 -18
- package/dist/plugins/toolbar/components/InsertAdmonition.d.ts +0 -6
- package/dist/plugins/toolbar/components/InsertCodeBlock.d.ts +0 -7
- package/dist/plugins/toolbar/components/InsertFrontmatter.d.ts +0 -6
- package/dist/plugins/toolbar/components/InsertImage.d.ts +0 -6
- package/dist/plugins/toolbar/components/InsertSandpack.d.ts +0 -6
- package/dist/plugins/toolbar/components/InsertTable.d.ts +0 -6
- package/dist/plugins/toolbar/components/InsertThematicBreak.d.ts +0 -6
- package/dist/plugins/toolbar/components/KitchenSinkToolbar.d.ts +0 -7
- package/dist/plugins/toolbar/components/ListsToggle.d.ts +0 -7
- package/dist/plugins/toolbar/components/ShowSandpackInfo.d.ts +0 -7
- package/dist/plugins/toolbar/components/UndoRedo.d.ts +0 -5
- package/dist/plugins/toolbar/index.d.ts +0 -564
- package/dist/plugins/toolbar/primitives/DialogButton.d.ts +0 -40
- package/dist/plugins/toolbar/primitives/TooltipWrap.d.ts +0 -8
- package/dist/plugins/toolbar/primitives/select.d.ts +0 -50
- package/dist/plugins/toolbar/primitives/toolbar.d.ts +0 -163
- package/dist/styles/lexicalTheme.d.ts +0 -2
- package/dist/utils/detectMac.d.ts +0 -3
- package/dist/utils/fp.d.ts +0 -47
- package/dist/utils/isPartOftheEditorUI.d.ts +0 -1
- package/dist/utils/lexicalHelpers.d.ts +0 -11
- package/dist/utils/makeHslTransparent.d.ts +0 -1
- package/dist/utils/mergeStyleAttributes.d.ts +0 -1
- package/dist/utils/uuid4.d.ts +0 -1
- package/dist/utils/voidEmitter.d.ts +0 -14
- package/dist/utils/whitespaceConversion.d.ts +0 -2
- package/dist/utils/whitespaceConversion.js +0 -9
package/dist/gurx/realm.js
DELETED
|
@@ -1,489 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => {
|
|
4
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
return value;
|
|
6
|
-
};
|
|
7
|
-
import { tap } from "../utils/fp.js";
|
|
8
|
-
import { uuidv4 } from "../utils/uuid4.js";
|
|
9
|
-
function defaultComparator(current, next) {
|
|
10
|
-
return current === next;
|
|
11
|
-
}
|
|
12
|
-
class SetMap {
|
|
13
|
-
constructor() {
|
|
14
|
-
__publicField(this, "map", /* @__PURE__ */ new Map());
|
|
15
|
-
}
|
|
16
|
-
getOrCreate(key) {
|
|
17
|
-
let record = this.map.get(key);
|
|
18
|
-
if (!record) {
|
|
19
|
-
record = /* @__PURE__ */ new Set();
|
|
20
|
-
this.map.set(key, record);
|
|
21
|
-
}
|
|
22
|
-
return record;
|
|
23
|
-
}
|
|
24
|
-
get(key) {
|
|
25
|
-
return this.map.get(key);
|
|
26
|
-
}
|
|
27
|
-
use(key, cb) {
|
|
28
|
-
const set = this.get(key);
|
|
29
|
-
if (set !== void 0) {
|
|
30
|
-
cb(set);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
delete(key) {
|
|
34
|
-
return this.map.delete(key);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
class RefCount {
|
|
38
|
-
constructor(map = /* @__PURE__ */ new Map()) {
|
|
39
|
-
__publicField(this, "map");
|
|
40
|
-
this.map = map;
|
|
41
|
-
}
|
|
42
|
-
clone() {
|
|
43
|
-
return new RefCount(new Map(this.map));
|
|
44
|
-
}
|
|
45
|
-
increment(key) {
|
|
46
|
-
const counter = this.map.get(key) ?? 0;
|
|
47
|
-
this.map.set(key, counter + 1);
|
|
48
|
-
}
|
|
49
|
-
decrement(key, ifZero) {
|
|
50
|
-
let counter = this.map.get(key);
|
|
51
|
-
if (counter !== void 0) {
|
|
52
|
-
counter -= 1;
|
|
53
|
-
this.map.set(key, counter);
|
|
54
|
-
if (counter === 0) {
|
|
55
|
-
ifZero();
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
const NO_VALUE = Symbol("NO_VALUE");
|
|
61
|
-
function realm() {
|
|
62
|
-
const subscriptions = new SetMap();
|
|
63
|
-
const singletonSubscriptions = /* @__PURE__ */ new Map();
|
|
64
|
-
const graph = new SetMap();
|
|
65
|
-
const state = /* @__PURE__ */ new Map();
|
|
66
|
-
const distinctNodes = /* @__PURE__ */ new Map();
|
|
67
|
-
const labels = {};
|
|
68
|
-
function node(value = NO_VALUE, distinct = false) {
|
|
69
|
-
const key = uuidv4();
|
|
70
|
-
if (value !== NO_VALUE) {
|
|
71
|
-
state.set(key, value);
|
|
72
|
-
}
|
|
73
|
-
if (distinct !== false) {
|
|
74
|
-
distinctNodes.set(key, distinct === true ? defaultComparator : distinct);
|
|
75
|
-
}
|
|
76
|
-
return { key, toString: () => key };
|
|
77
|
-
}
|
|
78
|
-
function subSingle({ key }, subscription) {
|
|
79
|
-
const nodeSubscriptions = subscriptions.getOrCreate(key);
|
|
80
|
-
nodeSubscriptions.add(subscription);
|
|
81
|
-
return () => nodeSubscriptions.delete(subscription);
|
|
82
|
-
}
|
|
83
|
-
function singletonSub({ key }, subscription) {
|
|
84
|
-
if (!subscription) {
|
|
85
|
-
singletonSubscriptions.delete(key);
|
|
86
|
-
} else {
|
|
87
|
-
singletonSubscriptions.set(key, subscription);
|
|
88
|
-
}
|
|
89
|
-
return () => singletonSubscriptions.delete(key);
|
|
90
|
-
}
|
|
91
|
-
function singletonSubKey(key, subscription) {
|
|
92
|
-
return singletonSub(labels[key], subscription);
|
|
93
|
-
}
|
|
94
|
-
function resetSingletonSubs() {
|
|
95
|
-
singletonSubscriptions.clear();
|
|
96
|
-
}
|
|
97
|
-
function subMultiple(sources, cb) {
|
|
98
|
-
const sink = node();
|
|
99
|
-
connect({
|
|
100
|
-
map: (done) => (...args) => {
|
|
101
|
-
done(args);
|
|
102
|
-
},
|
|
103
|
-
sink,
|
|
104
|
-
sources
|
|
105
|
-
});
|
|
106
|
-
return subSingle(sink, cb);
|
|
107
|
-
}
|
|
108
|
-
function sub(...args) {
|
|
109
|
-
const [subscription] = args.slice(-1);
|
|
110
|
-
const nodes = args.slice(0, -1);
|
|
111
|
-
if (nodes.length === 1) {
|
|
112
|
-
return subSingle(nodes[0], subscription);
|
|
113
|
-
} else {
|
|
114
|
-
return subMultiple(nodes, subscription);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
function calculateExecutionMap(keys) {
|
|
118
|
-
const participatingNodeKeys = [];
|
|
119
|
-
const visitedNodes = /* @__PURE__ */ new Set();
|
|
120
|
-
const pendingPulls = new SetMap();
|
|
121
|
-
const refCount = new RefCount();
|
|
122
|
-
const projections = new SetMap();
|
|
123
|
-
function visit(key, insertIndex = 0) {
|
|
124
|
-
refCount.increment(key);
|
|
125
|
-
if (visitedNodes.has(key)) {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
pendingPulls.use(key, (pulls) => {
|
|
129
|
-
insertIndex = Math.max(...Array.from(pulls).map((key2) => participatingNodeKeys.indexOf(key2))) + 1;
|
|
130
|
-
});
|
|
131
|
-
graph.use(key, (sinkProjections) => {
|
|
132
|
-
sinkProjections.forEach((projection) => {
|
|
133
|
-
if (projection.sources.has(key)) {
|
|
134
|
-
projections.getOrCreate(projection.sink).add(projection);
|
|
135
|
-
visit(projection.sink, insertIndex);
|
|
136
|
-
} else {
|
|
137
|
-
pendingPulls.getOrCreate(projection.sink).add(key);
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
visitedNodes.add(key);
|
|
142
|
-
participatingNodeKeys.splice(insertIndex, 0, key);
|
|
143
|
-
}
|
|
144
|
-
keys.forEach((key) => visit(key));
|
|
145
|
-
return { participatingNodeKeys, pendingPulls, projections, refCount };
|
|
146
|
-
}
|
|
147
|
-
const executionMaps = /* @__PURE__ */ new Map();
|
|
148
|
-
function pubIn(values) {
|
|
149
|
-
var _a;
|
|
150
|
-
const keys = Object.keys(values);
|
|
151
|
-
const executionMapKey = keys.join(",");
|
|
152
|
-
if (!executionMaps.has(executionMapKey)) {
|
|
153
|
-
executionMaps.set(executionMapKey, calculateExecutionMap(keys));
|
|
154
|
-
}
|
|
155
|
-
const map2 = executionMaps.get(executionMapKey);
|
|
156
|
-
const refCount = map2.refCount.clone();
|
|
157
|
-
const participatingNodeKeys = map2.participatingNodeKeys.slice();
|
|
158
|
-
const transientState = new Map(state);
|
|
159
|
-
function nodeWillNotEmit(key) {
|
|
160
|
-
graph.use(key, (projections) => {
|
|
161
|
-
projections.forEach(({ sources, sink }) => {
|
|
162
|
-
if (sources.has(key)) {
|
|
163
|
-
refCount.decrement(sink, () => {
|
|
164
|
-
participatingNodeKeys.splice(participatingNodeKeys.indexOf(sink), 1);
|
|
165
|
-
nodeWillNotEmit(sink);
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
let nodeKey;
|
|
172
|
-
while (nodeKey = participatingNodeKeys.shift()) {
|
|
173
|
-
let resolved = false;
|
|
174
|
-
const done = (value) => {
|
|
175
|
-
if (distinctNodes.has(nodeKey) && distinctNodes.get(nodeKey)(state.get(nodeKey), value)) {
|
|
176
|
-
resolved = false;
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
resolved = true;
|
|
180
|
-
transientState.set(nodeKey, value);
|
|
181
|
-
if (state.has(nodeKey)) {
|
|
182
|
-
state.set(nodeKey, value);
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
if (Object.prototype.hasOwnProperty.call(values, nodeKey)) {
|
|
186
|
-
done(values[nodeKey]);
|
|
187
|
-
} else {
|
|
188
|
-
map2.projections.use(nodeKey, (nodeProjections) => {
|
|
189
|
-
nodeProjections.forEach((projection) => {
|
|
190
|
-
const args = [...Array.from(projection.sources), ...Array.from(projection.pulls)].map((id) => transientState.get(id));
|
|
191
|
-
projection.map(done)(...args);
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
if (resolved) {
|
|
196
|
-
const value = transientState.get(nodeKey);
|
|
197
|
-
subscriptions.use(nodeKey, (nodeSubscriptions) => {
|
|
198
|
-
nodeSubscriptions.forEach((subscription) => subscription(value));
|
|
199
|
-
});
|
|
200
|
-
(_a = singletonSubscriptions.get(nodeKey)) == null ? void 0 : _a(value);
|
|
201
|
-
} else {
|
|
202
|
-
nodeWillNotEmit(nodeKey);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
function nodesToKeySet(nodes) {
|
|
207
|
-
return new Set(nodes.map((s) => s.key));
|
|
208
|
-
}
|
|
209
|
-
function connect({ sources, pulls = [], map: map2, sink: { key: sink } }) {
|
|
210
|
-
const dependency = {
|
|
211
|
-
map: map2,
|
|
212
|
-
pulls: nodesToKeySet(pulls),
|
|
213
|
-
sink,
|
|
214
|
-
sources: nodesToKeySet(sources)
|
|
215
|
-
};
|
|
216
|
-
[...sources, ...pulls].forEach(({ key: sourceKey }) => {
|
|
217
|
-
graph.getOrCreate(sourceKey).add(dependency);
|
|
218
|
-
});
|
|
219
|
-
executionMaps.clear();
|
|
220
|
-
}
|
|
221
|
-
function pub(...args) {
|
|
222
|
-
const map2 = {};
|
|
223
|
-
for (let index = 0; index < args.length; index += 2) {
|
|
224
|
-
const node2 = args[index];
|
|
225
|
-
map2[node2.key] = args[index + 1];
|
|
226
|
-
}
|
|
227
|
-
pubIn(map2);
|
|
228
|
-
}
|
|
229
|
-
function label(newLabels) {
|
|
230
|
-
Object.assign(labels, newLabels);
|
|
231
|
-
}
|
|
232
|
-
function pipe(source, ...operators) {
|
|
233
|
-
for (const operator of operators) {
|
|
234
|
-
source = operator(source);
|
|
235
|
-
}
|
|
236
|
-
return source;
|
|
237
|
-
}
|
|
238
|
-
function spread(source, initialValues) {
|
|
239
|
-
return initialValues.map((initialValue, index) => {
|
|
240
|
-
return tap(node(initialValue, true), (sink) => {
|
|
241
|
-
connect({
|
|
242
|
-
map: (done) => (sourceValue) => {
|
|
243
|
-
done(sourceValue[index]);
|
|
244
|
-
},
|
|
245
|
-
sink,
|
|
246
|
-
sources: [source]
|
|
247
|
-
});
|
|
248
|
-
});
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
function link(source, sink) {
|
|
252
|
-
connect({ map: (done) => (value) => done(value), sink, sources: [source] });
|
|
253
|
-
}
|
|
254
|
-
function derive(source, initial) {
|
|
255
|
-
return tap(node(initial, true), (sink) => {
|
|
256
|
-
connect({ map: (done) => (value) => done(value), sink, sources: [source] });
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
function map(mapFunction) {
|
|
260
|
-
return (source) => {
|
|
261
|
-
const sink = node();
|
|
262
|
-
connect({
|
|
263
|
-
map: (done) => (value) => {
|
|
264
|
-
done(mapFunction(value));
|
|
265
|
-
},
|
|
266
|
-
sink,
|
|
267
|
-
sources: [source]
|
|
268
|
-
});
|
|
269
|
-
return sink;
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
function mapTo(value) {
|
|
273
|
-
return (source) => {
|
|
274
|
-
const sink = node();
|
|
275
|
-
connect({ map: (done) => () => done(value), sink, sources: [source] });
|
|
276
|
-
return sink;
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
function filter(predicate) {
|
|
280
|
-
return (source) => {
|
|
281
|
-
const sink = node();
|
|
282
|
-
connect({ map: (done) => (value) => predicate(value) && done(value), sink, sources: [source] });
|
|
283
|
-
return sink;
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
function once() {
|
|
287
|
-
return (source) => {
|
|
288
|
-
const sink = node();
|
|
289
|
-
let passed = false;
|
|
290
|
-
connect({
|
|
291
|
-
map: (done) => (value) => {
|
|
292
|
-
if (!passed) {
|
|
293
|
-
passed = true;
|
|
294
|
-
done(value);
|
|
295
|
-
}
|
|
296
|
-
},
|
|
297
|
-
sink,
|
|
298
|
-
sources: [source]
|
|
299
|
-
});
|
|
300
|
-
return sink;
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
function scan(accumulator, seed) {
|
|
304
|
-
return (source) => {
|
|
305
|
-
const sink = node();
|
|
306
|
-
connect({ map: (done) => (value) => done(seed = accumulator(seed, value)), sink, sources: [source] });
|
|
307
|
-
return sink;
|
|
308
|
-
};
|
|
309
|
-
}
|
|
310
|
-
function throttleTime(delay) {
|
|
311
|
-
return (source) => {
|
|
312
|
-
const sink = node();
|
|
313
|
-
let currentValue;
|
|
314
|
-
let timeout;
|
|
315
|
-
sub(source, (value) => {
|
|
316
|
-
currentValue = value;
|
|
317
|
-
if (timeout) {
|
|
318
|
-
return;
|
|
319
|
-
}
|
|
320
|
-
timeout = setTimeout(() => {
|
|
321
|
-
timeout = void 0;
|
|
322
|
-
pub(sink, currentValue);
|
|
323
|
-
}, delay);
|
|
324
|
-
});
|
|
325
|
-
return sink;
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
function delayWithMicrotask() {
|
|
329
|
-
return (source) => {
|
|
330
|
-
const sink = node();
|
|
331
|
-
sub(source, (value) => queueMicrotask(() => pub(sink, value)));
|
|
332
|
-
return sink;
|
|
333
|
-
};
|
|
334
|
-
}
|
|
335
|
-
function debounceTime(delay) {
|
|
336
|
-
return (source) => {
|
|
337
|
-
const sink = node();
|
|
338
|
-
let currentValue;
|
|
339
|
-
let timeout;
|
|
340
|
-
sub(source, (value) => {
|
|
341
|
-
currentValue = value;
|
|
342
|
-
if (timeout) {
|
|
343
|
-
clearTimeout(timeout);
|
|
344
|
-
}
|
|
345
|
-
timeout = setTimeout(() => {
|
|
346
|
-
pub(sink, currentValue);
|
|
347
|
-
}, delay);
|
|
348
|
-
});
|
|
349
|
-
return sink;
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
function onNext(bufNode) {
|
|
353
|
-
return (source) => {
|
|
354
|
-
const sink = node();
|
|
355
|
-
let pendingValue = NO_VALUE;
|
|
356
|
-
sub(source, (value) => pendingValue = value);
|
|
357
|
-
connect({
|
|
358
|
-
map: (done) => (value) => {
|
|
359
|
-
if (pendingValue !== NO_VALUE) {
|
|
360
|
-
done([pendingValue, value]);
|
|
361
|
-
pendingValue = NO_VALUE;
|
|
362
|
-
}
|
|
363
|
-
},
|
|
364
|
-
sink,
|
|
365
|
-
sources: [bufNode]
|
|
366
|
-
});
|
|
367
|
-
return sink;
|
|
368
|
-
};
|
|
369
|
-
}
|
|
370
|
-
function passOnlyAfterNodeHasEmittedBefore(starterNode, durationNode) {
|
|
371
|
-
return (source) => {
|
|
372
|
-
const sink = node();
|
|
373
|
-
let startTime = 0;
|
|
374
|
-
sub(starterNode, () => startTime = Date.now());
|
|
375
|
-
connect({
|
|
376
|
-
map: (done) => (value) => {
|
|
377
|
-
if (Date.now() < startTime + state.get(durationNode.key)) {
|
|
378
|
-
done(value);
|
|
379
|
-
}
|
|
380
|
-
},
|
|
381
|
-
sink,
|
|
382
|
-
sources: [source]
|
|
383
|
-
});
|
|
384
|
-
return sink;
|
|
385
|
-
};
|
|
386
|
-
}
|
|
387
|
-
function withLatestFrom(...nodes) {
|
|
388
|
-
return (source) => {
|
|
389
|
-
const sink = node();
|
|
390
|
-
connect({
|
|
391
|
-
map: (done) => (...args) => done(args),
|
|
392
|
-
pulls: nodes,
|
|
393
|
-
sink,
|
|
394
|
-
sources: [source]
|
|
395
|
-
});
|
|
396
|
-
return sink;
|
|
397
|
-
};
|
|
398
|
-
}
|
|
399
|
-
function combine(...nodes) {
|
|
400
|
-
const sink = node();
|
|
401
|
-
connect({
|
|
402
|
-
map: (done) => (...args) => done(args),
|
|
403
|
-
sink,
|
|
404
|
-
sources: nodes
|
|
405
|
-
});
|
|
406
|
-
return sink;
|
|
407
|
-
}
|
|
408
|
-
function subKey(key, subscription) {
|
|
409
|
-
return sub(labels[key], subscription);
|
|
410
|
-
}
|
|
411
|
-
function subKeys(keys, subscription) {
|
|
412
|
-
const nodes = keys.map((key) => labels[key]);
|
|
413
|
-
return sub(...nodes.concat(subscription));
|
|
414
|
-
}
|
|
415
|
-
function pubKey(key, value) {
|
|
416
|
-
pubKeys({ [key]: value });
|
|
417
|
-
}
|
|
418
|
-
function pubKeys(values) {
|
|
419
|
-
const valuesWithInternalKeys = Object.entries(values).reduce(
|
|
420
|
-
(acc, [key, value]) => tap(acc, (acc2) => {
|
|
421
|
-
const label2 = labels[key];
|
|
422
|
-
if (!label2) {
|
|
423
|
-
throw new Error(`No label for key ${key}. Do you miss a plugin?`);
|
|
424
|
-
}
|
|
425
|
-
acc2[label2.key] = value;
|
|
426
|
-
return value;
|
|
427
|
-
}),
|
|
428
|
-
{}
|
|
429
|
-
);
|
|
430
|
-
pubIn(valuesWithInternalKeys);
|
|
431
|
-
}
|
|
432
|
-
function getKeyValue(key) {
|
|
433
|
-
return state.get(labels[key].key);
|
|
434
|
-
}
|
|
435
|
-
function getValue(node2) {
|
|
436
|
-
return state.get(node2.key);
|
|
437
|
-
}
|
|
438
|
-
function getKeyValues(keys) {
|
|
439
|
-
return keys.map((key) => {
|
|
440
|
-
const label2 = labels[key];
|
|
441
|
-
if (!label2) {
|
|
442
|
-
throw new Error(`No label for key ${key}. Do you miss a plugin?`);
|
|
443
|
-
}
|
|
444
|
-
return state.get(label2.key);
|
|
445
|
-
});
|
|
446
|
-
}
|
|
447
|
-
return {
|
|
448
|
-
combine,
|
|
449
|
-
connect,
|
|
450
|
-
derive,
|
|
451
|
-
getKeyValue,
|
|
452
|
-
getValue,
|
|
453
|
-
getKeyValues,
|
|
454
|
-
label,
|
|
455
|
-
labels,
|
|
456
|
-
link,
|
|
457
|
-
node,
|
|
458
|
-
o: {
|
|
459
|
-
delayWithMicrotask,
|
|
460
|
-
debounceTime,
|
|
461
|
-
filter,
|
|
462
|
-
map,
|
|
463
|
-
mapTo,
|
|
464
|
-
onNext,
|
|
465
|
-
scan,
|
|
466
|
-
throttleTime,
|
|
467
|
-
withLatestFrom,
|
|
468
|
-
once,
|
|
469
|
-
passOnlyAfterNodeHasEmittedBefore
|
|
470
|
-
},
|
|
471
|
-
pipe,
|
|
472
|
-
pub,
|
|
473
|
-
pubIn,
|
|
474
|
-
pubKey,
|
|
475
|
-
pubKeys,
|
|
476
|
-
resetSingletonSubs,
|
|
477
|
-
singletonSub,
|
|
478
|
-
singletonSubKey,
|
|
479
|
-
spread,
|
|
480
|
-
sub,
|
|
481
|
-
subKey,
|
|
482
|
-
subKeys
|
|
483
|
-
};
|
|
484
|
-
}
|
|
485
|
-
export {
|
|
486
|
-
RefCount,
|
|
487
|
-
defaultComparator,
|
|
488
|
-
realm
|
|
489
|
-
};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { Realm, RealmNode, Subscription, UnsubscribeHandle } from './realm';
|
|
2
|
-
/**
|
|
3
|
-
* The system interface is the runtime representation of a state management module, a record of nodes.
|
|
4
|
-
*/
|
|
5
|
-
export interface System {
|
|
6
|
-
[key: string]: RealmNode<any>;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* a SystemSpec is the result from a [[system]] call. To obtain the [[system]], pass the spec to [[init]].
|
|
10
|
-
* @typeParam Dependencies - The dependencies of the system.
|
|
11
|
-
* @typeParam Constructor - The system constructor.
|
|
12
|
-
*/
|
|
13
|
-
export interface SystemSpec<Dependencies extends AnySystemSpecs, /** @internal */ Constructor extends SystemConstructor<Dependencies>> {
|
|
14
|
-
id: string;
|
|
15
|
-
constructor: Constructor;
|
|
16
|
-
dependencies: Dependencies;
|
|
17
|
-
}
|
|
18
|
-
/** @internal **/
|
|
19
|
-
export interface AnySystemSpec extends SystemSpec<AnySystemSpecs, any> {
|
|
20
|
-
id: string;
|
|
21
|
-
}
|
|
22
|
-
/** @internal **/
|
|
23
|
-
export type AnySystemSpecs = Array<AnySystemSpec>;
|
|
24
|
-
/** @internal **/
|
|
25
|
-
export type SystemOfSpec<Spec extends AnySystemSpec> = ReturnType<Spec['constructor']>;
|
|
26
|
-
/** @internal **/
|
|
27
|
-
export type SSR<Spec extends AnySystemSpec> = SystemOfSpec<Spec>;
|
|
28
|
-
/** @internal **/
|
|
29
|
-
export type SystemsFromSpecs<ST extends AnySystemSpecs> = ST extends unknown[] ? SystemsFromSpecsRec<ST, []> : never;
|
|
30
|
-
type SystemsFromSpecsRec<ST extends unknown[], Acc extends unknown[]> = ST extends [infer Head, ...infer Tail] ? SystemsFromSpecsRec<Tail, [...Acc, Head extends AnySystemSpec ? SystemOfSpec<Head> : never]> : Acc;
|
|
31
|
-
/**
|
|
32
|
-
* The system constructor is a function which initializes and connects nodes and returns them as a [[system]].
|
|
33
|
-
* If the [[system]] call specifies system dependencies, the constructor receives the dependencies as an array argument.
|
|
34
|
-
*/
|
|
35
|
-
export interface SystemConstructor<D extends AnySystemSpecs> {
|
|
36
|
-
(r: Realm, dependencies: SystemsFromSpecs<D>): System;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Declare a new state management module (system). The constructor receives the realm and the dependencies as arguments.
|
|
40
|
-
* @param constructor - The system constructor.
|
|
41
|
-
* @param dependencies - The dependencies of the system - other systems.
|
|
42
|
-
*/
|
|
43
|
-
export declare function system<Dependencies extends LongTuple<AnySystemSpec>, Constructor extends SystemConstructor<Dependencies>>(constructor: Constructor, dependencies?: Dependencies): SystemSpec<Dependencies, Constructor>;
|
|
44
|
-
type SystemKey<S extends System> = Extract<keyof S, string>;
|
|
45
|
-
/** @internal */
|
|
46
|
-
export type ValuesForKeys<S extends System, K extends SystemKey<S>[]> = K extends unknown[] ? ValuesForKeysRec<S, K, []> : never;
|
|
47
|
-
type ValuesForKeysRec<S extends Record<any, RealmNode>, K extends unknown[], Acc extends unknown[]> = K extends [infer Head, ...infer Tail] ? ValuesForKeysRec<S, Tail, [...Acc, S[Head] extends RealmNode<infer R> ? R : never]> : Acc;
|
|
48
|
-
/** @internal **/
|
|
49
|
-
export type SystemOfSpecs<Specs extends AnySystemSpec[]> = Specs extends unknown[] ? SystemOfSpecsRec<Specs, {}> : Specs;
|
|
50
|
-
type SystemOfSpecsRec<Specs extends unknown[], Acc extends {}> = Specs extends [infer Head, ...infer Tail] ? SystemOfSpecsRec<Tail, Head extends AnySystemSpec ? Acc & SystemOfSpec<Head> : never> : Acc;
|
|
51
|
-
/** @internal */
|
|
52
|
-
export type LongTuple<K> = [] | [K] | [K, K] | [K, K, K] | [K, K, K, K] | [K, K, K, K, K] | [K, K, K, K, K, K] | [K, K, K, K, K, K, K] | [K, K, K, K, K, K, K, K] | [K, K, K, K, K, K, K, K, K] | [K, K, K, K, K, K, K, K, K, K] | [K, K, K, K, K, K, K, K, K, K, K] | [K, K, K, K, K, K, K, K, K, K, K, K] | [K, K, K, K, K, K, K, K, K, K, K, K, K] | [K, K, K, K, K, K, K, K, K, K, K, K, K, K] | [K, K, K, K, K, K, K, K, K, K, K, K, K, K, K] | [K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K] | [K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K] | [K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K] | [K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K] | [K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K] | [K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K] | [K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K] | [K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K];
|
|
53
|
-
/** @internal */
|
|
54
|
-
export type SystemKeys<S extends System, K extends Extract<keyof S, string> = Extract<keyof S, string>> = LongTuple<K>;
|
|
55
|
-
/** @internal */
|
|
56
|
-
export type ValueForKey<S extends System, K extends keyof S> = S[K] extends RealmNode<infer V> ? V : never;
|
|
57
|
-
/** @internal */
|
|
58
|
-
export type SystemDict<S extends System> = {
|
|
59
|
-
[K in keyof S]?: ValueForKey<S, K>;
|
|
60
|
-
};
|
|
61
|
-
/** @internal */
|
|
62
|
-
export type SystemKeysArray<S extends System> = Array<keyof S>;
|
|
63
|
-
/** @internal */
|
|
64
|
-
export interface TypedRealm<S extends System> extends Pick<Realm, 'sub' | 'pub' | 'spread' | 'derive' | 'singletonSubKey' | 'resetSingletonSubs'> {
|
|
65
|
-
getKeyValues<K extends SystemKeys<S>>(keys: K): ValuesForKeys<S, K>;
|
|
66
|
-
getKeyValue<K extends keyof S>(key: K): ValueForKey<S, K>;
|
|
67
|
-
labels: S;
|
|
68
|
-
pubKey<K extends keyof S>(key: K, value: ValueForKey<S, K>): void;
|
|
69
|
-
pubKeys: (values: SystemDict<S>) => void;
|
|
70
|
-
subKey<K extends keyof S>(key: K, subscription: Subscription<ValueForKey<S, K>>): UnsubscribeHandle;
|
|
71
|
-
subKeys<K extends SystemKeys<S>>(keys: K, subscription: Subscription<ValuesForKeys<S, K>>): UnsubscribeHandle;
|
|
72
|
-
}
|
|
73
|
-
/** @internal */
|
|
74
|
-
export declare function realmFactory<Specs extends LongTuple<AnySystemSpec>>(...specs: Specs): TypedRealm<SystemOfSpecs<Specs>>;
|
|
75
|
-
/** @internal */
|
|
76
|
-
export type RealmFactory<Sys extends System> = () => TypedRealm<Sys>;
|
|
77
|
-
/** @internal */
|
|
78
|
-
export declare function getRealmFactory<Specs extends LongTuple<AnySystemSpec>>(...specs: Specs): () => TypedRealm<SystemOfSpecs<[...Specs]>>;
|
|
79
|
-
export {};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { uuidv4 } from "../utils/uuid4.js";
|
|
2
|
-
import { realm } from "./realm.js";
|
|
3
|
-
function system(constructor, dependencies = []) {
|
|
4
|
-
return {
|
|
5
|
-
constructor,
|
|
6
|
-
dependencies,
|
|
7
|
-
id: uuidv4()
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
function realmFactory(...specs) {
|
|
11
|
-
const singletons = /* @__PURE__ */ new Map();
|
|
12
|
-
const r = realm();
|
|
13
|
-
const _init = ({ id, constructor, dependencies }) => {
|
|
14
|
-
if (singletons.has(id)) {
|
|
15
|
-
return singletons.get(id);
|
|
16
|
-
}
|
|
17
|
-
const system2 = constructor(r, dependencies.map((t) => _init(specs.find((spec) => spec.id === t.id))));
|
|
18
|
-
r.label(system2);
|
|
19
|
-
singletons.set(id, system2);
|
|
20
|
-
return system2;
|
|
21
|
-
};
|
|
22
|
-
specs.forEach(_init);
|
|
23
|
-
return r;
|
|
24
|
-
}
|
|
25
|
-
function getRealmFactory(...specs) {
|
|
26
|
-
return () => realmFactory(...specs);
|
|
27
|
-
}
|
|
28
|
-
export {
|
|
29
|
-
getRealmFactory,
|
|
30
|
-
realmFactory,
|
|
31
|
-
system
|
|
32
|
-
};
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { LexicalNode, RootNode as LexicalRootNode } from 'lexical';
|
|
2
|
-
import * as Mdast from 'mdast';
|
|
3
|
-
import { type Options } from 'mdast-util-from-markdown';
|
|
4
|
-
import { ParseOptions } from 'micromark-util-types';
|
|
5
|
-
import { IS_BOLD, IS_CODE, IS_ITALIC, IS_UNDERLINE } from './FormatConstants';
|
|
6
|
-
/** @internal */
|
|
7
|
-
export type MdastExtensions = Options['mdastExtensions'];
|
|
8
|
-
/**
|
|
9
|
-
* A set of actions that can be used to modify the lexical tree while visiting the mdast tree.
|
|
10
|
-
*/
|
|
11
|
-
export interface MdastVisitActions {
|
|
12
|
-
/**
|
|
13
|
-
* Iterate the children of the node with the lexical node as the parent.
|
|
14
|
-
*/
|
|
15
|
-
visitChildren(node: Mdast.Parent, lexicalParent: LexicalNode): void;
|
|
16
|
-
/**
|
|
17
|
-
* Add the given node to the lexical tree, and iterate the current mdast node's children with the newly created lexical node as a parent.
|
|
18
|
-
*/
|
|
19
|
-
addAndStepInto(lexicalNode: LexicalNode): void;
|
|
20
|
-
/**
|
|
21
|
-
* Adds formatting as a context for the current node and its children.
|
|
22
|
-
* This is necessary due to mdast treating formatting as a node, while lexical considering it an attribute of a node.
|
|
23
|
-
*/
|
|
24
|
-
addFormatting(format: typeof IS_BOLD | typeof IS_ITALIC | typeof IS_UNDERLINE | typeof IS_CODE, node?: Mdast.Content): void;
|
|
25
|
-
/**
|
|
26
|
-
* Adds formatting as a context for the current node and its children.
|
|
27
|
-
* This is necessary due to mdast treating formatting as a node, while lexical considering it an attribute of a node.
|
|
28
|
-
*/
|
|
29
|
-
removeFormatting(format: typeof IS_BOLD | typeof IS_ITALIC | typeof IS_UNDERLINE | typeof IS_CODE, node?: Mdast.Content): void;
|
|
30
|
-
/**
|
|
31
|
-
* Access the current formatting context.
|
|
32
|
-
*/
|
|
33
|
-
getParentFormatting(): number;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Parameters passed to the {@link MdastImportVisitor.visitNode} function.
|
|
37
|
-
* @param mdastNode - The node that is currently being visited.
|
|
38
|
-
* @param lexicalParent - The parent lexical node to which the results of the processing should be added.
|
|
39
|
-
* @param actions - A set of convenience utilities that can be used to add nodes to the lexical tree.
|
|
40
|
-
* @typeParam T - The type of the mdast node that is being visited.
|
|
41
|
-
*/
|
|
42
|
-
export interface MdastVisitParams<T extends Mdast.Content> {
|
|
43
|
-
mdastNode: T;
|
|
44
|
-
mdastParent: Mdast.Parent | null;
|
|
45
|
-
lexicalParent: LexicalNode;
|
|
46
|
-
actions: MdastVisitActions;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Implement this interface to convert certian mdast nodes into lexical nodes.
|
|
50
|
-
* @typeParam UN - The type of the mdast node that is being visited.
|
|
51
|
-
*/
|
|
52
|
-
export interface MdastImportVisitor<UN extends Mdast.Content> {
|
|
53
|
-
/**
|
|
54
|
-
* The test function that determines if this visitor should be used for the given node.
|
|
55
|
-
* As a convenience, you can also pass a string here, which will be compared to the node's type.
|
|
56
|
-
*/
|
|
57
|
-
testNode: ((mdastNode: Mdast.Content | Mdast.Root) => boolean) | string;
|
|
58
|
-
/**
|
|
59
|
-
* The function that is called when the node is visited. See {@link MdastVisitParams} for details.
|
|
60
|
-
*/
|
|
61
|
-
visitNode(params: MdastVisitParams<UN>): void;
|
|
62
|
-
/**
|
|
63
|
-
* Default 0, optional, sets the priority of the visitor. The higher the number, the earlier it will be called.
|
|
64
|
-
*/
|
|
65
|
-
priority?: number;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* The options of the tree import utility. Not meant to be used directly.
|
|
69
|
-
* @internal
|
|
70
|
-
*/
|
|
71
|
-
export interface MdastTreeImportOptions {
|
|
72
|
-
root: LexicalRootNode;
|
|
73
|
-
visitors: MdastImportVisitor<Mdast.Content>[];
|
|
74
|
-
mdastRoot: Mdast.Root;
|
|
75
|
-
}
|
|
76
|
-
/** @internal */
|
|
77
|
-
export interface MarkdownParseOptions extends Omit<MdastTreeImportOptions, 'mdastRoot'> {
|
|
78
|
-
markdown: string;
|
|
79
|
-
syntaxExtensions: NonNullable<ParseOptions['extensions']>;
|
|
80
|
-
mdastExtensions: MdastExtensions;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* An extension for the `fromMarkdown` utility tree construction.
|
|
84
|
-
* @internal
|
|
85
|
-
*/
|
|
86
|
-
export type MdastExtension = NonNullable<MdastExtensions>[number];
|
|
87
|
-
/**
|
|
88
|
-
* An extension for the `fromMarkdown` utility markdown parse.
|
|
89
|
-
* @internal
|
|
90
|
-
*/
|
|
91
|
-
export type SyntaxExtension = MarkdownParseOptions['syntaxExtensions'][number];
|
|
92
|
-
export declare class MarkdownParseError extends Error {
|
|
93
|
-
constructor(message: string, cause: unknown);
|
|
94
|
-
}
|
|
95
|
-
export declare class UnrecognizedMarkdownConstructError extends Error {
|
|
96
|
-
constructor(message: string);
|
|
97
|
-
}
|
|
98
|
-
/** @internal */
|
|
99
|
-
export declare function importMarkdownToLexical({ root, markdown, visitors, syntaxExtensions, mdastExtensions }: MarkdownParseOptions): void;
|
|
100
|
-
/** @internal */
|
|
101
|
-
export declare function importMdastTreeToLexical({ root, mdastRoot, visitors }: MdastTreeImportOptions): void;
|