@owomark/core 0.1.6 → 0.1.7
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/README.md +30 -10
- package/dist/.build-manifest.json +130 -0
- package/dist/browser.d.ts +66 -0
- package/dist/browser.js +396 -0
- package/dist/chunk-3KTK7CSS.js +82 -0
- package/dist/chunk-5JNL3LHV.js +215 -0
- package/dist/chunk-ASRCHEFF.js +0 -0
- package/dist/chunk-BKJCBEI7.js +397 -0
- package/dist/chunk-CJSBFWKS.js +549 -0
- package/dist/chunk-GA5EFGSZ.js +5820 -0
- package/dist/chunk-OOH46GIF.js +95 -0
- package/dist/chunk-ROJILHRQ.js +192 -0
- package/dist/chunk-WFPUIPWU.js +34 -0
- package/dist/chunk-WXVKSKP3.js +191 -0
- package/dist/chunk-YZYJIXGO.js +0 -0
- package/dist/editor-core-DbPhn6aI.d.ts +249 -0
- package/dist/index.d.ts +77 -87
- package/dist/index.js +127 -248
- package/dist/internal/dom-adapter.d.ts +37 -1
- package/dist/internal/dom-adapter.js +9 -2
- package/dist/public-zMo7BR9l.d.ts +469 -0
- package/dist/registry-C849sxCo.d.ts +74 -0
- package/dist/semantic/components/index.d.ts +9 -0
- package/dist/semantic/components/index.js +11 -0
- package/dist/semantic/editor/index.d.ts +9 -0
- package/dist/semantic/editor/index.js +13 -0
- package/dist/semantic/index.d.ts +7 -0
- package/dist/semantic/index.js +106 -0
- package/dist/semantic/runtime/index.d.ts +9 -0
- package/dist/semantic/runtime/index.js +13 -0
- package/dist/semantic/shared/index.d.ts +10 -0
- package/dist/semantic/shared/index.js +17 -0
- package/dist/semantic/syntax/index.d.ts +151 -0
- package/dist/semantic/syntax/index.js +63 -0
- package/dist/types-DMqYF6Zn.d.ts +83 -0
- package/package.json +29 -1
- package/dist/chunk-6CBUAORJ.js +0 -3337
- package/dist/dom-adapter-C8wuoffZ.d.ts +0 -471
package/dist/index.js
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
DEFAULT_VIEWPORT_ANCHOR_RATIO,
|
|
3
|
+
buildProgressSegments,
|
|
4
|
+
buildScrollProjectionSnapshot,
|
|
5
|
+
projectToScrollSegments,
|
|
6
|
+
resolveScrollPosition,
|
|
7
|
+
resolveScrollTopFromPosition
|
|
8
|
+
} from "./chunk-5JNL3LHV.js";
|
|
9
|
+
import {
|
|
10
|
+
CARDS_FAMILY_CUSTOM_BLOCK_KEY,
|
|
4
11
|
NOT_HANDLED,
|
|
5
|
-
SIDE_ANNOTATION_TAIL_RE,
|
|
6
|
-
SIDE_CONTINUATION_TAIL_RE,
|
|
7
|
-
TOKEN_CLASS_EXEMPTIONS,
|
|
8
|
-
TOKEN_TO_CLASS,
|
|
9
12
|
applyMarkdownIndent,
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
buildConformanceDocument,
|
|
14
|
+
buildConformanceMdastRoot,
|
|
15
|
+
cardsFamilyContainerExtension,
|
|
16
|
+
computePreviewDirtyRange,
|
|
12
17
|
createBlockIdGenerator,
|
|
13
18
|
createCommandRegistry,
|
|
19
|
+
createDelimitedInlineExtension,
|
|
14
20
|
createOwoMarkCore,
|
|
15
|
-
|
|
16
|
-
domRangeToOffset,
|
|
17
|
-
expandDirtyRange,
|
|
18
|
-
expandWithContext,
|
|
19
|
-
fullRender,
|
|
21
|
+
deriveRenderKey,
|
|
20
22
|
getBlockAtOffset,
|
|
21
23
|
getBlockById,
|
|
22
24
|
getBlockIndexById,
|
|
@@ -26,35 +28,53 @@ import {
|
|
|
26
28
|
handleMarkdownEnter,
|
|
27
29
|
handleSmartBackspace,
|
|
28
30
|
handleSmartDelete,
|
|
31
|
+
hydrateOwoMarkDocument,
|
|
29
32
|
insertCodeFence,
|
|
30
33
|
insertImage,
|
|
31
34
|
insertLink,
|
|
32
35
|
insertMathBlock,
|
|
33
36
|
insertSideAnnotation,
|
|
34
37
|
insertTable,
|
|
35
|
-
|
|
38
|
+
isCardsFamilyAttributes,
|
|
36
39
|
isVirtualSelectionCollapsed,
|
|
37
40
|
linearToVirtual,
|
|
38
41
|
linearToVirtualPosition,
|
|
39
|
-
offsetToDomRange,
|
|
40
42
|
parseMarkdownToDocument,
|
|
41
|
-
|
|
42
|
-
readSelection,
|
|
43
|
+
projectToPreviewBlocks,
|
|
43
44
|
reconcileBlocks,
|
|
44
45
|
resetBlockIdCounter,
|
|
45
46
|
resolveBlockContextType,
|
|
46
47
|
resolveIndentSize,
|
|
47
|
-
restoreSelection,
|
|
48
48
|
serializeDocument,
|
|
49
49
|
toggleBold,
|
|
50
50
|
toggleItalic,
|
|
51
51
|
tokenizeBlock,
|
|
52
52
|
tokenizeInline,
|
|
53
|
-
updateBlockElement,
|
|
54
53
|
virtualPositionToLinear,
|
|
55
54
|
virtualPositionsEqual,
|
|
56
55
|
virtualToLinear
|
|
57
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-GA5EFGSZ.js";
|
|
57
|
+
import {
|
|
58
|
+
deriveBlockId,
|
|
59
|
+
deriveSourceKey,
|
|
60
|
+
expandDirtyRange,
|
|
61
|
+
expandWithContext
|
|
62
|
+
} from "./chunk-WFPUIPWU.js";
|
|
63
|
+
import "./chunk-YZYJIXGO.js";
|
|
64
|
+
import "./chunk-ASRCHEFF.js";
|
|
65
|
+
import {
|
|
66
|
+
getRuntimeBlockDescriptor,
|
|
67
|
+
getRuntimeBlockDescriptorByBlockType,
|
|
68
|
+
getRuntimeBlockDescriptorByPreviewKind,
|
|
69
|
+
runtimeBlockRegistry
|
|
70
|
+
} from "./chunk-ROJILHRQ.js";
|
|
71
|
+
import {
|
|
72
|
+
getSyntaxDescriptor,
|
|
73
|
+
parseInlineSideAnnotationFromText,
|
|
74
|
+
stripInlineSideAnnotationTail,
|
|
75
|
+
stripSideContinuationTail,
|
|
76
|
+
syntaxRegistry
|
|
77
|
+
} from "./chunk-BKJCBEI7.js";
|
|
58
78
|
import {
|
|
59
79
|
normalizeMarkdownPaste
|
|
60
80
|
} from "./chunk-BGXCXQZP.js";
|
|
@@ -64,6 +84,18 @@ import {
|
|
|
64
84
|
deleteWordBackward,
|
|
65
85
|
deleteWordForward
|
|
66
86
|
} from "./chunk-MPIWZLI3.js";
|
|
87
|
+
import {
|
|
88
|
+
componentRegistry,
|
|
89
|
+
getComponentDescriptor,
|
|
90
|
+
getComponentDescriptorByDirective
|
|
91
|
+
} from "./chunk-WXVKSKP3.js";
|
|
92
|
+
import {
|
|
93
|
+
editorEntryRegistry,
|
|
94
|
+
getEditorEntryDescriptor,
|
|
95
|
+
getEditorEntryDescriptorByCommandId,
|
|
96
|
+
resolveEditorEntryPresentation
|
|
97
|
+
} from "./chunk-3KTK7CSS.js";
|
|
98
|
+
import "./chunk-OOH46GIF.js";
|
|
67
99
|
|
|
68
100
|
// src/types/public.ts
|
|
69
101
|
var INLINE_TOKEN_TYPES = [
|
|
@@ -72,11 +104,15 @@ var INLINE_TOKEN_TYPES = [
|
|
|
72
104
|
"strong",
|
|
73
105
|
"emphasis-marker",
|
|
74
106
|
"emphasis",
|
|
107
|
+
"custom-inline-marker",
|
|
108
|
+
"custom-inline",
|
|
75
109
|
"code-marker",
|
|
76
110
|
"code",
|
|
77
111
|
"link-bracket",
|
|
78
112
|
"link-text",
|
|
79
113
|
"link-url",
|
|
114
|
+
"reference-bracket",
|
|
115
|
+
"reference-label",
|
|
80
116
|
"image-marker",
|
|
81
117
|
"image-alt",
|
|
82
118
|
"image-url",
|
|
@@ -98,216 +134,6 @@ var INLINE_TOKEN_TYPES = [
|
|
|
98
134
|
];
|
|
99
135
|
var CLASSLESS_INLINE_TOKEN_TYPES = ["text"];
|
|
100
136
|
|
|
101
|
-
// src/preview/block-id.ts
|
|
102
|
-
function deriveBlockId(renderKey, occurrenceIndex) {
|
|
103
|
-
return `${renderKey}#${occurrenceIndex}`;
|
|
104
|
-
}
|
|
105
|
-
function deriveSourceKey(startLine, endLine) {
|
|
106
|
-
return `L${startLine}-${endLine}`;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// src/preview/render-key.ts
|
|
110
|
-
function djb2(input) {
|
|
111
|
-
let hash = 5381;
|
|
112
|
-
for (let i = 0; i < input.length; i++) {
|
|
113
|
-
hash = (hash << 5) + hash ^ input.charCodeAt(i);
|
|
114
|
-
}
|
|
115
|
-
return (hash >>> 0).toString(36);
|
|
116
|
-
}
|
|
117
|
-
function deriveRenderKey(raw, kind, themeKey) {
|
|
118
|
-
const src = `${kind}:${themeKey ?? ""}:${raw}`;
|
|
119
|
-
return djb2(src);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// src/preview/projection.ts
|
|
123
|
-
var BLOCK_TYPE_TO_KIND = {
|
|
124
|
-
"paragraph": "paragraph",
|
|
125
|
-
"heading": "heading",
|
|
126
|
-
"unordered-list": "unordered-list",
|
|
127
|
-
"ordered-list": "ordered-list",
|
|
128
|
-
"blockquote": "blockquote",
|
|
129
|
-
"code-fence": "code-fence",
|
|
130
|
-
"directive-container": "custom",
|
|
131
|
-
"thematic-break": "thematic-break",
|
|
132
|
-
"math-block": "math-block",
|
|
133
|
-
"table": "table"
|
|
134
|
-
};
|
|
135
|
-
function blockTypeToPreviewKind(node) {
|
|
136
|
-
return BLOCK_TYPE_TO_KIND[node.type];
|
|
137
|
-
}
|
|
138
|
-
function isGroupableType(type) {
|
|
139
|
-
return type === "unordered-list" || type === "ordered-list" || type === "blockquote";
|
|
140
|
-
}
|
|
141
|
-
function countLines(raw) {
|
|
142
|
-
let count = 1;
|
|
143
|
-
for (let i = 0; i < raw.length; i++) {
|
|
144
|
-
if (raw.charCodeAt(i) === 10) count++;
|
|
145
|
-
}
|
|
146
|
-
return count;
|
|
147
|
-
}
|
|
148
|
-
function isBlankParagraph(block) {
|
|
149
|
-
return block.type === "paragraph" && !block.raw.trim();
|
|
150
|
-
}
|
|
151
|
-
function isSideAnnotationHead(block) {
|
|
152
|
-
return block.type === "paragraph" && SIDE_ANNOTATION_TAIL_RE.test(block.raw);
|
|
153
|
-
}
|
|
154
|
-
function isSideAnnotationContinuation(block) {
|
|
155
|
-
return block.type === "paragraph" && SIDE_CONTINUATION_TAIL_RE.test(block.raw);
|
|
156
|
-
}
|
|
157
|
-
function collectSideAnnotationChain(blocks, startIndex) {
|
|
158
|
-
if (!isSideAnnotationHead(blocks[startIndex])) return null;
|
|
159
|
-
const rawParts = [blocks[startIndex].raw];
|
|
160
|
-
let endIndex = startIndex;
|
|
161
|
-
let endLine = 0;
|
|
162
|
-
let currentLine = 0;
|
|
163
|
-
let foundContinuation = false;
|
|
164
|
-
let i = startIndex + 1;
|
|
165
|
-
while (i < blocks.length) {
|
|
166
|
-
const block = blocks[i];
|
|
167
|
-
if (isBlankParagraph(block)) {
|
|
168
|
-
const next = blocks[i + 1];
|
|
169
|
-
if (!next || !isSideAnnotationContinuation(next)) break;
|
|
170
|
-
rawParts.push(block.raw, next.raw);
|
|
171
|
-
endIndex = i + 1;
|
|
172
|
-
i += 2;
|
|
173
|
-
foundContinuation = true;
|
|
174
|
-
continue;
|
|
175
|
-
}
|
|
176
|
-
if (isSideAnnotationContinuation(block)) {
|
|
177
|
-
rawParts.push(block.raw);
|
|
178
|
-
endIndex = i;
|
|
179
|
-
i++;
|
|
180
|
-
foundContinuation = true;
|
|
181
|
-
continue;
|
|
182
|
-
}
|
|
183
|
-
break;
|
|
184
|
-
}
|
|
185
|
-
if (!foundContinuation) return null;
|
|
186
|
-
for (let j = startIndex; j <= endIndex; j++) {
|
|
187
|
-
currentLine += countLines(blocks[j].raw);
|
|
188
|
-
}
|
|
189
|
-
endLine = currentLine - 1;
|
|
190
|
-
return {
|
|
191
|
-
endIndex,
|
|
192
|
-
raw: rawParts.join("\n"),
|
|
193
|
-
endLine
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
function projectToPreviewBlocks(doc, themeKey, transforms) {
|
|
197
|
-
const result = [];
|
|
198
|
-
const blocks = doc.blocks;
|
|
199
|
-
const occurrenceCounter = /* @__PURE__ */ new Map();
|
|
200
|
-
let currentLine = 1;
|
|
201
|
-
let i = 0;
|
|
202
|
-
while (i < blocks.length) {
|
|
203
|
-
const block = blocks[i];
|
|
204
|
-
const blockLines = countLines(block.raw);
|
|
205
|
-
const startLine = currentLine;
|
|
206
|
-
const sideChain = collectSideAnnotationChain(blocks, i);
|
|
207
|
-
if (sideChain) {
|
|
208
|
-
const endLine2 = startLine + sideChain.endLine;
|
|
209
|
-
const renderKey2 = deriveRenderKey(sideChain.raw, "paragraph", themeKey);
|
|
210
|
-
const occurrence2 = occurrenceCounter.get(renderKey2) ?? 0;
|
|
211
|
-
occurrenceCounter.set(renderKey2, occurrence2 + 1);
|
|
212
|
-
result.push({
|
|
213
|
-
blockId: deriveBlockId(renderKey2, occurrence2),
|
|
214
|
-
kind: "paragraph",
|
|
215
|
-
raw: sideChain.raw,
|
|
216
|
-
startLine,
|
|
217
|
-
endLine: endLine2,
|
|
218
|
-
renderKey: renderKey2
|
|
219
|
-
});
|
|
220
|
-
currentLine = endLine2 + 1;
|
|
221
|
-
i = sideChain.endIndex + 1;
|
|
222
|
-
continue;
|
|
223
|
-
}
|
|
224
|
-
if (isBlankParagraph(block)) {
|
|
225
|
-
currentLine += blockLines;
|
|
226
|
-
i++;
|
|
227
|
-
continue;
|
|
228
|
-
}
|
|
229
|
-
if (isGroupableType(block.type)) {
|
|
230
|
-
const groupType = block.type;
|
|
231
|
-
const groupRawParts = [block.raw];
|
|
232
|
-
let endLine2 = startLine + blockLines - 1;
|
|
233
|
-
let j = i + 1;
|
|
234
|
-
while (j < blocks.length && blocks[j].type === groupType) {
|
|
235
|
-
const nextLines = countLines(blocks[j].raw);
|
|
236
|
-
endLine2 += nextLines;
|
|
237
|
-
groupRawParts.push(blocks[j].raw);
|
|
238
|
-
j++;
|
|
239
|
-
}
|
|
240
|
-
const raw = groupRawParts.join("\n");
|
|
241
|
-
const kind2 = blockTypeToPreviewKind(block);
|
|
242
|
-
const renderKey2 = deriveRenderKey(raw, kind2, themeKey);
|
|
243
|
-
const occurrence2 = occurrenceCounter.get(renderKey2) ?? 0;
|
|
244
|
-
occurrenceCounter.set(renderKey2, occurrence2 + 1);
|
|
245
|
-
result.push({
|
|
246
|
-
blockId: deriveBlockId(renderKey2, occurrence2),
|
|
247
|
-
kind: kind2,
|
|
248
|
-
raw,
|
|
249
|
-
startLine,
|
|
250
|
-
endLine: endLine2,
|
|
251
|
-
renderKey: renderKey2
|
|
252
|
-
});
|
|
253
|
-
currentLine = endLine2 + 1;
|
|
254
|
-
i = j;
|
|
255
|
-
continue;
|
|
256
|
-
}
|
|
257
|
-
const endLine = startLine + blockLines - 1;
|
|
258
|
-
const kind = blockTypeToPreviewKind(block);
|
|
259
|
-
const renderKey = deriveRenderKey(block.raw, kind, themeKey);
|
|
260
|
-
const occurrence = occurrenceCounter.get(renderKey) ?? 0;
|
|
261
|
-
occurrenceCounter.set(renderKey, occurrence + 1);
|
|
262
|
-
const previewBlock = {
|
|
263
|
-
blockId: deriveBlockId(renderKey, occurrence),
|
|
264
|
-
kind,
|
|
265
|
-
raw: block.raw,
|
|
266
|
-
startLine,
|
|
267
|
-
endLine,
|
|
268
|
-
renderKey
|
|
269
|
-
};
|
|
270
|
-
if (block.type === "code-fence") {
|
|
271
|
-
previewBlock.language = block.language || null;
|
|
272
|
-
}
|
|
273
|
-
if (block.type === "heading") {
|
|
274
|
-
previewBlock.headingLevel = block.headingLevel;
|
|
275
|
-
}
|
|
276
|
-
result.push(previewBlock);
|
|
277
|
-
currentLine = endLine + 1;
|
|
278
|
-
i++;
|
|
279
|
-
}
|
|
280
|
-
if (!transforms || transforms.length === 0) return result;
|
|
281
|
-
return result.map((block) => {
|
|
282
|
-
let b = block;
|
|
283
|
-
for (const transform of transforms) {
|
|
284
|
-
b = transform(b);
|
|
285
|
-
}
|
|
286
|
-
return b;
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
function blocksMatch(a, b) {
|
|
290
|
-
return a.blockId === b.blockId;
|
|
291
|
-
}
|
|
292
|
-
function computePreviewDirtyRange(oldBlocks, newBlocks) {
|
|
293
|
-
const oldLen = oldBlocks.length;
|
|
294
|
-
const newLen = newBlocks.length;
|
|
295
|
-
const minLen = Math.min(oldLen, newLen);
|
|
296
|
-
let start = 0;
|
|
297
|
-
while (start < minLen && blocksMatch(oldBlocks[start], newBlocks[start])) {
|
|
298
|
-
start++;
|
|
299
|
-
}
|
|
300
|
-
let oldEnd = oldLen - 1;
|
|
301
|
-
let newEnd = newLen - 1;
|
|
302
|
-
while (oldEnd >= start && newEnd >= start && blocksMatch(oldBlocks[oldEnd], newBlocks[newEnd])) {
|
|
303
|
-
oldEnd--;
|
|
304
|
-
newEnd--;
|
|
305
|
-
}
|
|
306
|
-
const end = Math.max(oldEnd, newEnd);
|
|
307
|
-
if (start > end) return null;
|
|
308
|
-
return { startBlock: start, endBlock: Math.min(end, newLen - 1) };
|
|
309
|
-
}
|
|
310
|
-
|
|
311
137
|
// src/state/shared-state.ts
|
|
312
138
|
function createInitialState(markdown, themeKey, transforms) {
|
|
313
139
|
const document = parseMarkdownToDocument(markdown);
|
|
@@ -321,6 +147,8 @@ function createInitialState(markdown, themeKey, transforms) {
|
|
|
321
147
|
compositionActive: false,
|
|
322
148
|
visibleBlockIds: [],
|
|
323
149
|
version: 1,
|
|
150
|
+
contentVersion: 1,
|
|
151
|
+
uiVersion: 1,
|
|
324
152
|
markdown
|
|
325
153
|
};
|
|
326
154
|
}
|
|
@@ -331,10 +159,17 @@ function createSharedStateStore(options) {
|
|
|
331
159
|
let editor = null;
|
|
332
160
|
let editorUnsubs = [];
|
|
333
161
|
const listeners = /* @__PURE__ */ new Set();
|
|
162
|
+
const selectorListeners = /* @__PURE__ */ new Set();
|
|
334
163
|
function notify() {
|
|
335
164
|
for (const listener of listeners) {
|
|
336
165
|
listener(state);
|
|
337
166
|
}
|
|
167
|
+
for (const subscription of selectorListeners) {
|
|
168
|
+
const nextSelected = subscription.selector(state);
|
|
169
|
+
if (subscription.isEqual(subscription.lastSelected, nextSelected)) continue;
|
|
170
|
+
subscription.lastSelected = nextSelected;
|
|
171
|
+
subscription.listener(nextSelected, state);
|
|
172
|
+
}
|
|
338
173
|
}
|
|
339
174
|
function updateFromMarkdown(markdown, reason) {
|
|
340
175
|
const oldBlocks = state.previewBlocks;
|
|
@@ -358,6 +193,8 @@ function createSharedStateStore(options) {
|
|
|
358
193
|
compositionActive: state.compositionActive,
|
|
359
194
|
visibleBlockIds: state.visibleBlockIds,
|
|
360
195
|
version: state.version + 1,
|
|
196
|
+
contentVersion: state.contentVersion + 1,
|
|
197
|
+
uiVersion: state.uiVersion,
|
|
361
198
|
markdown
|
|
362
199
|
};
|
|
363
200
|
notify();
|
|
@@ -369,7 +206,8 @@ function createSharedStateStore(options) {
|
|
|
369
206
|
previewBlocks,
|
|
370
207
|
dirtyRange: previewBlocks.length > 0 ? { startBlock: 0, endBlock: previewBlocks.length - 1 } : null,
|
|
371
208
|
dirtyReason: reason,
|
|
372
|
-
version: state.version + 1
|
|
209
|
+
version: state.version + 1,
|
|
210
|
+
contentVersion: state.contentVersion + 1
|
|
373
211
|
};
|
|
374
212
|
notify();
|
|
375
213
|
}
|
|
@@ -380,11 +218,19 @@ function createSharedStateStore(options) {
|
|
|
380
218
|
updateFromMarkdown(markdown, "text-edit");
|
|
381
219
|
});
|
|
382
220
|
const unsubSelection = instance.onSelectionChange((selection) => {
|
|
383
|
-
state = {
|
|
221
|
+
state = {
|
|
222
|
+
...state,
|
|
223
|
+
selection,
|
|
224
|
+
uiVersion: state.uiVersion + 1
|
|
225
|
+
};
|
|
384
226
|
notify();
|
|
385
227
|
});
|
|
386
228
|
const unsubComposition = instance.onCompositionStateChange((active) => {
|
|
387
|
-
state = {
|
|
229
|
+
state = {
|
|
230
|
+
...state,
|
|
231
|
+
compositionActive: active,
|
|
232
|
+
uiVersion: state.uiVersion + 1
|
|
233
|
+
};
|
|
388
234
|
notify();
|
|
389
235
|
});
|
|
390
236
|
editorUnsubs = [unsubChange, unsubSelection, unsubComposition];
|
|
@@ -407,6 +253,18 @@ function createSharedStateStore(options) {
|
|
|
407
253
|
listeners.add(listener);
|
|
408
254
|
return () => listeners.delete(listener);
|
|
409
255
|
},
|
|
256
|
+
subscribeWithSelector(selector, listener, isEqual = Object.is) {
|
|
257
|
+
const subscription = {
|
|
258
|
+
selector,
|
|
259
|
+
listener,
|
|
260
|
+
isEqual,
|
|
261
|
+
lastSelected: selector(state)
|
|
262
|
+
};
|
|
263
|
+
selectorListeners.add(subscription);
|
|
264
|
+
return () => {
|
|
265
|
+
selectorListeners.delete(subscription);
|
|
266
|
+
};
|
|
267
|
+
},
|
|
410
268
|
setMarkdown(markdown) {
|
|
411
269
|
if (editor) {
|
|
412
270
|
editor.setMarkdown(markdown);
|
|
@@ -564,6 +422,13 @@ function estimateEditorBlockHeight(block, charsPerLine = 80) {
|
|
|
564
422
|
const lineCount = countNewlines(block.raw) + 1;
|
|
565
423
|
return lineCount * lineHeight + FENCED_BLOCK_PADDING;
|
|
566
424
|
}
|
|
425
|
+
case "side-annotation":
|
|
426
|
+
case "side-note-definition":
|
|
427
|
+
case "directive-container":
|
|
428
|
+
case "custom-block": {
|
|
429
|
+
const lineCount = countNewlines(block.raw) + 1;
|
|
430
|
+
return lineCount * lineHeight + FENCED_BLOCK_PADDING;
|
|
431
|
+
}
|
|
567
432
|
case "table": {
|
|
568
433
|
const lineCount = countNewlines(block.raw) + 1;
|
|
569
434
|
return lineCount * lineHeight + TABLE_BLOCK_PADDING;
|
|
@@ -622,21 +487,24 @@ function computeVisibleRange(rows, scrollTop, viewportHeight, overscan = 5) {
|
|
|
622
487
|
return { startIndex, endIndex, totalHeight, offsetTop, offsetBottom };
|
|
623
488
|
}
|
|
624
489
|
export {
|
|
625
|
-
|
|
626
|
-
BQ_STEP,
|
|
490
|
+
CARDS_FAMILY_CUSTOM_BLOCK_KEY,
|
|
627
491
|
CLASSLESS_INLINE_TOKEN_TYPES,
|
|
492
|
+
DEFAULT_VIEWPORT_ANCHOR_RATIO,
|
|
628
493
|
INLINE_TOKEN_TYPES,
|
|
629
494
|
NOT_HANDLED,
|
|
630
|
-
TOKEN_CLASS_EXEMPTIONS,
|
|
631
|
-
TOKEN_TO_CLASS,
|
|
632
495
|
applyMarkdownIndent,
|
|
633
|
-
|
|
496
|
+
buildConformanceDocument,
|
|
497
|
+
buildConformanceMdastRoot,
|
|
498
|
+
buildProgressSegments,
|
|
499
|
+
buildScrollProjectionSnapshot,
|
|
634
500
|
buildVirtualRows,
|
|
501
|
+
cardsFamilyContainerExtension,
|
|
502
|
+
componentRegistry,
|
|
635
503
|
computePreviewDirtyRange,
|
|
636
504
|
computeVisibleRange,
|
|
637
|
-
createBlockElement,
|
|
638
505
|
createBlockIdGenerator,
|
|
639
506
|
createCommandRegistry,
|
|
507
|
+
createDelimitedInlineExtension,
|
|
640
508
|
createImageSizeTransform,
|
|
641
509
|
createOwoMarkCore,
|
|
642
510
|
createSharedStateStore,
|
|
@@ -647,50 +515,61 @@ export {
|
|
|
647
515
|
deriveBlockId,
|
|
648
516
|
deriveRenderKey,
|
|
649
517
|
deriveSourceKey,
|
|
650
|
-
|
|
651
|
-
domRangeToOffset,
|
|
518
|
+
editorEntryRegistry,
|
|
652
519
|
enableMapSet,
|
|
653
520
|
estimateEditorBlockHeight,
|
|
654
521
|
expandDirtyRange,
|
|
655
522
|
expandWithContext,
|
|
656
|
-
fullRender,
|
|
657
523
|
getBlockAtOffset,
|
|
658
524
|
getBlockById,
|
|
659
525
|
getBlockIndexById,
|
|
660
526
|
getBlockIndexForPosition,
|
|
661
527
|
getBlockStartOffset,
|
|
528
|
+
getComponentDescriptor,
|
|
529
|
+
getComponentDescriptorByDirective,
|
|
530
|
+
getEditorEntryDescriptor,
|
|
531
|
+
getEditorEntryDescriptorByCommandId,
|
|
532
|
+
getRuntimeBlockDescriptor,
|
|
533
|
+
getRuntimeBlockDescriptorByBlockType,
|
|
534
|
+
getRuntimeBlockDescriptorByPreviewKind,
|
|
535
|
+
getSyntaxDescriptor,
|
|
662
536
|
handleCharInput,
|
|
663
537
|
handleMarkdownEnter,
|
|
664
538
|
handleSmartBackspace,
|
|
665
539
|
handleSmartDelete,
|
|
540
|
+
hydrateOwoMarkDocument,
|
|
666
541
|
insertCodeFence,
|
|
667
542
|
insertImage,
|
|
668
543
|
insertLink,
|
|
669
544
|
insertMathBlock,
|
|
670
545
|
insertSideAnnotation,
|
|
671
546
|
insertTable,
|
|
672
|
-
|
|
547
|
+
isCardsFamilyAttributes,
|
|
673
548
|
isVirtualSelectionCollapsed,
|
|
674
549
|
linearToVirtual,
|
|
675
550
|
linearToVirtualPosition,
|
|
676
551
|
normalizeMarkdownPaste,
|
|
677
|
-
|
|
552
|
+
parseInlineSideAnnotationFromText,
|
|
678
553
|
parseMarkdownToDocument,
|
|
679
|
-
patchDirtyBlocks,
|
|
680
554
|
produce,
|
|
681
555
|
projectToPreviewBlocks,
|
|
682
|
-
|
|
556
|
+
projectToScrollSegments,
|
|
683
557
|
reconcileBlocks,
|
|
684
558
|
resetBlockIdCounter,
|
|
685
559
|
resolveBlockContextType,
|
|
560
|
+
resolveEditorEntryPresentation,
|
|
686
561
|
resolveIndentSize,
|
|
687
|
-
|
|
562
|
+
resolveScrollPosition,
|
|
563
|
+
resolveScrollTopFromPosition,
|
|
564
|
+
runtimeBlockRegistry,
|
|
688
565
|
serializeDocument,
|
|
566
|
+
stripInlineSideAnnotationTail,
|
|
567
|
+
stripSideContinuationTail,
|
|
568
|
+
syntaxRegistry,
|
|
689
569
|
toggleBold,
|
|
690
570
|
toggleItalic,
|
|
691
571
|
tokenizeBlock,
|
|
692
572
|
tokenizeInline,
|
|
693
|
-
updateBlockElement,
|
|
694
573
|
virtualPositionToLinear,
|
|
695
574
|
virtualPositionsEqual,
|
|
696
575
|
virtualToLinear
|
|
@@ -1 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
import { O as OwoMarkSelection, a as OwoMarkDocument, V as VirtualSelection } from '../public-zMo7BR9l.js';
|
|
2
|
+
import { O as OwoMarkCore } from '../editor-core-DbPhn6aI.js';
|
|
3
|
+
export { D as DocumentChangeCallback } from '../editor-core-DbPhn6aI.js';
|
|
4
|
+
|
|
5
|
+
type OwoMarkEditorInstance = {
|
|
6
|
+
mount(root: HTMLElement): void;
|
|
7
|
+
destroy(): void;
|
|
8
|
+
getMarkdown(): string;
|
|
9
|
+
setMarkdown(markdown: string): void;
|
|
10
|
+
replaceMarkdown(markdown: string, selection: OwoMarkSelection): void;
|
|
11
|
+
getSelection(): OwoMarkSelection | null;
|
|
12
|
+
getDocument(): OwoMarkDocument;
|
|
13
|
+
focus(): void;
|
|
14
|
+
dispatch(command: string, payload?: unknown): void;
|
|
15
|
+
setIndentMode(mode: 'auto' | '2' | '4'): void;
|
|
16
|
+
onChange(callback: (markdown: string) => void): () => void;
|
|
17
|
+
onSelectionChange(callback: (selection: OwoMarkSelection) => void): () => void;
|
|
18
|
+
onCompositionStateChange(callback: (active: boolean) => void): () => void;
|
|
19
|
+
onDocumentChange(callback: (doc: OwoMarkDocument, selection: VirtualSelection) => void): () => void;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Shared DOM adapter factory.
|
|
24
|
+
*
|
|
25
|
+
* Contains the full DOM event binding, imperative rendering, and
|
|
26
|
+
* selection management logic. Consumed by `@owomark/view`.
|
|
27
|
+
*
|
|
28
|
+
* @internal Not part of the public API — consumed only by adapter wrappers.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
type DomAdapterInstance = OwoMarkEditorInstance & {
|
|
32
|
+
/** Internal escape hatch for @owomark/view wrappers. */
|
|
33
|
+
getCore(): OwoMarkCore;
|
|
34
|
+
};
|
|
35
|
+
declare function createDomAdapter(): DomAdapterInstance;
|
|
36
|
+
|
|
37
|
+
export { type DomAdapterInstance, createDomAdapter };
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
|
-
createOwoMarkCore,
|
|
3
2
|
detectAndRenderDirty,
|
|
4
3
|
fullRender,
|
|
5
4
|
readSelection,
|
|
6
5
|
restoreSelection
|
|
7
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-CJSBFWKS.js";
|
|
7
|
+
import {
|
|
8
|
+
createOwoMarkCore
|
|
9
|
+
} from "../chunk-GA5EFGSZ.js";
|
|
10
|
+
import "../chunk-WFPUIPWU.js";
|
|
11
|
+
import "../chunk-ROJILHRQ.js";
|
|
12
|
+
import "../chunk-BKJCBEI7.js";
|
|
8
13
|
import "../chunk-BGXCXQZP.js";
|
|
9
14
|
import "../chunk-MPIWZLI3.js";
|
|
15
|
+
import "../chunk-3KTK7CSS.js";
|
|
16
|
+
import "../chunk-OOH46GIF.js";
|
|
10
17
|
|
|
11
18
|
// src/internal/dom-adapter.ts
|
|
12
19
|
function createDomAdapter() {
|