wysimark-lite 0.25.3 → 0.25.5
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/index.js +126 -126
- package/dist/index.mjs +328 -165
- package/dist/index.mjs.map +1 -1
- package/dist/metafile-esm.json +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -132,25 +132,199 @@ function escapeUrlSlashes(text) {
|
|
|
132
132
|
const markdownLinkPattern = /\[([^\]]+)\]\(([^)]+)\)/g;
|
|
133
133
|
const links = [];
|
|
134
134
|
let linkIndex = 0;
|
|
135
|
-
|
|
135
|
+
let result = text.replace(markdownLinkPattern, (match) => {
|
|
136
136
|
links.push(match);
|
|
137
137
|
return `__MARKDOWN_LINK_${linkIndex++}__`;
|
|
138
138
|
});
|
|
139
|
+
const htmlBlocks = [];
|
|
140
|
+
const masked = maskHtmlBlocks(result, htmlBlocks);
|
|
141
|
+
result = masked;
|
|
139
142
|
const urlPattern = /(https?:\/\/[^\s]+)/g;
|
|
140
|
-
|
|
143
|
+
result = result.replace(urlPattern, (url) => {
|
|
141
144
|
return url.replace(/\//g, "\\/");
|
|
142
145
|
});
|
|
143
|
-
let
|
|
146
|
+
for (let i = 0; i < htmlBlocks.length; i++) {
|
|
147
|
+
result = result.replace(`__HTML_BLOCK_${i}__`, htmlBlocks[i]);
|
|
148
|
+
}
|
|
144
149
|
for (let i = 0; i < links.length; i++) {
|
|
145
150
|
result = result.replace(`__MARKDOWN_LINK_${i}__`, links[i]);
|
|
146
151
|
}
|
|
147
152
|
return result;
|
|
148
153
|
}
|
|
149
154
|
function unescapeUrlSlashes(text) {
|
|
150
|
-
return text.replace(/\\(.)/g, (
|
|
155
|
+
return text.replace(/\\(.)/g, (_match, char) => {
|
|
151
156
|
return char;
|
|
152
157
|
});
|
|
153
158
|
}
|
|
159
|
+
var RAW_TEXT_TAGS = /* @__PURE__ */ new Set(["script", "style"]);
|
|
160
|
+
function maskHtmlBlocks(text, htmlBlocks) {
|
|
161
|
+
let output = "";
|
|
162
|
+
let index = 0;
|
|
163
|
+
while (index < text.length) {
|
|
164
|
+
const ltIndex = text.indexOf("<", index);
|
|
165
|
+
if (ltIndex === -1) {
|
|
166
|
+
output += text.slice(index);
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
output += text.slice(index, ltIndex);
|
|
170
|
+
if (text.startsWith("<!--", ltIndex)) {
|
|
171
|
+
const end = text.indexOf("-->", ltIndex + 4);
|
|
172
|
+
if (end === -1) {
|
|
173
|
+
output += text.slice(ltIndex);
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
const block2 = text.slice(ltIndex, end + 3);
|
|
177
|
+
htmlBlocks.push(block2);
|
|
178
|
+
output += `__HTML_BLOCK_${htmlBlocks.length - 1}__`;
|
|
179
|
+
index = end + 3;
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
if (text.startsWith("<![CDATA[", ltIndex)) {
|
|
183
|
+
const end = text.indexOf("]]>", ltIndex + 9);
|
|
184
|
+
if (end === -1) {
|
|
185
|
+
output += text.slice(ltIndex);
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
const block2 = text.slice(ltIndex, end + 3);
|
|
189
|
+
htmlBlocks.push(block2);
|
|
190
|
+
output += `__HTML_BLOCK_${htmlBlocks.length - 1}__`;
|
|
191
|
+
index = end + 3;
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
const tag = parseTag(text, ltIndex);
|
|
195
|
+
if (!tag) {
|
|
196
|
+
output += "<";
|
|
197
|
+
index = ltIndex + 1;
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
const blockIndex = htmlBlocks.length;
|
|
201
|
+
const placeholder = `__HTML_BLOCK_${blockIndex}__`;
|
|
202
|
+
if (!tag.name) {
|
|
203
|
+
const block2 = text.slice(ltIndex, tag.endIndex + 1);
|
|
204
|
+
htmlBlocks.push(block2);
|
|
205
|
+
output += placeholder;
|
|
206
|
+
index = tag.endIndex + 1;
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
const tagName = tag.name.toLowerCase();
|
|
210
|
+
if (tag.isClosing || tag.isSelfClosing) {
|
|
211
|
+
const block2 = text.slice(ltIndex, tag.endIndex + 1);
|
|
212
|
+
htmlBlocks.push(block2);
|
|
213
|
+
output += placeholder;
|
|
214
|
+
index = tag.endIndex + 1;
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
if (RAW_TEXT_TAGS.has(tagName)) {
|
|
218
|
+
const closeStart = text.toLowerCase().indexOf(`</${tagName}`, tag.endIndex + 1);
|
|
219
|
+
if (closeStart !== -1) {
|
|
220
|
+
const closeTag = parseTag(text, closeStart);
|
|
221
|
+
if (closeTag) {
|
|
222
|
+
const block2 = text.slice(ltIndex, closeTag.endIndex + 1);
|
|
223
|
+
htmlBlocks.push(block2);
|
|
224
|
+
output += placeholder;
|
|
225
|
+
index = closeTag.endIndex + 1;
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
const closingTagEnd = findClosingTagEnd(text, tagName, tag.endIndex + 1);
|
|
231
|
+
if (closingTagEnd !== null) {
|
|
232
|
+
const block2 = text.slice(ltIndex, closingTagEnd + 1);
|
|
233
|
+
htmlBlocks.push(block2);
|
|
234
|
+
output += placeholder;
|
|
235
|
+
index = closingTagEnd + 1;
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
const block = text.slice(ltIndex, tag.endIndex + 1);
|
|
239
|
+
htmlBlocks.push(block);
|
|
240
|
+
output += placeholder;
|
|
241
|
+
index = tag.endIndex + 1;
|
|
242
|
+
}
|
|
243
|
+
return output;
|
|
244
|
+
}
|
|
245
|
+
function parseTag(text, startIndex) {
|
|
246
|
+
if (text[startIndex] !== "<")
|
|
247
|
+
return null;
|
|
248
|
+
const endIndex = findTagEnd(text, startIndex);
|
|
249
|
+
if (endIndex === -1)
|
|
250
|
+
return null;
|
|
251
|
+
let cursor = startIndex + 1;
|
|
252
|
+
if (cursor >= text.length)
|
|
253
|
+
return null;
|
|
254
|
+
const firstChar = text[cursor];
|
|
255
|
+
if (firstChar === "!" || firstChar === "?") {
|
|
256
|
+
return {
|
|
257
|
+
name: null,
|
|
258
|
+
endIndex,
|
|
259
|
+
isClosing: false,
|
|
260
|
+
isSelfClosing: true
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
let isClosing = false;
|
|
264
|
+
if (firstChar === "/") {
|
|
265
|
+
isClosing = true;
|
|
266
|
+
cursor += 1;
|
|
267
|
+
}
|
|
268
|
+
const nameMatch = /^[A-Za-z][A-Za-z0-9-]*/.exec(text.slice(cursor));
|
|
269
|
+
if (!nameMatch)
|
|
270
|
+
return null;
|
|
271
|
+
const name = nameMatch[0];
|
|
272
|
+
const tagText = text.slice(startIndex, endIndex + 1);
|
|
273
|
+
const isSelfClosing = /\/\s*>$/.test(tagText);
|
|
274
|
+
return {
|
|
275
|
+
name,
|
|
276
|
+
endIndex,
|
|
277
|
+
isClosing,
|
|
278
|
+
isSelfClosing
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
function findTagEnd(text, startIndex) {
|
|
282
|
+
let quote = null;
|
|
283
|
+
for (let i = startIndex + 1; i < text.length; i++) {
|
|
284
|
+
const char = text[i];
|
|
285
|
+
if (quote) {
|
|
286
|
+
if (char === quote) {
|
|
287
|
+
quote = null;
|
|
288
|
+
}
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
if (char === "'" || char === '"') {
|
|
292
|
+
quote = char;
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
if (char === ">") {
|
|
296
|
+
return i;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return -1;
|
|
300
|
+
}
|
|
301
|
+
function findClosingTagEnd(text, tagName, startIndex) {
|
|
302
|
+
let depth = 1;
|
|
303
|
+
let cursor = startIndex;
|
|
304
|
+
const lowerTag = tagName.toLowerCase();
|
|
305
|
+
while (cursor < text.length) {
|
|
306
|
+
const ltIndex = text.indexOf("<", cursor);
|
|
307
|
+
if (ltIndex === -1)
|
|
308
|
+
return null;
|
|
309
|
+
const tag = parseTag(text, ltIndex);
|
|
310
|
+
if (!tag || !tag.name) {
|
|
311
|
+
cursor = ltIndex + 1;
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
if (tag.name.toLowerCase() === lowerTag) {
|
|
315
|
+
if (tag.isClosing) {
|
|
316
|
+
depth -= 1;
|
|
317
|
+
} else if (!tag.isSelfClosing) {
|
|
318
|
+
depth += 1;
|
|
319
|
+
}
|
|
320
|
+
if (depth === 0) {
|
|
321
|
+
return tag.endIndex;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
cursor = tag.endIndex + 1;
|
|
325
|
+
}
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
154
328
|
function assert(pass, message) {
|
|
155
329
|
if (!pass)
|
|
156
330
|
throw new Error(`${message}`);
|
|
@@ -339,71 +513,36 @@ function sortMarks(marks) {
|
|
|
339
513
|
}
|
|
340
514
|
|
|
341
515
|
// src/convert/serialize/serialize-line/utils/text-utils.ts
|
|
342
|
-
var
|
|
516
|
+
var INLINE_ESCAPES = [
|
|
343
517
|
"\\",
|
|
344
|
-
// escape
|
|
518
|
+
// escape character
|
|
345
519
|
"`",
|
|
346
|
-
// code
|
|
520
|
+
// inline code
|
|
347
521
|
"*",
|
|
348
|
-
// bold
|
|
522
|
+
// emphasis/bold
|
|
349
523
|
"_",
|
|
350
|
-
// bold
|
|
524
|
+
// emphasis/bold
|
|
351
525
|
"[",
|
|
352
|
-
// link
|
|
526
|
+
// link start
|
|
353
527
|
"]",
|
|
354
|
-
// link
|
|
355
|
-
"(",
|
|
356
|
-
// link
|
|
357
|
-
")",
|
|
358
|
-
// link
|
|
359
|
-
"#",
|
|
360
|
-
// headings
|
|
361
|
-
"+",
|
|
362
|
-
// list
|
|
363
|
-
"-",
|
|
364
|
-
// hr/list
|
|
365
|
-
".",
|
|
366
|
-
// numbered list
|
|
367
|
-
"!",
|
|
368
|
-
// image
|
|
369
|
-
"|",
|
|
370
|
-
// table
|
|
371
|
-
"^",
|
|
372
|
-
// sup
|
|
528
|
+
// link end
|
|
373
529
|
"~",
|
|
374
|
-
//
|
|
375
|
-
"
|
|
376
|
-
//
|
|
377
|
-
"
|
|
378
|
-
//
|
|
379
|
-
/**
|
|
380
|
-
* Includes all the characters in the list of Backslash escapes in the example
|
|
381
|
-
* for GitHub Flavored Markdown.
|
|
382
|
-
*
|
|
383
|
-
* https://github.github.com/gfm/#backslash-escapes
|
|
384
|
-
*/
|
|
385
|
-
"{",
|
|
386
|
-
"}",
|
|
387
|
-
"=",
|
|
388
|
-
":",
|
|
389
|
-
";",
|
|
390
|
-
"$",
|
|
391
|
-
"%",
|
|
392
|
-
"&",
|
|
393
|
-
"?",
|
|
394
|
-
'"',
|
|
395
|
-
"'",
|
|
396
|
-
",",
|
|
397
|
-
"\\",
|
|
398
|
-
"/",
|
|
399
|
-
"@"
|
|
530
|
+
// strikethrough (GFM)
|
|
531
|
+
"|",
|
|
532
|
+
// table cell (GFM)
|
|
533
|
+
"<"
|
|
534
|
+
// HTML tag
|
|
400
535
|
];
|
|
401
|
-
var
|
|
402
|
-
`(${
|
|
536
|
+
var INLINE_ESCAPES_REGEXP = new RegExp(
|
|
537
|
+
`(${INLINE_ESCAPES.map((symbol) => `\\${symbol}`).join("|")})`,
|
|
403
538
|
"g"
|
|
404
539
|
);
|
|
405
540
|
function escapeText(s) {
|
|
406
|
-
|
|
541
|
+
let result = s.replace(INLINE_ESCAPES_REGEXP, (s2) => `\\${s2}`);
|
|
542
|
+
result = result.replace(/^(#{1,6})(\s)/m, "\\$1$2");
|
|
543
|
+
result = result.replace(/^(\d+)([.)]\s)/m, "$1\\$2");
|
|
544
|
+
result = result.replace(/^([-+>])\s/m, "\\$1 ");
|
|
545
|
+
return result;
|
|
407
546
|
}
|
|
408
547
|
|
|
409
548
|
// src/convert/parse/parse-phrasing-content/normalize-segment.ts
|
|
@@ -456,7 +595,7 @@ function parseGenericImage(image) {
|
|
|
456
595
|
}
|
|
457
596
|
|
|
458
597
|
// src/convert/parseUrl.ts
|
|
459
|
-
var URL_REGEX = /^(
|
|
598
|
+
var URL_REGEX = /^([^?#]*)(?:\?([^#]*))?(#.*)?$/;
|
|
460
599
|
function parseUrl(url) {
|
|
461
600
|
try {
|
|
462
601
|
const urlData = new URL(url);
|
|
@@ -490,8 +629,8 @@ function parseSize(s) {
|
|
|
490
629
|
if (sizeMatch === null)
|
|
491
630
|
return null;
|
|
492
631
|
return {
|
|
493
|
-
width: parseInt(sizeMatch[1]),
|
|
494
|
-
height: parseInt(sizeMatch[2])
|
|
632
|
+
width: parseInt(sizeMatch[1], 10),
|
|
633
|
+
height: parseInt(sizeMatch[2], 10)
|
|
495
634
|
};
|
|
496
635
|
}
|
|
497
636
|
|
|
@@ -515,8 +654,8 @@ function parsePortiveImage(image) {
|
|
|
515
654
|
alt: image.alt || void 0,
|
|
516
655
|
width: size.width,
|
|
517
656
|
height: size.height,
|
|
518
|
-
srcWidth: parseInt(srcSizeMatch[1]),
|
|
519
|
-
srcHeight: parseInt(srcSizeMatch[2])
|
|
657
|
+
srcWidth: parseInt(srcSizeMatch[1], 10),
|
|
658
|
+
srcHeight: parseInt(srcSizeMatch[2], 10)
|
|
520
659
|
};
|
|
521
660
|
}
|
|
522
661
|
|
|
@@ -1050,7 +1189,7 @@ function mergeAdjacentSpaces({
|
|
|
1050
1189
|
}) {
|
|
1051
1190
|
if (!isText(node) || !isPlainSpace(node) || node.code)
|
|
1052
1191
|
return false;
|
|
1053
|
-
if (!isText(nextNode) || !isPlainSpace(nextNode) ||
|
|
1192
|
+
if (!isText(nextNode) || !isPlainSpace(nextNode) || nextNode.code)
|
|
1054
1193
|
return false;
|
|
1055
1194
|
nodes.splice(index, 2, { text: `${node.text}${nextNode.text}` });
|
|
1056
1195
|
return true;
|
|
@@ -1446,7 +1585,7 @@ function serializeTableCell(element) {
|
|
|
1446
1585
|
element.children
|
|
1447
1586
|
)}`
|
|
1448
1587
|
);
|
|
1449
|
-
return element.children.map(serializeTableContent).join();
|
|
1588
|
+
return element.children.map(serializeTableContent).join("");
|
|
1450
1589
|
}
|
|
1451
1590
|
function serializeTableContent(element) {
|
|
1452
1591
|
assertElementType(element, "table-content");
|
|
@@ -1461,7 +1600,7 @@ function serializeElement(element, orders) {
|
|
|
1461
1600
|
return `[${serializeLine(element.children)}](${element.href})`;
|
|
1462
1601
|
case "block-quote": {
|
|
1463
1602
|
const lines = serializeElements(element.children);
|
|
1464
|
-
return `${lines.split("\n").map((line) => `> ${line}
|
|
1603
|
+
return `${lines.split("\n").map((line) => line ? `> ${line}` : ">").join("\n")}
|
|
1465
1604
|
|
|
1466
1605
|
`;
|
|
1467
1606
|
}
|
|
@@ -1508,6 +1647,8 @@ function serializeElement(element, orders) {
|
|
|
1508
1647
|
}
|
|
1509
1648
|
case "image-block":
|
|
1510
1649
|
return serializeImageBlock(element);
|
|
1650
|
+
case "image-inline":
|
|
1651
|
+
return ``;
|
|
1511
1652
|
case "code-block":
|
|
1512
1653
|
return serializeCodeBlock(element);
|
|
1513
1654
|
case "code-block-line":
|
|
@@ -1858,7 +1999,7 @@ function SinkEditable(originalProps) {
|
|
|
1858
1999
|
const editor = useSlateStatic();
|
|
1859
2000
|
useEffect(() => {
|
|
1860
2001
|
Editor.normalize(editor, { force: true });
|
|
1861
|
-
}, []);
|
|
2002
|
+
}, [editor]);
|
|
1862
2003
|
const { plugins: plugins2 } = editor.sink;
|
|
1863
2004
|
const nextProps = useMemo(
|
|
1864
2005
|
() => ({
|
|
@@ -1881,7 +2022,19 @@ function SinkEditable(originalProps) {
|
|
|
1881
2022
|
onPaste: createOnPaste(originalProps.onPaste, plugins2),
|
|
1882
2023
|
onDrop: createOnDrop(originalProps.onDrop, plugins2)
|
|
1883
2024
|
}),
|
|
1884
|
-
|
|
2025
|
+
[
|
|
2026
|
+
originalProps.decorate,
|
|
2027
|
+
originalProps.renderElement,
|
|
2028
|
+
originalProps.renderLeaf,
|
|
2029
|
+
originalProps.renderPlaceholder,
|
|
2030
|
+
originalProps.onKeyDown,
|
|
2031
|
+
originalProps.onKeyUp,
|
|
2032
|
+
originalProps.onPaste,
|
|
2033
|
+
originalProps.onDrop,
|
|
2034
|
+
originalProps.placeholder,
|
|
2035
|
+
originalProps.className,
|
|
2036
|
+
plugins2
|
|
2037
|
+
]
|
|
1885
2038
|
);
|
|
1886
2039
|
const NextEditable = useMemo(() => createEditable(plugins2), [plugins2]);
|
|
1887
2040
|
return /* @__PURE__ */ jsx2(NextEditable, { ...nextProps });
|
|
@@ -2340,7 +2493,7 @@ function editLink(editor, { href, title, text }, { at }) {
|
|
|
2340
2493
|
}
|
|
2341
2494
|
|
|
2342
2495
|
// src/anchor-plugin/methods/insertLink.ts
|
|
2343
|
-
import { Editor as Editor15, Range as Range3, Text as Text2, Transforms as Transforms8 } from "slate";
|
|
2496
|
+
import { Editor as Editor15, Element as Element9, Range as Range3, Text as Text2, Transforms as Transforms8 } from "slate";
|
|
2344
2497
|
function insertLink(editor, href, text = href, { select = true, title } = {}) {
|
|
2345
2498
|
const selection = editor.selection || {
|
|
2346
2499
|
anchor: Editor15.start(editor, [0]),
|
|
@@ -2367,7 +2520,7 @@ function insertLink(editor, href, text = href, { select = true, title } = {}) {
|
|
|
2367
2520
|
{ type: "anchor", href, title, children: [] },
|
|
2368
2521
|
{
|
|
2369
2522
|
split: true,
|
|
2370
|
-
match: (node) => Text2.isText(node) || Editor15.isInline(editor, node)
|
|
2523
|
+
match: (node) => Text2.isText(node) || Element9.isElement(node) && Editor15.isInline(editor, node)
|
|
2371
2524
|
}
|
|
2372
2525
|
);
|
|
2373
2526
|
}
|
|
@@ -2393,16 +2546,16 @@ function createAnchorMethods(editor) {
|
|
|
2393
2546
|
}
|
|
2394
2547
|
|
|
2395
2548
|
// src/anchor-plugin/normalize-node/index.ts
|
|
2396
|
-
import { Element as
|
|
2549
|
+
import { Element as Element10, Transforms as Transforms10 } from "slate";
|
|
2397
2550
|
function normalizeNode(editor, entry) {
|
|
2398
|
-
if (!
|
|
2551
|
+
if (!Element10.isElement(entry[0]))
|
|
2399
2552
|
return false;
|
|
2400
2553
|
if (entry[0].type !== "anchor")
|
|
2401
2554
|
return false;
|
|
2402
2555
|
const children = entry[0].children;
|
|
2403
2556
|
for (let i = 0; i < children.length; i++) {
|
|
2404
2557
|
const child = children[i];
|
|
2405
|
-
if (!
|
|
2558
|
+
if (!Element10.isElement(child) || child.type !== "anchor")
|
|
2406
2559
|
continue;
|
|
2407
2560
|
Transforms10.unwrapNodes(editor, { at: [...entry[1], i] });
|
|
2408
2561
|
return true;
|
|
@@ -2701,15 +2854,18 @@ import { useEffect as useEffect2 } from "react";
|
|
|
2701
2854
|
|
|
2702
2855
|
// src/use-reposition/hooks/use-throttled-refresh.ts
|
|
2703
2856
|
import throttle from "lodash.throttle";
|
|
2704
|
-
import { useState as useState2 } from "react";
|
|
2857
|
+
import { useMemo as useMemo2, useState as useState2 } from "react";
|
|
2705
2858
|
function useThrottledRefresh(intervalInMs = 100) {
|
|
2706
2859
|
const [counter, setState] = useState2(0);
|
|
2707
|
-
const refresh =
|
|
2708
|
-
() =>
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2860
|
+
const refresh = useMemo2(
|
|
2861
|
+
() => throttle(
|
|
2862
|
+
() => {
|
|
2863
|
+
setState((counter2) => counter2 + 1);
|
|
2864
|
+
},
|
|
2865
|
+
intervalInMs,
|
|
2866
|
+
{ trailing: true }
|
|
2867
|
+
),
|
|
2868
|
+
[intervalInMs]
|
|
2713
2869
|
);
|
|
2714
2870
|
return Object.assign(refresh, { counter });
|
|
2715
2871
|
}
|
|
@@ -3077,6 +3233,8 @@ function Menu({
|
|
|
3077
3233
|
const editor = useSlateStatic2();
|
|
3078
3234
|
const ref = useRef2(null);
|
|
3079
3235
|
const style = useAbsoluteReposition({ src: ref, dest }, ({ dest: dest2 }) => {
|
|
3236
|
+
if (!dest2)
|
|
3237
|
+
return { left: 0, top: 0 };
|
|
3080
3238
|
return { left: dest2.left - 8, top: dest2.top + dest2.height };
|
|
3081
3239
|
});
|
|
3082
3240
|
return /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
@@ -3761,7 +3919,7 @@ var AnchorPlugin = createPlugin(
|
|
|
3761
3919
|
import { Editor as Editor19, Transforms as Transforms11 } from "slate";
|
|
3762
3920
|
|
|
3763
3921
|
// src/atomic-delete-plugin/is-safe-delete.ts
|
|
3764
|
-
import { Element as
|
|
3922
|
+
import { Element as Element11, Path as Path6 } from "slate";
|
|
3765
3923
|
function isSafeDelete(editor, a, b) {
|
|
3766
3924
|
if (!a || !b)
|
|
3767
3925
|
return true;
|
|
@@ -3769,13 +3927,13 @@ function isSafeDelete(editor, a, b) {
|
|
|
3769
3927
|
return true;
|
|
3770
3928
|
const masterEntryA = findElementUp(
|
|
3771
3929
|
editor,
|
|
3772
|
-
(el) =>
|
|
3930
|
+
(el) => Element11.isElement(el) && editor.isMaster(el),
|
|
3773
3931
|
{ at: a[1] }
|
|
3774
3932
|
);
|
|
3775
3933
|
const masterEntryB = findElementUp(
|
|
3776
3934
|
editor,
|
|
3777
3935
|
(el) => {
|
|
3778
|
-
return
|
|
3936
|
+
return Element11.isElement(el) && editor.isMaster(el);
|
|
3779
3937
|
},
|
|
3780
3938
|
{ at: b[1] }
|
|
3781
3939
|
);
|
|
@@ -4132,7 +4290,7 @@ function resizeInBounds(size, bounds) {
|
|
|
4132
4290
|
}
|
|
4133
4291
|
return size;
|
|
4134
4292
|
}
|
|
4135
|
-
function resizeInPreset(
|
|
4293
|
+
function resizeInPreset(_size, srcSize, preset) {
|
|
4136
4294
|
switch (preset.type) {
|
|
4137
4295
|
case "bounds":
|
|
4138
4296
|
return resizeInBounds(srcSize, preset);
|
|
@@ -4146,7 +4304,7 @@ function resizeInPreset(size, srcSize, preset) {
|
|
|
4146
4304
|
function getEditorWidth(editor) {
|
|
4147
4305
|
const element = ReactEditor4.toDOMNode(editor, editor);
|
|
4148
4306
|
const computed = getComputedStyle(element);
|
|
4149
|
-
const padding = parseInt(computed.paddingLeft) + parseInt(computed.paddingRight);
|
|
4307
|
+
const padding = parseInt(computed.paddingLeft, 10) + parseInt(computed.paddingRight, 10);
|
|
4150
4308
|
return element.clientWidth - padding;
|
|
4151
4309
|
}
|
|
4152
4310
|
|
|
@@ -4550,7 +4708,7 @@ import { useCallback as useCallback9 } from "react";
|
|
|
4550
4708
|
import { useSlateStatic as useSlateStatic8 } from "slate-react";
|
|
4551
4709
|
|
|
4552
4710
|
// src/image-plugin/render-element/image-with-controls/image-toolbar/image-type-buttons/convert-to-block-image.tsx
|
|
4553
|
-
import { Editor as Editor23, Text as Text3, Transforms as Transforms16 } from "slate";
|
|
4711
|
+
import { Editor as Editor23, Element as Element12, Text as Text3, Transforms as Transforms16 } from "slate";
|
|
4554
4712
|
import { ReactEditor as ReactEditor8 } from "slate-react";
|
|
4555
4713
|
function convertToBlockImage(editor, element) {
|
|
4556
4714
|
if (!element.width || !element.height || !element.srcWidth || !element.srcHeight)
|
|
@@ -4573,7 +4731,7 @@ function convertToBlockImage(editor, element) {
|
|
|
4573
4731
|
);
|
|
4574
4732
|
const parentEntry = findElementUp(
|
|
4575
4733
|
editor,
|
|
4576
|
-
(node) => Editor23.isBlock(editor, node) && node.type !== "image-block"
|
|
4734
|
+
(node) => Element12.isElement(node) && Editor23.isBlock(editor, node) && node.type !== "image-block"
|
|
4577
4735
|
);
|
|
4578
4736
|
if (!parentEntry)
|
|
4579
4737
|
throw new Error("This shouldn't happen");
|
|
@@ -4901,7 +5059,7 @@ var ImagePlugin = (
|
|
|
4901
5059
|
);
|
|
4902
5060
|
|
|
4903
5061
|
// src/block-quote-plugin/index.tsx
|
|
4904
|
-
import { Editor as Editor25, Element as
|
|
5062
|
+
import { Editor as Editor25, Element as Element13, Transforms as Transforms18 } from "slate";
|
|
4905
5063
|
|
|
4906
5064
|
// src/block-quote-plugin/styles.tsx
|
|
4907
5065
|
import styled23 from "@emotion/styled";
|
|
@@ -4917,7 +5075,7 @@ var $BlockQuote = styled23("blockquote")`
|
|
|
4917
5075
|
// src/block-quote-plugin/index.tsx
|
|
4918
5076
|
import { jsx as jsx29 } from "react/jsx-runtime";
|
|
4919
5077
|
function matchBlockQuoteSafe(node) {
|
|
4920
|
-
return
|
|
5078
|
+
return Element13.isElement(node) && /**
|
|
4921
5079
|
* TODO:
|
|
4922
5080
|
*
|
|
4923
5081
|
* This is probably:
|
|
@@ -4945,13 +5103,13 @@ var BlockQuotePlugin = createPlugin(
|
|
|
4945
5103
|
},
|
|
4946
5104
|
isActive: () => {
|
|
4947
5105
|
const [match] = Editor25.nodes(editor, {
|
|
4948
|
-
match: (n) =>
|
|
5106
|
+
match: (n) => Element13.isElement(n) && n.type === "block-quote"
|
|
4949
5107
|
});
|
|
4950
5108
|
return !!match;
|
|
4951
5109
|
},
|
|
4952
5110
|
increaseDepth: () => {
|
|
4953
5111
|
const [match] = Editor25.nodes(editor, {
|
|
4954
|
-
match: (n) =>
|
|
5112
|
+
match: (n) => Element13.isElement(n) && n.type === "block-quote"
|
|
4955
5113
|
});
|
|
4956
5114
|
if (!match)
|
|
4957
5115
|
return;
|
|
@@ -4967,7 +5125,7 @@ var BlockQuotePlugin = createPlugin(
|
|
|
4967
5125
|
},
|
|
4968
5126
|
decreaseDepth: () => {
|
|
4969
5127
|
const [match] = Editor25.nodes(editor, {
|
|
4970
|
-
match: (n) =>
|
|
5128
|
+
match: (n) => Element13.isElement(n) && n.type === "block-quote"
|
|
4971
5129
|
});
|
|
4972
5130
|
if (!match)
|
|
4973
5131
|
return;
|
|
@@ -4975,24 +5133,24 @@ var BlockQuotePlugin = createPlugin(
|
|
|
4975
5133
|
return;
|
|
4976
5134
|
const [node, path] = match;
|
|
4977
5135
|
const children = node.children;
|
|
4978
|
-
if (children.length === 1 &&
|
|
5136
|
+
if (children.length === 1 && Element13.isElement(children[0]) && children[0].type === "block-quote") {
|
|
4979
5137
|
Transforms18.unwrapNodes(editor, {
|
|
4980
5138
|
at: [...path, 0],
|
|
4981
5139
|
// Path to the nested block-quote
|
|
4982
|
-
match: (n) =>
|
|
5140
|
+
match: (n) => Element13.isElement(n) && n.type === "block-quote"
|
|
4983
5141
|
});
|
|
4984
5142
|
}
|
|
4985
5143
|
},
|
|
4986
5144
|
canIncreaseDepth: () => {
|
|
4987
5145
|
const [match] = Editor25.nodes(editor, {
|
|
4988
|
-
match: (n) =>
|
|
5146
|
+
match: (n) => Element13.isElement(n) && n.type === "block-quote"
|
|
4989
5147
|
});
|
|
4990
5148
|
if (!match)
|
|
4991
5149
|
return false;
|
|
4992
5150
|
const [node] = match;
|
|
4993
5151
|
let depth = 0;
|
|
4994
5152
|
let current = node;
|
|
4995
|
-
while (current.children.length === 1 &&
|
|
5153
|
+
while (current.children.length === 1 && Element13.isElement(current.children[0]) && current.children[0] && current.children[0] && current.children[0].type === "block-quote") {
|
|
4996
5154
|
depth++;
|
|
4997
5155
|
current = current.children[0];
|
|
4998
5156
|
}
|
|
@@ -5000,12 +5158,12 @@ var BlockQuotePlugin = createPlugin(
|
|
|
5000
5158
|
},
|
|
5001
5159
|
canDecreaseDepth: () => {
|
|
5002
5160
|
const [match] = Editor25.nodes(editor, {
|
|
5003
|
-
match: (n) =>
|
|
5161
|
+
match: (n) => Element13.isElement(n) && n.type === "block-quote"
|
|
5004
5162
|
});
|
|
5005
5163
|
if (!match)
|
|
5006
5164
|
return false;
|
|
5007
5165
|
const [node] = match;
|
|
5008
|
-
return node.children.length === 1 &&
|
|
5166
|
+
return node.children.length === 1 && Element13.isElement(node.children[0]) && node.children[0] && node.children[0].type === "block-quote";
|
|
5009
5167
|
}
|
|
5010
5168
|
};
|
|
5011
5169
|
return {
|
|
@@ -5013,12 +5171,12 @@ var BlockQuotePlugin = createPlugin(
|
|
|
5013
5171
|
editor: {
|
|
5014
5172
|
normalizeNode(entry) {
|
|
5015
5173
|
const [node, path] = entry;
|
|
5016
|
-
if (!
|
|
5174
|
+
if (!Element13.isElement(node))
|
|
5017
5175
|
return false;
|
|
5018
5176
|
if (node.type !== "block-quote")
|
|
5019
5177
|
return false;
|
|
5020
5178
|
return normalizeSiblings(editor, [node, path], (a, b) => {
|
|
5021
|
-
if (
|
|
5179
|
+
if (Element13.isElement(a[0]) && Element13.isElement(b[0]) && a[0].type === "block-quote" && b[0].type === "block-quote") {
|
|
5022
5180
|
Transforms18.mergeNodes(editor, { at: b[1] });
|
|
5023
5181
|
}
|
|
5024
5182
|
return true;
|
|
@@ -5041,11 +5199,11 @@ var BlockQuotePlugin = createPlugin(
|
|
|
5041
5199
|
);
|
|
5042
5200
|
|
|
5043
5201
|
// src/code-block-plugin/index.tsx
|
|
5044
|
-
import { Editor as Editor28, Element as
|
|
5202
|
+
import { Editor as Editor28, Element as Element17, Transforms as Transforms21 } from "slate";
|
|
5045
5203
|
|
|
5046
5204
|
// src/code-block-plugin/decorate.tsx
|
|
5047
5205
|
import Prism from "prismjs";
|
|
5048
|
-
import { Element as
|
|
5206
|
+
import { Element as Element14, Node as Node8 } from "slate";
|
|
5049
5207
|
var { languages, tokenize } = Prism;
|
|
5050
5208
|
function getLineOffsets(lines) {
|
|
5051
5209
|
let offset = 0;
|
|
@@ -5058,7 +5216,7 @@ function getLineOffsets(lines) {
|
|
|
5058
5216
|
}
|
|
5059
5217
|
function decorate(nodeEntry) {
|
|
5060
5218
|
const [node, path] = nodeEntry;
|
|
5061
|
-
if (!
|
|
5219
|
+
if (!Element14.isElement(node))
|
|
5062
5220
|
return [];
|
|
5063
5221
|
if (node.type !== "code-block")
|
|
5064
5222
|
return [];
|
|
@@ -5112,11 +5270,11 @@ function createCodeBlock(editor, { language }) {
|
|
|
5112
5270
|
}
|
|
5113
5271
|
|
|
5114
5272
|
// src/code-block-plugin/methods/setCodeBlockLanguage.ts
|
|
5115
|
-
import { Element as
|
|
5273
|
+
import { Element as Element15, Transforms as Transforms19 } from "slate";
|
|
5116
5274
|
function setCodeBlockLanguage(editor, language, options = {}) {
|
|
5117
5275
|
const entry = findElementUp(
|
|
5118
5276
|
editor,
|
|
5119
|
-
(el) =>
|
|
5277
|
+
(el) => Element15.isElement(el) && el.type === "code-block",
|
|
5120
5278
|
{ at: options.at }
|
|
5121
5279
|
);
|
|
5122
5280
|
if (!entry)
|
|
@@ -5188,13 +5346,13 @@ var LanguageList = [
|
|
|
5188
5346
|
];
|
|
5189
5347
|
|
|
5190
5348
|
// src/code-block-plugin/normalizeNode.tsx
|
|
5191
|
-
import { Element as
|
|
5349
|
+
import { Element as Element16, Node as Node9, Transforms as Transforms20 } from "slate";
|
|
5192
5350
|
function normalizeNode3(editor, entry) {
|
|
5193
|
-
if (!
|
|
5351
|
+
if (!Element16.isElement(entry[0]))
|
|
5194
5352
|
return false;
|
|
5195
5353
|
if (entry[0].type === "code-block-line") {
|
|
5196
5354
|
for (const [child, path] of Node9.children(editor, entry[1])) {
|
|
5197
|
-
if (!
|
|
5355
|
+
if (!Element16.isElement(child))
|
|
5198
5356
|
continue;
|
|
5199
5357
|
if (editor.isVoid(child)) {
|
|
5200
5358
|
Transforms20.removeNodes(editor, { at: path });
|
|
@@ -5207,7 +5365,7 @@ function normalizeNode3(editor, entry) {
|
|
|
5207
5365
|
}
|
|
5208
5366
|
if (entry[0].type === "code-block") {
|
|
5209
5367
|
for (const [child, path] of Node9.children(editor, entry[1])) {
|
|
5210
|
-
if (!
|
|
5368
|
+
if (!Element16.isElement(child))
|
|
5211
5369
|
continue;
|
|
5212
5370
|
if (child.type === "code-block-line")
|
|
5213
5371
|
continue;
|
|
@@ -5387,7 +5545,7 @@ function renderElement2({
|
|
|
5387
5545
|
}
|
|
5388
5546
|
|
|
5389
5547
|
// src/code-block-plugin/index.tsx
|
|
5390
|
-
import { jsx as jsx34 } from "react/jsx-runtime";
|
|
5548
|
+
import { Fragment as Fragment4, jsx as jsx34 } from "react/jsx-runtime";
|
|
5391
5549
|
var CodeBlockPlugin = createPlugin(
|
|
5392
5550
|
(editor, _options, { createPolicy }) => {
|
|
5393
5551
|
editor.codeBlock = createCodeBlockMethods(editor);
|
|
@@ -5415,7 +5573,7 @@ var CodeBlockPlugin = createPlugin(
|
|
|
5415
5573
|
return false;
|
|
5416
5574
|
},
|
|
5417
5575
|
isVoid(element) {
|
|
5418
|
-
if (element.type === "code-block" || element.type
|
|
5576
|
+
if (element.type === "code-block" || element.type === "code-block-line")
|
|
5419
5577
|
return false;
|
|
5420
5578
|
},
|
|
5421
5579
|
isMaster(element) {
|
|
@@ -5431,7 +5589,7 @@ var CodeBlockPlugin = createPlugin(
|
|
|
5431
5589
|
"mod+a": () => {
|
|
5432
5590
|
const entry = findElementUp(
|
|
5433
5591
|
editor,
|
|
5434
|
-
(el) =>
|
|
5592
|
+
(el) => Element17.isElement(el) && el.type === "code-block"
|
|
5435
5593
|
);
|
|
5436
5594
|
if (!entry)
|
|
5437
5595
|
return false;
|
|
@@ -5443,7 +5601,7 @@ var CodeBlockPlugin = createPlugin(
|
|
|
5443
5601
|
renderLeaf: ({ leaf, children }) => {
|
|
5444
5602
|
const style = leaf.prismToken ? tokenStyles[leaf.prismToken] || null : null;
|
|
5445
5603
|
if (style === null) {
|
|
5446
|
-
return children;
|
|
5604
|
+
return /* @__PURE__ */ jsx34(Fragment4, { children });
|
|
5447
5605
|
} else {
|
|
5448
5606
|
return /* @__PURE__ */ jsx34("span", { style, children });
|
|
5449
5607
|
}
|
|
@@ -5548,12 +5706,12 @@ var HtmlBlockPlugin = createPlugin(
|
|
|
5548
5706
|
import { Editor as Editor32 } from "slate";
|
|
5549
5707
|
|
|
5550
5708
|
// src/collapsible-paragraph-plugin/normalize-node/index.ts
|
|
5551
|
-
import { Element as
|
|
5709
|
+
import { Element as Element20 } from "slate";
|
|
5552
5710
|
|
|
5553
5711
|
// src/collapsible-paragraph-plugin/normalize-node/normalize-sibling-paragraphs.ts
|
|
5554
|
-
import { Element as
|
|
5712
|
+
import { Element as Element18, Transforms as Transforms23 } from "slate";
|
|
5555
5713
|
function isParagraph(node) {
|
|
5556
|
-
return
|
|
5714
|
+
return Element18.isElement(node) && node.type === "paragraph";
|
|
5557
5715
|
}
|
|
5558
5716
|
function normalizeSiblingParagraphs(editor, entry) {
|
|
5559
5717
|
return normalizeSiblings(editor, entry, (a, b) => {
|
|
@@ -5568,9 +5726,9 @@ function normalizeSiblingParagraphs(editor, entry) {
|
|
|
5568
5726
|
}
|
|
5569
5727
|
|
|
5570
5728
|
// src/collapsible-paragraph-plugin/normalize-node/normalize-sibling-walls.ts
|
|
5571
|
-
import { Element as
|
|
5729
|
+
import { Element as Element19, Transforms as Transforms24 } from "slate";
|
|
5572
5730
|
function isWall(editor, node) {
|
|
5573
|
-
if (!
|
|
5731
|
+
if (!Element19.isElement(node))
|
|
5574
5732
|
return false;
|
|
5575
5733
|
return editor.isVoid(node) || editor.isMaster(node);
|
|
5576
5734
|
}
|
|
@@ -5596,7 +5754,7 @@ function normalizeSiblingWalls(editor, entry) {
|
|
|
5596
5754
|
// src/collapsible-paragraph-plugin/normalize-node/index.ts
|
|
5597
5755
|
function normalizeNode4(editor, entry) {
|
|
5598
5756
|
const [node, path] = entry;
|
|
5599
|
-
if (!
|
|
5757
|
+
if (!Element20.isElement(node))
|
|
5600
5758
|
return false;
|
|
5601
5759
|
if (normalizeSiblingWalls(editor, [node, path]))
|
|
5602
5760
|
return true;
|
|
@@ -5741,7 +5899,7 @@ function addConvertElementType(editor, type) {
|
|
|
5741
5899
|
}
|
|
5742
5900
|
|
|
5743
5901
|
// src/convert-element-plugin/methods/convert-elements.ts
|
|
5744
|
-
import { Editor as Editor33, Element as
|
|
5902
|
+
import { Editor as Editor33, Element as Element22, Node as Node13, Point, Range as Range5, Transforms as Transforms25 } from "slate";
|
|
5745
5903
|
function getOffsetInElement(editor, point, elementPath) {
|
|
5746
5904
|
try {
|
|
5747
5905
|
const elementStart = Editor33.start(editor, elementPath);
|
|
@@ -5758,7 +5916,7 @@ function getOffsetInElement(editor, point, elementPath) {
|
|
|
5758
5916
|
function restoreSelectionInElement(editor, elementPath, offset) {
|
|
5759
5917
|
try {
|
|
5760
5918
|
const element = Node13.get(editor, elementPath);
|
|
5761
|
-
if (!
|
|
5919
|
+
if (!Element22.isElement(element))
|
|
5762
5920
|
return;
|
|
5763
5921
|
const text = Node13.string(element);
|
|
5764
5922
|
const safeOffset = Math.min(offset, text.length);
|
|
@@ -5891,7 +6049,7 @@ function convertElements(editor, matchForToggle, targetElement, allowToggle) {
|
|
|
5891
6049
|
const isCollapsed2 = Range5.isCollapsed(selection);
|
|
5892
6050
|
const entries = Array.from(
|
|
5893
6051
|
Editor33.nodes(editor, {
|
|
5894
|
-
match: (node) =>
|
|
6052
|
+
match: (node) => Element22.isElement(node) && editor.convertElement.isConvertibleElement(node)
|
|
5895
6053
|
})
|
|
5896
6054
|
);
|
|
5897
6055
|
if (entries.length > 0) {
|
|
@@ -5921,7 +6079,7 @@ function convertElements(editor, matchForToggle, targetElement, allowToggle) {
|
|
|
5921
6079
|
const updatedEntries = allPaths.map((path) => {
|
|
5922
6080
|
try {
|
|
5923
6081
|
const node = Node13.get(editor, path);
|
|
5924
|
-
if (
|
|
6082
|
+
if (Element22.isElement(node)) {
|
|
5925
6083
|
return [node, path];
|
|
5926
6084
|
}
|
|
5927
6085
|
return null;
|
|
@@ -5952,7 +6110,7 @@ function convertElements(editor, matchForToggle, targetElement, allowToggle) {
|
|
|
5952
6110
|
} else if (savedFocusOffset >= 0) {
|
|
5953
6111
|
try {
|
|
5954
6112
|
const element = Node13.get(editor, firstPath);
|
|
5955
|
-
if (
|
|
6113
|
+
if (Element22.isElement(element)) {
|
|
5956
6114
|
const text = Node13.string(element);
|
|
5957
6115
|
const safeAnchorOffset = Math.min(savedAnchorOffset, text.length);
|
|
5958
6116
|
const safeFocusOffset = Math.min(savedFocusOffset, text.length);
|
|
@@ -6220,14 +6378,14 @@ function HorizontalRule({
|
|
|
6220
6378
|
}
|
|
6221
6379
|
|
|
6222
6380
|
// src/horizontal-rule-plugin/methods/index.ts
|
|
6223
|
-
import { Editor as Editor36, Element as
|
|
6381
|
+
import { Editor as Editor36, Element as Element23, Path as Path10, Transforms as Transforms27 } from "slate";
|
|
6224
6382
|
function insertHorizontalRule(editor) {
|
|
6225
6383
|
const { selection } = editor;
|
|
6226
6384
|
if (!selection)
|
|
6227
6385
|
return false;
|
|
6228
6386
|
const entry = findElementUp(
|
|
6229
6387
|
editor,
|
|
6230
|
-
(node) =>
|
|
6388
|
+
(node) => Element23.isElement(node) && editor.isMaster(node)
|
|
6231
6389
|
);
|
|
6232
6390
|
const hrElement = {
|
|
6233
6391
|
type: "horizontal-rule",
|
|
@@ -6522,13 +6680,13 @@ function createListMethods(editor) {
|
|
|
6522
6680
|
}
|
|
6523
6681
|
|
|
6524
6682
|
// src/list-plugin/normalize-node/normalize-ordered-first-at-depth.ts
|
|
6525
|
-
import { Element as
|
|
6683
|
+
import { Element as Element24, Transforms as Transforms30 } from "slate";
|
|
6526
6684
|
var isOrderedListItem = createIsElementType([
|
|
6527
6685
|
"ordered-list-item"
|
|
6528
6686
|
]);
|
|
6529
6687
|
function normalizeOrderedFirstAtDepth(editor, entry) {
|
|
6530
6688
|
const [node, path] = entry;
|
|
6531
|
-
if (!
|
|
6689
|
+
if (!Element24.isElement(node))
|
|
6532
6690
|
return false;
|
|
6533
6691
|
return normalizeSiblings(editor, [node, path], (a, b) => {
|
|
6534
6692
|
if (!isOrderedListItem(b[0]))
|
|
@@ -6801,7 +6959,7 @@ var ListPlugin = createPlugin(
|
|
|
6801
6959
|
|
|
6802
6960
|
// src/marks-plugin/index.tsx
|
|
6803
6961
|
import { clsx as clsx7 } from "clsx";
|
|
6804
|
-
import { Editor as Editor44,
|
|
6962
|
+
import { Editor as Editor44, Range as Range8 } from "slate";
|
|
6805
6963
|
|
|
6806
6964
|
// src/marks-plugin/methods/removeMarks.ts
|
|
6807
6965
|
import { Editor as Editor42, Text as Text4, Transforms as Transforms31 } from "slate";
|
|
@@ -6928,13 +7086,11 @@ var MarksPlugin = createPlugin((editor) => {
|
|
|
6928
7086
|
const { removeMarks: removeMarks2 } = editor.marksPlugin;
|
|
6929
7087
|
editor.marksPlugin.removeMarks = () => {
|
|
6930
7088
|
removeMarks2();
|
|
6931
|
-
if (editor.selection) {
|
|
6932
|
-
const point =
|
|
6933
|
-
|
|
6934
|
-
|
|
6935
|
-
|
|
6936
|
-
editor.activeMarks = {};
|
|
6937
|
-
}
|
|
7089
|
+
if (editor.selection && Range8.isRange(editor.selection)) {
|
|
7090
|
+
const point = editor.selection.focus;
|
|
7091
|
+
const isAtLineEnd = Editor44.after(editor, point) === null || Editor44.isEnd(editor, point, Editor44.end(editor, []));
|
|
7092
|
+
if (isAtLineEnd) {
|
|
7093
|
+
editor.activeMarks = {};
|
|
6938
7094
|
}
|
|
6939
7095
|
}
|
|
6940
7096
|
};
|
|
@@ -6966,7 +7122,7 @@ var MarksPlugin = createPlugin((editor) => {
|
|
|
6966
7122
|
});
|
|
6967
7123
|
|
|
6968
7124
|
// src/normalize-after-delete-plugin/index.tsx
|
|
6969
|
-
import { Editor as Editor45, Point as
|
|
7125
|
+
import { Editor as Editor45, Point as Point3 } from "slate";
|
|
6970
7126
|
function forceNormalizeNearestElement(editor) {
|
|
6971
7127
|
if (!editor.selection)
|
|
6972
7128
|
return;
|
|
@@ -6982,7 +7138,7 @@ var NormalizeAfterDeletePlugin = createPlugin((editor) => {
|
|
|
6982
7138
|
if (!editor.selection)
|
|
6983
7139
|
return false;
|
|
6984
7140
|
const entry = Editor45.parent(editor, editor.selection);
|
|
6985
|
-
const isStart =
|
|
7141
|
+
const isStart = Point3.equals(
|
|
6986
7142
|
Editor45.start(editor, entry[1]),
|
|
6987
7143
|
editor.selection.anchor
|
|
6988
7144
|
);
|
|
@@ -6996,7 +7152,7 @@ var NormalizeAfterDeletePlugin = createPlugin((editor) => {
|
|
|
6996
7152
|
if (!editor.selection)
|
|
6997
7153
|
return false;
|
|
6998
7154
|
const entry = Editor45.parent(editor, editor.selection);
|
|
6999
|
-
const isEnd =
|
|
7155
|
+
const isEnd = Point3.equals(
|
|
7000
7156
|
Editor45.end(editor, entry[1]),
|
|
7001
7157
|
editor.selection.anchor
|
|
7002
7158
|
);
|
|
@@ -7012,7 +7168,7 @@ var NormalizeAfterDeletePlugin = createPlugin((editor) => {
|
|
|
7012
7168
|
});
|
|
7013
7169
|
|
|
7014
7170
|
// src/table-plugin/index.tsx
|
|
7015
|
-
import { Element as
|
|
7171
|
+
import { Element as Element26 } from "slate";
|
|
7016
7172
|
|
|
7017
7173
|
// src/table-plugin/delete-fragment/index.ts
|
|
7018
7174
|
import { Editor as Editor47, Path as Path13, Transforms as Transforms32 } from "slate";
|
|
@@ -7119,7 +7275,7 @@ function getTableInfo(editor, { at = editor.selection } = {}) {
|
|
|
7119
7275
|
import { Editor as Editor48, Transforms as Transforms33 } from "slate";
|
|
7120
7276
|
|
|
7121
7277
|
// src/table-plugin/methods/utils.ts
|
|
7122
|
-
function createCell(
|
|
7278
|
+
function createCell(_index, children = [
|
|
7123
7279
|
{
|
|
7124
7280
|
type: "table-content",
|
|
7125
7281
|
children: [{ text: "" }]
|
|
@@ -7141,9 +7297,10 @@ function insertColumn(editor, { offset = 0, at = editor.selection } = {}) {
|
|
|
7141
7297
|
Editor48.withoutNormalizing(editor, () => {
|
|
7142
7298
|
const { columns } = tableElement;
|
|
7143
7299
|
const nextColumns = [...columns];
|
|
7144
|
-
|
|
7300
|
+
const sourceIndex = Math.min(nextCellIndex, columns.length - 1);
|
|
7301
|
+
nextColumns.splice(nextCellIndex, 0, columns[sourceIndex]);
|
|
7145
7302
|
Transforms33.setNodes(editor, { columns: nextColumns }, { at: tablePath });
|
|
7146
|
-
tableElement.children.forEach((
|
|
7303
|
+
tableElement.children.forEach((_rowElement, i) => {
|
|
7147
7304
|
Transforms33.insertNodes(editor, createCell(nextCellIndex), {
|
|
7148
7305
|
at: [...tablePath, i, nextCellIndex]
|
|
7149
7306
|
});
|
|
@@ -7175,7 +7332,7 @@ function insertRowBelow(editor, { at } = {}) {
|
|
|
7175
7332
|
}
|
|
7176
7333
|
|
|
7177
7334
|
// src/table-plugin/methods/insert-table.ts
|
|
7178
|
-
import { Editor as Editor50, Element as
|
|
7335
|
+
import { Editor as Editor50, Element as Element25, Path as Path14, Transforms as Transforms35 } from "slate";
|
|
7179
7336
|
function createRange(size) {
|
|
7180
7337
|
return [...Array(size).keys()];
|
|
7181
7338
|
}
|
|
@@ -7204,7 +7361,7 @@ function insertRootElement2(editor, element, { at = editor.selection } = {}) {
|
|
|
7204
7361
|
return false;
|
|
7205
7362
|
const entry = findElementUp(
|
|
7206
7363
|
editor,
|
|
7207
|
-
(node) =>
|
|
7364
|
+
(node) => Element25.isElement(node) && editor.isMaster(node)
|
|
7208
7365
|
);
|
|
7209
7366
|
if (entry == null) {
|
|
7210
7367
|
const selection = editor.selection;
|
|
@@ -7324,7 +7481,7 @@ function removeColumn(editor, { at = editor.selection } = {}) {
|
|
|
7324
7481
|
const columns = [...tableElement.columns];
|
|
7325
7482
|
columns.splice(cellIndex, 1);
|
|
7326
7483
|
Transforms37.setNodes(editor, { columns }, { at: tablePath });
|
|
7327
|
-
tableElement.children.forEach((
|
|
7484
|
+
tableElement.children.forEach((_rowElement, rowIndex2) => {
|
|
7328
7485
|
Transforms37.removeNodes(editor, {
|
|
7329
7486
|
at: [...tablePath, rowIndex2, cellIndex]
|
|
7330
7487
|
});
|
|
@@ -7772,7 +7929,7 @@ var AlignCenter = () => /* @__PURE__ */ jsx50(TablerIcon, { children: /* @__PURE
|
|
|
7772
7929
|
var AlignRight = () => /* @__PURE__ */ jsx50(TablerIcon, { children: /* @__PURE__ */ jsx50("path", { d: "M4 6h16M10 12h10M6 18h14" }) });
|
|
7773
7930
|
|
|
7774
7931
|
// src/table-plugin/render-element/table-cell/column-menu/index.tsx
|
|
7775
|
-
import { Fragment as
|
|
7932
|
+
import { Fragment as Fragment5, jsx as jsx51, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
7776
7933
|
function ColumnMenu({ cellElement }) {
|
|
7777
7934
|
const editor = useSlateStatic14();
|
|
7778
7935
|
const menu = useLayer("column-menu");
|
|
@@ -7825,7 +7982,7 @@ function ColumnMenu({ cellElement }) {
|
|
|
7825
7982
|
onMouseLeave,
|
|
7826
7983
|
children: [
|
|
7827
7984
|
/* @__PURE__ */ jsx51($ColumnMenuTile, { className: "--tile", children: /* @__PURE__ */ jsx51(BarsIcon, {}) }),
|
|
7828
|
-
hover ? /* @__PURE__ */ jsxs23(
|
|
7985
|
+
hover ? /* @__PURE__ */ jsxs23(Fragment5, { children: [
|
|
7829
7986
|
/* @__PURE__ */ jsx51(
|
|
7830
7987
|
$RemoveMenuButton,
|
|
7831
7988
|
{
|
|
@@ -7863,7 +8020,7 @@ function ColumnMenu({ cellElement }) {
|
|
|
7863
8020
|
// src/table-plugin/render-element/table-cell/row-menu/index.tsx
|
|
7864
8021
|
import { useState as useState7 } from "react";
|
|
7865
8022
|
import { useSlateStatic as useSlateStatic15 } from "slate-react";
|
|
7866
|
-
import { Fragment as
|
|
8023
|
+
import { Fragment as Fragment6, jsx as jsx52, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
7867
8024
|
function RowMenu({ cellElement }) {
|
|
7868
8025
|
const editor = useSlateStatic15();
|
|
7869
8026
|
const [hover, setHover] = useState7(false);
|
|
@@ -7875,7 +8032,7 @@ function RowMenu({ cellElement }) {
|
|
|
7875
8032
|
onMouseLeave: () => setHover(false),
|
|
7876
8033
|
children: [
|
|
7877
8034
|
/* @__PURE__ */ jsx52($RowMenuTile, { className: "--tile", children: /* @__PURE__ */ jsx52(BarsIcon, {}) }),
|
|
7878
|
-
hover ? /* @__PURE__ */ jsxs24(
|
|
8035
|
+
hover ? /* @__PURE__ */ jsxs24(Fragment6, { children: [
|
|
7879
8036
|
/* @__PURE__ */ jsx52(
|
|
7880
8037
|
$RemoveMenuButton,
|
|
7881
8038
|
{
|
|
@@ -8056,7 +8213,7 @@ var TablePlugin = createPlugin(
|
|
|
8056
8213
|
},
|
|
8057
8214
|
normalizeNode: (entry) => {
|
|
8058
8215
|
const [node] = entry;
|
|
8059
|
-
if (!
|
|
8216
|
+
if (!Element26.isElement(node))
|
|
8060
8217
|
return false;
|
|
8061
8218
|
switch (node.type) {
|
|
8062
8219
|
case "table":
|
|
@@ -8167,14 +8324,14 @@ var globalStyles = css2`
|
|
|
8167
8324
|
`;
|
|
8168
8325
|
|
|
8169
8326
|
// src/theme-plugin/index.tsx
|
|
8170
|
-
import { Fragment as
|
|
8327
|
+
import { Fragment as Fragment7, jsx as jsx58, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
8171
8328
|
var ThemePlugin = createPlugin((editor) => {
|
|
8172
8329
|
editor.theme = true;
|
|
8173
8330
|
return {
|
|
8174
8331
|
name: "theme",
|
|
8175
8332
|
editor: {},
|
|
8176
8333
|
renderEditable: ({ attributes, Editable: Editable3 }) => {
|
|
8177
|
-
return /* @__PURE__ */ jsxs26(
|
|
8334
|
+
return /* @__PURE__ */ jsxs26(Fragment7, { children: [
|
|
8178
8335
|
/* @__PURE__ */ jsx58(Global, { styles: globalStyles }),
|
|
8179
8336
|
/* @__PURE__ */ jsx58(Editable3, { ...attributes })
|
|
8180
8337
|
] });
|
|
@@ -8218,7 +8375,7 @@ var $TableDialogGridCell = styled35("div")`
|
|
|
8218
8375
|
`;
|
|
8219
8376
|
|
|
8220
8377
|
// src/toolbar-plugin/components/dialog/table-dialog.tsx
|
|
8221
|
-
import { Fragment as
|
|
8378
|
+
import { Fragment as Fragment8, jsx as jsx59, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
8222
8379
|
function createRange2(size) {
|
|
8223
8380
|
return [...Array(size).keys()];
|
|
8224
8381
|
}
|
|
@@ -8230,6 +8387,8 @@ function TableDialog({
|
|
|
8230
8387
|
const editor = useSlateStatic16();
|
|
8231
8388
|
const ref = useRef8(null);
|
|
8232
8389
|
const style = useAbsoluteReposition({ src: ref, dest }, ({ dest: dest2 }) => {
|
|
8390
|
+
if (!dest2)
|
|
8391
|
+
return { left: 0, top: 0 };
|
|
8233
8392
|
return { left: dest2.left - 8, top: dest2.top + dest2.height };
|
|
8234
8393
|
});
|
|
8235
8394
|
const rows = createRange2(5).map((i) => i + 1);
|
|
@@ -8248,7 +8407,7 @@ function TableDialog({
|
|
|
8248
8407
|
},
|
|
8249
8408
|
[editor]
|
|
8250
8409
|
);
|
|
8251
|
-
return /* @__PURE__ */ jsxs27(
|
|
8410
|
+
return /* @__PURE__ */ jsxs27(Fragment8, { children: [
|
|
8252
8411
|
/* @__PURE__ */ jsx59(CloseMask, { close }),
|
|
8253
8412
|
/* @__PURE__ */ jsx59($TableDialog, { ref, style, children: /* @__PURE__ */ jsx59($TableDialogGrid, { onMouseLeave: () => hoverCell(0, 0), children: rows.map((y) => {
|
|
8254
8413
|
return cols.map((x) => {
|
|
@@ -8394,13 +8553,13 @@ var $FileDialog = styled36($Panel)`
|
|
|
8394
8553
|
`;
|
|
8395
8554
|
|
|
8396
8555
|
// src/toolbar-plugin/components/dialog/image-url-dialog.tsx
|
|
8397
|
-
import { Fragment as
|
|
8556
|
+
import { Fragment as Fragment9, jsx as jsx61, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
8398
8557
|
function ImageUrlDialog({
|
|
8399
8558
|
dest,
|
|
8400
8559
|
close
|
|
8401
8560
|
}) {
|
|
8402
8561
|
const editor = useSlateStatic17();
|
|
8403
|
-
const ref = useRef9(
|
|
8562
|
+
const ref = useRef9(null);
|
|
8404
8563
|
const fileInputRef = useRef9(null);
|
|
8405
8564
|
const [dragOffset, setDragOffset] = useState9({ x: 0, y: 0 });
|
|
8406
8565
|
const handleDrag = useCallback14((deltaX, deltaY) => {
|
|
@@ -8479,7 +8638,6 @@ function ImageUrlDialog({
|
|
|
8479
8638
|
const resultUrl = await editor.wysimark.onImageChange(file);
|
|
8480
8639
|
setUploadedUrl(resultUrl);
|
|
8481
8640
|
} catch (error) {
|
|
8482
|
-
console.error("Failed to upload image:", error);
|
|
8483
8641
|
} finally {
|
|
8484
8642
|
setIsUploading(false);
|
|
8485
8643
|
}
|
|
@@ -8488,7 +8646,7 @@ function ImageUrlDialog({
|
|
|
8488
8646
|
fileInputRef.current?.click();
|
|
8489
8647
|
}
|
|
8490
8648
|
const isSubmitDisabled = imageSource === "file" ? uploadedUrl.trim() === "" || isUploading : url.trim() === "";
|
|
8491
|
-
return /* @__PURE__ */ jsxs29(
|
|
8649
|
+
return /* @__PURE__ */ jsxs29(Fragment9, { children: [
|
|
8492
8650
|
/* @__PURE__ */ jsx61(CloseMask, { close }),
|
|
8493
8651
|
/* @__PURE__ */ jsxs29($FileDialog, { ref, style, children: [
|
|
8494
8652
|
/* @__PURE__ */ jsx61(DraggableHeader, { onDrag: handleDrag }),
|
|
@@ -8669,7 +8827,7 @@ function ImageUrlDialog({
|
|
|
8669
8827
|
import { isHotkey as isHotkey3 } from "is-hotkey";
|
|
8670
8828
|
import {
|
|
8671
8829
|
useCallback as useCallback15,
|
|
8672
|
-
useMemo as
|
|
8830
|
+
useMemo as useMemo3,
|
|
8673
8831
|
useRef as useRef10,
|
|
8674
8832
|
useState as useState10
|
|
8675
8833
|
} from "react";
|
|
@@ -8711,7 +8869,7 @@ var $DialogHint = styled37("div")`
|
|
|
8711
8869
|
`;
|
|
8712
8870
|
|
|
8713
8871
|
// src/toolbar-plugin/components/dialog/anchor-dialog.tsx
|
|
8714
|
-
import { Fragment as
|
|
8872
|
+
import { Fragment as Fragment10, jsx as jsx62, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
8715
8873
|
var isEnter = isHotkey3("enter");
|
|
8716
8874
|
function AnchorDialog2({
|
|
8717
8875
|
dest,
|
|
@@ -8726,6 +8884,8 @@ function AnchorDialog2({
|
|
|
8726
8884
|
const baseStyle = useAbsoluteReposition(
|
|
8727
8885
|
{ src: ref, dest },
|
|
8728
8886
|
({ src, dest: dest2 }, viewport) => {
|
|
8887
|
+
if (!src || !dest2)
|
|
8888
|
+
return { left: 0, top: 0 };
|
|
8729
8889
|
return positionInside(
|
|
8730
8890
|
src,
|
|
8731
8891
|
viewport,
|
|
@@ -8742,7 +8902,7 @@ function AnchorDialog2({
|
|
|
8742
8902
|
left: baseStyle.left + dragOffset.x,
|
|
8743
8903
|
top: baseStyle.top + dragOffset.y
|
|
8744
8904
|
};
|
|
8745
|
-
const initialText =
|
|
8905
|
+
const initialText = useMemo3(() => {
|
|
8746
8906
|
const { selection } = editor;
|
|
8747
8907
|
if (selection && !Range10.isCollapsed(selection)) {
|
|
8748
8908
|
return Editor60.string(editor, selection);
|
|
@@ -8790,7 +8950,7 @@ function AnchorDialog2({
|
|
|
8790
8950
|
e.stopPropagation();
|
|
8791
8951
|
insertLink2();
|
|
8792
8952
|
};
|
|
8793
|
-
return /* @__PURE__ */ jsxs30(
|
|
8953
|
+
return /* @__PURE__ */ jsxs30(Fragment10, { children: [
|
|
8794
8954
|
/* @__PURE__ */ jsx62(CloseMask, { close }),
|
|
8795
8955
|
/* @__PURE__ */ jsxs30($AnchorDialog, { ref, style, children: [
|
|
8796
8956
|
/* @__PURE__ */ jsx62(DraggableHeader, { onDrag: handleDrag }),
|
|
@@ -9498,6 +9658,8 @@ function Editable2({
|
|
|
9498
9658
|
const initialValueRef = useRef14(void 0);
|
|
9499
9659
|
const prevValueRef = useRef14(void 0);
|
|
9500
9660
|
const pendingRawTextRef = useRef14(null);
|
|
9661
|
+
const onChangeRef = useRef14(onChange);
|
|
9662
|
+
onChangeRef.current = onChange;
|
|
9501
9663
|
const onThrottledSlateChange = useCallback18(
|
|
9502
9664
|
throttle3(
|
|
9503
9665
|
() => {
|
|
@@ -9506,12 +9668,13 @@ function Editable2({
|
|
|
9506
9668
|
markdown,
|
|
9507
9669
|
children: editor.children
|
|
9508
9670
|
};
|
|
9509
|
-
|
|
9671
|
+
onChangeRef.current(markdown);
|
|
9510
9672
|
},
|
|
9511
9673
|
throttleInMs,
|
|
9512
9674
|
{ leading: false, trailing: true }
|
|
9513
9675
|
),
|
|
9514
|
-
|
|
9676
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
9677
|
+
[editor, throttleInMs]
|
|
9515
9678
|
);
|
|
9516
9679
|
const onSlateChange = useCallback18(() => {
|
|
9517
9680
|
if (prevValueRef.current === editor.children) {
|