@pie-element/simple-cloze 0.1.7-next.20261007075859 → 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/dist/author/index.js +64 -19
- package/dist/author/index.js.map +1 -1
- package/dist/browser/author/index.js +1039 -1010
- package/dist/browser/author/index.js.map +1 -1
- package/dist/browser/delivery/index.js +1 -1
- package/dist/browser/editor-runtime/author/index.js +121 -92
- package/dist/browser/editor-runtime/author/index.js.map +1 -1
- package/dist/browser/editor-runtime/delivery/index.js +1 -1
- package/dist/browser/editor-runtime/{i18n-4_33nRWl.js → i18n-CXqnW0mV.js} +1201 -685
- package/dist/browser/editor-runtime/i18n-CXqnW0mV.js.map +1 -0
- package/dist/browser/{mathjax-BKrHE4xs-55Y8WgRM.js → editor-runtime/mathjax-BKrHE4xs-BTRY2LLA.js} +2 -2
- package/dist/browser/editor-runtime/{mathjax-BKrHE4xs-55Y8WgRM.js.map → mathjax-BKrHE4xs-BTRY2LLA.js.map} +1 -1
- package/dist/browser/editor-runtime/print/index.js +1 -1
- package/dist/browser/{i18n-4_33nRWl.js → i18n-CXqnW0mV.js} +1201 -685
- package/dist/browser/i18n-CXqnW0mV.js.map +1 -0
- package/dist/browser/{editor-runtime/mathjax-BKrHE4xs-55Y8WgRM.js → mathjax-BKrHE4xs-BTRY2LLA.js} +2 -2
- package/dist/browser/{mathjax-BKrHE4xs-55Y8WgRM.js.map → mathjax-BKrHE4xs-BTRY2LLA.js.map} +1 -1
- package/dist/browser/print/index.js +1 -1
- package/dist/delivery/index.js +837 -300
- package/dist/delivery/index.js.map +1 -1
- package/dist/index.iife.js +21 -21
- package/dist/print/index.js +837 -300
- package/dist/print/index.js.map +1 -1
- package/module/print.js +1425 -909
- package/module/print.js.map +1 -1
- package/package.json +4 -4
- package/dist/browser/editor-runtime/i18n-4_33nRWl.js.map +0 -1
- package/dist/browser/i18n-4_33nRWl.js.map +0 -1
package/dist/author/index.js
CHANGED
|
@@ -23375,13 +23375,26 @@ var PASTED_FORMATTING = [
|
|
|
23375
23375
|
"subscript",
|
|
23376
23376
|
"bulletList",
|
|
23377
23377
|
"orderedList",
|
|
23378
|
-
"table"
|
|
23378
|
+
"table",
|
|
23379
|
+
"image"
|
|
23379
23380
|
];
|
|
23380
23381
|
var hasImageFile = (data) => Array.from(data.items ?? []).some((item) => item.kind === "file" && item.type.startsWith("image/"));
|
|
23381
23382
|
var hasElement = (html, selector) => new DOMParser().parseFromString(html, "text/html").querySelector(selector) !== null;
|
|
23382
23383
|
var isProseMirrorSlice = (html) => html.includes("data-pm-slice") && hasElement(html, "[data-pm-slice]");
|
|
23383
23384
|
var hasMath = (html) => /data-latex|data-type="?mathml/.test(html) && hasElement(html, "[data-latex], [data-type=\"mathml\"]");
|
|
23384
23385
|
var filtering = null;
|
|
23386
|
+
var PICTURE = /^data:image\/(?:png|jpeg|gif|webp);base64,/i;
|
|
23387
|
+
var imageKey = () => `img-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
23388
|
+
/**
|
|
23389
|
+
* `html` with its pictures marked as image upload nodes, which parse from that mark alone. The
|
|
23390
|
+
* Image extension leaves out a data URL.
|
|
23391
|
+
*/
|
|
23392
|
+
function markPictures(html) {
|
|
23393
|
+
if (!html.includes("data:image/")) return html;
|
|
23394
|
+
const doc = new DOMParser().parseFromString(html, "text/html");
|
|
23395
|
+
for (const img of Array.from(doc.body.querySelectorAll("img"))) if (PICTURE.test(img.getAttribute("src") ?? "")) img.setAttribute("data-type", "image-upload-node");
|
|
23396
|
+
return doc.body.innerHTML;
|
|
23397
|
+
}
|
|
23385
23398
|
var escapeHtml = (text) => text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
23386
23399
|
var lines = (text) => text.replace(/\r*\n|\r/g, "\n").replace(/\n+$/, "");
|
|
23387
23400
|
var childrenOf = (node) => {
|
|
@@ -23449,13 +23462,14 @@ function externalContentOf(data) {
|
|
|
23449
23462
|
}
|
|
23450
23463
|
/**
|
|
23451
23464
|
* A parsed slice cut down to paragraphs, line breaks and math, plus the marks, lists and tables in
|
|
23452
|
-
* `kept
|
|
23453
|
-
*
|
|
23454
|
-
*
|
|
23465
|
+
* `kept` and, with `pictures`, the pictures markPictures marked. Attributes go, except an ordered
|
|
23466
|
+
* list's numbering, a cell's spans, a header cell's scope, a table's caption and a picture's size
|
|
23467
|
+
* and alt text. A list or table not kept becomes paragraphs, as a plain-text copy of it reads: an
|
|
23468
|
+
* item behind its bullet or number, a row with tabs between its cells.
|
|
23455
23469
|
*/
|
|
23456
|
-
var keepFormatting = (kept) => (slice, state) => {
|
|
23470
|
+
var keepFormatting = (kept, pictures = null) => (slice, state) => {
|
|
23457
23471
|
const { schema } = state;
|
|
23458
|
-
const { paragraph, hardBreak, math } = schema.nodes;
|
|
23472
|
+
const { paragraph, hardBreak, math, imageUploadNode } = schema.nodes;
|
|
23459
23473
|
const line = (content) => paragraph.create(null, content);
|
|
23460
23474
|
const keptMarks = (marks) => marks.filter((mark) => kept.has(mark.type.name)).map((mark) => mark.type.create());
|
|
23461
23475
|
const inline = (node) => childrenOf(node).flatMap((child) => {
|
|
@@ -23466,6 +23480,20 @@ var keepFormatting = (kept) => (slice, state) => {
|
|
|
23466
23480
|
if (child.type === hardBreak || math && child.type === math) return [child.mark(keptMarks(child.marks))];
|
|
23467
23481
|
return child.isLeaf ? [] : inline(child);
|
|
23468
23482
|
});
|
|
23483
|
+
const picture = (node) => {
|
|
23484
|
+
const { src, width, height, alt } = node.attrs;
|
|
23485
|
+
if (!pictures || !PICTURE.test(src ?? "")) return [];
|
|
23486
|
+
const nodeKey = imageKey();
|
|
23487
|
+
pictures.keys.push(nodeKey);
|
|
23488
|
+
return [node.type.create({
|
|
23489
|
+
src,
|
|
23490
|
+
width,
|
|
23491
|
+
height,
|
|
23492
|
+
alt,
|
|
23493
|
+
nodeKey,
|
|
23494
|
+
loaded: !pictures.upload
|
|
23495
|
+
})];
|
|
23496
|
+
};
|
|
23469
23497
|
const cellText = (cell) => {
|
|
23470
23498
|
const content = [];
|
|
23471
23499
|
cell.descendants((child) => {
|
|
@@ -23515,10 +23543,15 @@ var keepFormatting = (kept) => (slice, state) => {
|
|
|
23515
23543
|
}
|
|
23516
23544
|
return [...caption ? [line([schema.text(caption)])] : [], ...childrenOf(node).map((row) => line(childrenOf(row).flatMap((cell, i) => i ? [schema.text(" "), ...cellText(cell)] : cellText(cell))))];
|
|
23517
23545
|
};
|
|
23518
|
-
const
|
|
23546
|
+
const blank = (node) => /^\s+$/.test(node.textContent) && childrenOf(node).every((child) => child.isText);
|
|
23547
|
+
const isPicture = (node) => !!pictures && !!node && node.type === imageUploadNode;
|
|
23548
|
+
const blocks = (node) => childrenOf(node).flatMap((child, i, children) => {
|
|
23549
|
+
if (child.isTextblock && !child.content.size && (isPicture(children[i - 1]) || isPicture(children[i + 1]))) return [];
|
|
23550
|
+
if (child.isTextblock && blank(child)) return [line([schema.text(child.textContent)])];
|
|
23519
23551
|
if (child.isTextblock) return [line(inline(child))];
|
|
23520
23552
|
if (child.type.spec.tableRole === "table") return table(child);
|
|
23521
23553
|
if (child.type.name === "bulletList" || child.type.name === "orderedList") return list(child);
|
|
23554
|
+
if (isPicture(child)) return picture(child);
|
|
23522
23555
|
return child.isLeaf ? [] : blocks(child);
|
|
23523
23556
|
});
|
|
23524
23557
|
return openSlice(schema, slice.content.firstChild?.isInline ? [line(inline(slice.content))] : blocks(slice.content));
|
|
@@ -23567,7 +23600,7 @@ function pasteFiltered(view, html, filter) {
|
|
|
23567
23600
|
filtering = null;
|
|
23568
23601
|
}
|
|
23569
23602
|
}
|
|
23570
|
-
function insertExternal(view, { text, html }, settings) {
|
|
23603
|
+
function insertExternal(view, { text, html }, settings, uploadImage) {
|
|
23571
23604
|
const { selection, schema } = view.state;
|
|
23572
23605
|
const kept = new Set(settings.plainText ? [] : settings.formatting);
|
|
23573
23606
|
if ("$anchorCell" in selection && !(kept.has("table") && hasElement(html, "table"))) {
|
|
@@ -23576,7 +23609,13 @@ function insertExternal(view, { text, html }, settings) {
|
|
|
23576
23609
|
return;
|
|
23577
23610
|
}
|
|
23578
23611
|
if (!settings.plainText) {
|
|
23579
|
-
|
|
23612
|
+
const pictures = kept.has("image") && schema.nodes.imageUploadNode ? {
|
|
23613
|
+
keys: [],
|
|
23614
|
+
upload: !!uploadImage
|
|
23615
|
+
} : null;
|
|
23616
|
+
pasteFiltered(view, rebuildWordLists(pictures ? markPictures(html) : html), keepFormatting(kept, pictures));
|
|
23617
|
+
let uploads = Promise.resolve();
|
|
23618
|
+
for (const nodeKey of pictures?.keys ?? []) uploads = uploads.then(() => uploadImage?.(nodeKey));
|
|
23580
23619
|
return;
|
|
23581
23620
|
}
|
|
23582
23621
|
if (schema.nodes.math && hasMath(html)) {
|
|
@@ -23591,9 +23630,10 @@ function insertExternal(view, { text, html }, settings) {
|
|
|
23591
23630
|
* superscript, subscript, lists and tables in `formatting`. Its fonts, sizes, colours, alignment,
|
|
23592
23631
|
* headings, links and class names go, which TextStyleKit, TextAlign and CSSMark would otherwise keep
|
|
23593
23632
|
* (PIE-1145). Word for Windows and Mac copies lists as styled paragraphs, which are rebuilt as
|
|
23594
|
-
* lists first.
|
|
23595
|
-
*
|
|
23596
|
-
* the
|
|
23633
|
+
* lists first. Word's pictures paste as image upload nodes when `formatting` has `image`, and
|
|
23634
|
+
* upload through `uploadImage`. With `plainText` set it pastes plain text. Copies from a PIE editor
|
|
23635
|
+
* and pasted image files are left to ProseMirror and the image upload handler. This editor has no
|
|
23636
|
+
* math node or image upload node, so the React editor's math and picture handling never runs here.
|
|
23597
23637
|
*
|
|
23598
23638
|
* Mirrors `packages/lib-react/editable-html-tip-tap/src/external-paste.ts`.
|
|
23599
23639
|
*/
|
|
@@ -23601,13 +23641,18 @@ var ExternalPaste = Extension.create({
|
|
|
23601
23641
|
name: "externalPaste",
|
|
23602
23642
|
priority: 1e3,
|
|
23603
23643
|
addOptions() {
|
|
23604
|
-
return {
|
|
23605
|
-
|
|
23606
|
-
|
|
23607
|
-
|
|
23644
|
+
return {
|
|
23645
|
+
settings: () => ({
|
|
23646
|
+
plainText: false,
|
|
23647
|
+
formatting: PASTED_FORMATTING
|
|
23648
|
+
}),
|
|
23649
|
+
uploadImage: void 0
|
|
23650
|
+
};
|
|
23608
23651
|
},
|
|
23609
23652
|
addProseMirrorPlugins() {
|
|
23610
|
-
const { settings } = this.options;
|
|
23653
|
+
const { settings, uploadImage } = this.options;
|
|
23654
|
+
const { editor } = this;
|
|
23655
|
+
const upload = uploadImage ? (nodeKey) => uploadImage(editor, nodeKey) : null;
|
|
23611
23656
|
return [new Plugin({
|
|
23612
23657
|
key: new PluginKey("externalPaste"),
|
|
23613
23658
|
props: {
|
|
@@ -23617,7 +23662,7 @@ var ExternalPaste = Extension.create({
|
|
|
23617
23662
|
handlePaste(view, event) {
|
|
23618
23663
|
const content = externalContentOf(event.clipboardData);
|
|
23619
23664
|
if (content === null) return false;
|
|
23620
|
-
insertExternal(view, content, settings());
|
|
23665
|
+
insertExternal(view, content, settings(), upload);
|
|
23621
23666
|
return true;
|
|
23622
23667
|
},
|
|
23623
23668
|
handleDrop(view, event) {
|
|
@@ -23628,7 +23673,7 @@ var ExternalPaste = Extension.create({
|
|
|
23628
23673
|
});
|
|
23629
23674
|
if (content === null || !target) return false;
|
|
23630
23675
|
view.dispatch(view.state.tr.setSelection(TextSelection.near(view.state.doc.resolve(target.pos))));
|
|
23631
|
-
insertExternal(view, content, settings());
|
|
23676
|
+
insertExternal(view, content, settings(), upload);
|
|
23632
23677
|
view.focus();
|
|
23633
23678
|
return true;
|
|
23634
23679
|
}
|