@shadow-garden/bapbong-model 0.11.2 → 0.12.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/index.cjs +48 -14
- package/dist/index.js +48 -14
- package/dist/lib/model.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -102,6 +102,7 @@ function pastedImageAttrs(el) {
|
|
|
102
102
|
return {
|
|
103
103
|
src,
|
|
104
104
|
alt: e.getAttribute("alt") ?? "",
|
|
105
|
+
title: e.getAttribute("title"),
|
|
105
106
|
width: dim(e.getAttribute("width")),
|
|
106
107
|
height: dim(e.getAttribute("height")),
|
|
107
108
|
crop: dataJson(el, "data-crop"),
|
|
@@ -148,6 +149,11 @@ var schema = new import_prosemirror_model.Schema({
|
|
|
148
149
|
// body w:sectPr. Edited via setDocAttribute (page-setup commands) so
|
|
149
150
|
// orientation/paper-size changes undo cleanly. null → A4 default.
|
|
150
151
|
page: { default: null },
|
|
152
|
+
// DocCompat (contracts) — the Word compatibility profile settings.xml
|
|
153
|
+
// declares (compatibilityMode + the compat flags), resolved to the
|
|
154
|
+
// answers layout rules ask. Importer-set on every story doc; null
|
|
155
|
+
// (an editor-authored doc) reads as current Word.
|
|
156
|
+
compat: { default: null },
|
|
151
157
|
// CommentNode[] (contracts) — comment threads keyed to `comment` marks.
|
|
152
158
|
// Edited via setDocAttribute so add/reply/resolve/delete undo cleanly.
|
|
153
159
|
comments: { default: null },
|
|
@@ -223,10 +229,12 @@ var schema = new import_prosemirror_model.Schema({
|
|
|
223
229
|
shading: { default: null },
|
|
224
230
|
// The paragraph MARK's own font ({ family?, sizePt?, bold?, italic? }
|
|
225
231
|
// or null) — w:pPr/w:rPr resolved through the same cascade a run gets.
|
|
226
|
-
//
|
|
227
|
-
//
|
|
228
|
-
//
|
|
229
|
-
//
|
|
232
|
+
// The mark is a glyph on the paragraph's LAST line (the only glyph
|
|
233
|
+
// when the paragraph is empty), so it takes part in that line's
|
|
234
|
+
// height. Importer-set on every paragraph; the font commands edit it
|
|
235
|
+
// when the selection takes the mark in (Word: a ¶ inside the
|
|
236
|
+
// selection is re-sized with the text); the exporter writes it back
|
|
237
|
+
// into w:pPr/w:rPr ahead of `carry.markRPr` (the rest of that rPr).
|
|
230
238
|
markFont: { default: null },
|
|
231
239
|
// Carry-through fidelity (docx round-trip): OOXML paragraph
|
|
232
240
|
// properties the model does NOT represent, preserved verbatim so a
|
|
@@ -293,6 +301,9 @@ var schema = new import_prosemirror_model.Schema({
|
|
|
293
301
|
attrs: {
|
|
294
302
|
src: {},
|
|
295
303
|
alt: { default: "" },
|
|
304
|
+
// wp:docPr @title — the "Title" field of Word's alt-text pane, kept
|
|
305
|
+
// separate from `alt` (@descr) so both round-trip verbatim.
|
|
306
|
+
title: { default: null },
|
|
296
307
|
width: { default: null },
|
|
297
308
|
height: { default: null },
|
|
298
309
|
// wp:anchor (floating image): { wrap: 'square'|'topAndBottom'|'none',
|
|
@@ -316,7 +327,10 @@ var schema = new import_prosemirror_model.Schema({
|
|
|
316
327
|
// keeps its size; the selected region scales to fill it.
|
|
317
328
|
crop: { default: null },
|
|
318
329
|
// a:ln on pic:spPr — Word's picture border, as a BorderSide, or null.
|
|
319
|
-
outline: { default: null }
|
|
330
|
+
outline: { default: null },
|
|
331
|
+
// a:solidFill on pic:spPr — "#RRGGBB" painted behind the bitmap
|
|
332
|
+
// (shows through transparency), or null.
|
|
333
|
+
background: { default: null }
|
|
320
334
|
},
|
|
321
335
|
parseDOM: [{ tag: "img[src]", getAttrs: pastedImageAttrs }],
|
|
322
336
|
toDOM(node) {
|
|
@@ -325,10 +339,13 @@ var schema = new import_prosemirror_model.Schema({
|
|
|
325
339
|
src: a["src"],
|
|
326
340
|
alt: a["alt"]
|
|
327
341
|
};
|
|
342
|
+
if (a["title"]) attrs["title"] = a["title"];
|
|
328
343
|
if (a["width"] != null) attrs["width"] = String(a["width"]);
|
|
329
344
|
if (a["height"] != null) attrs["height"] = String(a["height"]);
|
|
330
345
|
if (a["crop"]) attrs["data-crop"] = JSON.stringify(a["crop"]);
|
|
331
346
|
if (a["outline"]) attrs["data-outline"] = JSON.stringify(a["outline"]);
|
|
347
|
+
if (a["background"])
|
|
348
|
+
attrs["data-background"] = a["background"];
|
|
332
349
|
return ["img", attrs];
|
|
333
350
|
}
|
|
334
351
|
},
|
|
@@ -361,6 +378,11 @@ var schema = new import_prosemirror_model.Schema({
|
|
|
361
378
|
borders: { default: null },
|
|
362
379
|
// w:tblPr/w:jc — 'center' | 'right' table alignment, or null (left).
|
|
363
380
|
align: { default: null },
|
|
381
|
+
// w:tblInd resolved to px: where a left-aligned table's leading
|
|
382
|
+
// border sits relative to the text margin (compat-mode aware — see
|
|
383
|
+
// the importer). null = Word's implicit outdent by the left cell
|
|
384
|
+
// margin. Importer-set; the element itself rides carry for export.
|
|
385
|
+
indent: { default: null },
|
|
364
386
|
// Carry-through fidelity: unmodelled w:tblPr children (tblStyle,
|
|
365
387
|
// tblLayout, tblLook, tblInd, floating tblpPr, …) as one raw XML
|
|
366
388
|
// string ({ tblPr: string }), or null. Importer-set; the exporter
|
|
@@ -377,6 +399,7 @@ var schema = new import_prosemirror_model.Schema({
|
|
|
377
399
|
borders: dataJson(el, "data-borders"),
|
|
378
400
|
cellPadding: dataJson(el, "data-cell-padding"),
|
|
379
401
|
align: el.getAttribute("data-align"),
|
|
402
|
+
indent: dataJson(el, "data-indent"),
|
|
380
403
|
carry: dataJson(el, "data-carry")
|
|
381
404
|
})
|
|
382
405
|
}
|
|
@@ -388,6 +411,7 @@ var schema = new import_prosemirror_model.Schema({
|
|
|
388
411
|
if (a["cellPadding"])
|
|
389
412
|
dom["data-cell-padding"] = JSON.stringify(a["cellPadding"]);
|
|
390
413
|
if (a["align"]) dom["data-align"] = String(a["align"]);
|
|
414
|
+
if (a["indent"] != null) dom["data-indent"] = String(a["indent"]);
|
|
391
415
|
if (a["carry"]) dom["data-carry"] = JSON.stringify(a["carry"]);
|
|
392
416
|
return ["table", dom, ["tbody", 0]];
|
|
393
417
|
}
|
|
@@ -713,27 +737,37 @@ var schema = new import_prosemirror_model.Schema({
|
|
|
713
737
|
},
|
|
714
738
|
// w:footnoteReference — the carrier text is the superscript number; `num`
|
|
715
739
|
// lets the layout engine match the reference to its page-bottom body.
|
|
740
|
+
// `id` is the ORIGINAL w:id from footnotes.xml: that part is carried
|
|
741
|
+
// byte-for-byte on save, so the exported reference must point at the
|
|
742
|
+
// source id, not the display number (Word reserves -1/0 and reuses ids
|
|
743
|
+
// freely — they rarely equal 1..N in document order).
|
|
716
744
|
footnote: {
|
|
717
|
-
attrs: { num: {} },
|
|
745
|
+
attrs: { num: {}, id: { default: null } },
|
|
718
746
|
inclusive: false,
|
|
719
747
|
parseDOM: [
|
|
720
748
|
{
|
|
721
749
|
tag: "sup[data-footnote]",
|
|
722
750
|
// `el` is an HTMLElement at runtime; this package has no DOM lib, so
|
|
723
751
|
// narrow structurally rather than naming the type.
|
|
724
|
-
getAttrs: (el) =>
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
752
|
+
getAttrs: (el) => {
|
|
753
|
+
const get = (n) => el.getAttribute(
|
|
754
|
+
n
|
|
755
|
+
);
|
|
756
|
+
return {
|
|
757
|
+
num: Number(get("data-footnote")) || 0,
|
|
758
|
+
id: get("data-footnote-id")
|
|
759
|
+
};
|
|
760
|
+
}
|
|
731
761
|
}
|
|
732
762
|
],
|
|
733
763
|
toDOM(mark) {
|
|
764
|
+
const id = mark.attrs["id"];
|
|
734
765
|
return [
|
|
735
766
|
"sup",
|
|
736
|
-
{
|
|
767
|
+
{
|
|
768
|
+
"data-footnote": String(mark.attrs["num"]),
|
|
769
|
+
...id != null ? { "data-footnote-id": id } : {}
|
|
770
|
+
},
|
|
737
771
|
0
|
|
738
772
|
];
|
|
739
773
|
}
|
package/dist/index.js
CHANGED
|
@@ -70,6 +70,7 @@ function pastedImageAttrs(el) {
|
|
|
70
70
|
return {
|
|
71
71
|
src,
|
|
72
72
|
alt: e.getAttribute("alt") ?? "",
|
|
73
|
+
title: e.getAttribute("title"),
|
|
73
74
|
width: dim(e.getAttribute("width")),
|
|
74
75
|
height: dim(e.getAttribute("height")),
|
|
75
76
|
crop: dataJson(el, "data-crop"),
|
|
@@ -116,6 +117,11 @@ var schema = new Schema({
|
|
|
116
117
|
// body w:sectPr. Edited via setDocAttribute (page-setup commands) so
|
|
117
118
|
// orientation/paper-size changes undo cleanly. null → A4 default.
|
|
118
119
|
page: { default: null },
|
|
120
|
+
// DocCompat (contracts) — the Word compatibility profile settings.xml
|
|
121
|
+
// declares (compatibilityMode + the compat flags), resolved to the
|
|
122
|
+
// answers layout rules ask. Importer-set on every story doc; null
|
|
123
|
+
// (an editor-authored doc) reads as current Word.
|
|
124
|
+
compat: { default: null },
|
|
119
125
|
// CommentNode[] (contracts) — comment threads keyed to `comment` marks.
|
|
120
126
|
// Edited via setDocAttribute so add/reply/resolve/delete undo cleanly.
|
|
121
127
|
comments: { default: null },
|
|
@@ -191,10 +197,12 @@ var schema = new Schema({
|
|
|
191
197
|
shading: { default: null },
|
|
192
198
|
// The paragraph MARK's own font ({ family?, sizePt?, bold?, italic? }
|
|
193
199
|
// or null) — w:pPr/w:rPr resolved through the same cascade a run gets.
|
|
194
|
-
//
|
|
195
|
-
//
|
|
196
|
-
//
|
|
197
|
-
//
|
|
200
|
+
// The mark is a glyph on the paragraph's LAST line (the only glyph
|
|
201
|
+
// when the paragraph is empty), so it takes part in that line's
|
|
202
|
+
// height. Importer-set on every paragraph; the font commands edit it
|
|
203
|
+
// when the selection takes the mark in (Word: a ¶ inside the
|
|
204
|
+
// selection is re-sized with the text); the exporter writes it back
|
|
205
|
+
// into w:pPr/w:rPr ahead of `carry.markRPr` (the rest of that rPr).
|
|
198
206
|
markFont: { default: null },
|
|
199
207
|
// Carry-through fidelity (docx round-trip): OOXML paragraph
|
|
200
208
|
// properties the model does NOT represent, preserved verbatim so a
|
|
@@ -261,6 +269,9 @@ var schema = new Schema({
|
|
|
261
269
|
attrs: {
|
|
262
270
|
src: {},
|
|
263
271
|
alt: { default: "" },
|
|
272
|
+
// wp:docPr @title — the "Title" field of Word's alt-text pane, kept
|
|
273
|
+
// separate from `alt` (@descr) so both round-trip verbatim.
|
|
274
|
+
title: { default: null },
|
|
264
275
|
width: { default: null },
|
|
265
276
|
height: { default: null },
|
|
266
277
|
// wp:anchor (floating image): { wrap: 'square'|'topAndBottom'|'none',
|
|
@@ -284,7 +295,10 @@ var schema = new Schema({
|
|
|
284
295
|
// keeps its size; the selected region scales to fill it.
|
|
285
296
|
crop: { default: null },
|
|
286
297
|
// a:ln on pic:spPr — Word's picture border, as a BorderSide, or null.
|
|
287
|
-
outline: { default: null }
|
|
298
|
+
outline: { default: null },
|
|
299
|
+
// a:solidFill on pic:spPr — "#RRGGBB" painted behind the bitmap
|
|
300
|
+
// (shows through transparency), or null.
|
|
301
|
+
background: { default: null }
|
|
288
302
|
},
|
|
289
303
|
parseDOM: [{ tag: "img[src]", getAttrs: pastedImageAttrs }],
|
|
290
304
|
toDOM(node) {
|
|
@@ -293,10 +307,13 @@ var schema = new Schema({
|
|
|
293
307
|
src: a["src"],
|
|
294
308
|
alt: a["alt"]
|
|
295
309
|
};
|
|
310
|
+
if (a["title"]) attrs["title"] = a["title"];
|
|
296
311
|
if (a["width"] != null) attrs["width"] = String(a["width"]);
|
|
297
312
|
if (a["height"] != null) attrs["height"] = String(a["height"]);
|
|
298
313
|
if (a["crop"]) attrs["data-crop"] = JSON.stringify(a["crop"]);
|
|
299
314
|
if (a["outline"]) attrs["data-outline"] = JSON.stringify(a["outline"]);
|
|
315
|
+
if (a["background"])
|
|
316
|
+
attrs["data-background"] = a["background"];
|
|
300
317
|
return ["img", attrs];
|
|
301
318
|
}
|
|
302
319
|
},
|
|
@@ -329,6 +346,11 @@ var schema = new Schema({
|
|
|
329
346
|
borders: { default: null },
|
|
330
347
|
// w:tblPr/w:jc — 'center' | 'right' table alignment, or null (left).
|
|
331
348
|
align: { default: null },
|
|
349
|
+
// w:tblInd resolved to px: where a left-aligned table's leading
|
|
350
|
+
// border sits relative to the text margin (compat-mode aware — see
|
|
351
|
+
// the importer). null = Word's implicit outdent by the left cell
|
|
352
|
+
// margin. Importer-set; the element itself rides carry for export.
|
|
353
|
+
indent: { default: null },
|
|
332
354
|
// Carry-through fidelity: unmodelled w:tblPr children (tblStyle,
|
|
333
355
|
// tblLayout, tblLook, tblInd, floating tblpPr, …) as one raw XML
|
|
334
356
|
// string ({ tblPr: string }), or null. Importer-set; the exporter
|
|
@@ -345,6 +367,7 @@ var schema = new Schema({
|
|
|
345
367
|
borders: dataJson(el, "data-borders"),
|
|
346
368
|
cellPadding: dataJson(el, "data-cell-padding"),
|
|
347
369
|
align: el.getAttribute("data-align"),
|
|
370
|
+
indent: dataJson(el, "data-indent"),
|
|
348
371
|
carry: dataJson(el, "data-carry")
|
|
349
372
|
})
|
|
350
373
|
}
|
|
@@ -356,6 +379,7 @@ var schema = new Schema({
|
|
|
356
379
|
if (a["cellPadding"])
|
|
357
380
|
dom["data-cell-padding"] = JSON.stringify(a["cellPadding"]);
|
|
358
381
|
if (a["align"]) dom["data-align"] = String(a["align"]);
|
|
382
|
+
if (a["indent"] != null) dom["data-indent"] = String(a["indent"]);
|
|
359
383
|
if (a["carry"]) dom["data-carry"] = JSON.stringify(a["carry"]);
|
|
360
384
|
return ["table", dom, ["tbody", 0]];
|
|
361
385
|
}
|
|
@@ -681,27 +705,37 @@ var schema = new Schema({
|
|
|
681
705
|
},
|
|
682
706
|
// w:footnoteReference — the carrier text is the superscript number; `num`
|
|
683
707
|
// lets the layout engine match the reference to its page-bottom body.
|
|
708
|
+
// `id` is the ORIGINAL w:id from footnotes.xml: that part is carried
|
|
709
|
+
// byte-for-byte on save, so the exported reference must point at the
|
|
710
|
+
// source id, not the display number (Word reserves -1/0 and reuses ids
|
|
711
|
+
// freely — they rarely equal 1..N in document order).
|
|
684
712
|
footnote: {
|
|
685
|
-
attrs: { num: {} },
|
|
713
|
+
attrs: { num: {}, id: { default: null } },
|
|
686
714
|
inclusive: false,
|
|
687
715
|
parseDOM: [
|
|
688
716
|
{
|
|
689
717
|
tag: "sup[data-footnote]",
|
|
690
718
|
// `el` is an HTMLElement at runtime; this package has no DOM lib, so
|
|
691
719
|
// narrow structurally rather than naming the type.
|
|
692
|
-
getAttrs: (el) =>
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
720
|
+
getAttrs: (el) => {
|
|
721
|
+
const get = (n) => el.getAttribute(
|
|
722
|
+
n
|
|
723
|
+
);
|
|
724
|
+
return {
|
|
725
|
+
num: Number(get("data-footnote")) || 0,
|
|
726
|
+
id: get("data-footnote-id")
|
|
727
|
+
};
|
|
728
|
+
}
|
|
699
729
|
}
|
|
700
730
|
],
|
|
701
731
|
toDOM(mark) {
|
|
732
|
+
const id = mark.attrs["id"];
|
|
702
733
|
return [
|
|
703
734
|
"sup",
|
|
704
|
-
{
|
|
735
|
+
{
|
|
736
|
+
"data-footnote": String(mark.attrs["num"]),
|
|
737
|
+
...id != null ? { "data-footnote-id": id } : {}
|
|
738
|
+
},
|
|
705
739
|
0
|
|
706
740
|
];
|
|
707
741
|
}
|
package/dist/lib/model.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/lib/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/lib/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AA0F3C;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM,yWAwqBjB,CAAC;AAEH,wEAAwE;AACxE,MAAM,MAAM,aAAa,GAAG,OAAO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