@stll/folio-core 0.40.0 → 0.41.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.
Files changed (47) hide show
  1. package/dist/ai-edits/clean-text.d.ts +28 -6
  2. package/dist/ai-edits/clean-text.js +28 -13
  3. package/dist/ai-edits/headless.d.ts +12 -0
  4. package/dist/ai-edits/headless.js +26 -3
  5. package/dist/ai-edits/snapshot.d.ts +6 -1
  6. package/dist/ai-edits/snapshot.js +15 -10
  7. package/dist/ai-suggestions/text-positions.js +15 -3
  8. package/dist/compare/inline-atoms.js +2 -2
  9. package/dist/compat/eigenpal.d.ts +3 -2
  10. package/dist/compat/eigenpal.js +2 -1
  11. package/dist/display-list/primitives.d.ts +2 -1
  12. package/dist/document-operations.d.ts +3 -2
  13. package/dist/docx/blockPlainText.d.ts +8 -0
  14. package/dist/docx/blockPlainText.js +40 -0
  15. package/dist/docx/compatibility.d.ts +16 -2
  16. package/dist/docx/compatibility.js +30 -9
  17. package/dist/docx/footnoteParser.js +4 -23
  18. package/dist/docx/graphicFrameLocks.d.ts +22 -0
  19. package/dist/docx/graphicFrameLocks.js +55 -0
  20. package/dist/docx/groupDrawingParser.d.ts +7 -1
  21. package/dist/docx/groupDrawingParser.js +11 -2
  22. package/dist/docx/headerFooterParser.d.ts +5 -1
  23. package/dist/docx/headerFooterParser.js +7 -21
  24. package/dist/docx/imageParser.js +5 -0
  25. package/dist/docx/imageRawXml.d.ts +33 -1
  26. package/dist/docx/imageRawXml.js +56 -1
  27. package/dist/docx/runParser.js +43 -21
  28. package/dist/docx/serializer/runSerializer.js +4 -2
  29. package/dist/docx/server/createBilingualDocument.js +31 -5
  30. package/dist/docx/shapeParser.js +32 -6
  31. package/dist/docx/vmlImageParser.d.ts +11 -1
  32. package/dist/docx/vmlImageParser.js +29 -2
  33. package/dist/index.d.ts +3 -2
  34. package/dist/index.js +2 -1
  35. package/dist/internal/compare/inline-presentation.d.ts +11 -3
  36. package/dist/internal/compare/inline-presentation.js +8 -1
  37. package/dist/prosemirror/attrs/index.js +33 -3
  38. package/dist/prosemirror/conversion/fromProseDoc.d.ts +13 -2
  39. package/dist/prosemirror/conversion/fromProseDoc.js +80 -27
  40. package/dist/prosemirror/conversion/index.d.ts +2 -2
  41. package/dist/prosemirror/conversion/toProseDoc.js +10 -2
  42. package/dist/prosemirror/extensions/nodes/ImageExtension.js +6 -0
  43. package/dist/prosemirror/imageCommit.js +7 -3
  44. package/dist/prosemirror/runFormattingInlineCarriers.d.ts +16 -1
  45. package/dist/prosemirror/runFormattingInlineCarriers.js +20 -1
  46. package/dist/prosemirror/schema/nodes.d.ts +20 -0
  47. package/package.json +2 -2
@@ -1,5 +1,5 @@
1
+ import { allowsDirectDrawingEdit } from "../docx/imageRawXml.js";
1
2
  import { expectImageAttrs, mergeImageAttrs } from "./attrs/index.js";
2
- import { DRAWING_RAW_XML_MODES } from "@stll/docx-core/model";
3
3
  //#region src/prosemirror/imageCommit.ts
4
4
  const MIN_IMAGE_PX = 20;
5
5
  const MAX_IMAGE_PX = 2e3;
@@ -38,11 +38,15 @@ function isFloatingImage(node) {
38
38
  "through"
39
39
  ].includes(wrapType) : false);
40
40
  }
41
- /** Resolve the image node at `pmPos`, or null if it isn't an image. */
41
+ /**
42
+ * Resolve the image node at `pmPos`, or null if it isn't an image or is one
43
+ * whose raw XML says more than the model does. Refusing the node leaves the
44
+ * rest of the document editable.
45
+ */
42
46
  function imageNodeAt(view, pmPos) {
43
47
  const node = view.state.doc.nodeAt(pmPos);
44
48
  if (!node || node.type.name !== "image") return null;
45
- if (expectImageAttrs(node)._docxRawXmlMode === DRAWING_RAW_XML_MODES.PRESERVE_ONLY) return null;
49
+ if (!allowsDirectDrawingEdit(expectImageAttrs(node)._docxRawXmlMode)) return null;
46
50
  return node;
47
51
  }
48
52
  /**
@@ -26,6 +26,21 @@ declare const RUN_FORMATTING_INLINE_ATOM_DISPOSITIONS: Readonly<{
26
26
  readonly textBoxAnchor: "not-a-run";
27
27
  }>;
28
28
  declare const runFormattingInlineControlCharacter: (node: Node) => string | null;
29
+ /**
30
+ * Text an inline atom contributes to a flattened, reader-facing projection.
31
+ *
32
+ * A control-character carrier contributes its character; a field contributes its
33
+ * authored result, so a cross-reference reads as the text Word shows instead of
34
+ * vanishing. A field with no result contributes nothing: the placeholder
35
+ * `getFieldVisibleText` paints for the editor is a rendering decision, not
36
+ * document text, and one of its branches is the current date.
37
+ */
38
+ declare const runFormattingInlineAtomCleanText: (node: Node) => string | null;
39
+ /**
40
+ * Document text an inline atom contributes, as opposed to a control character:
41
+ * today a field's authored result.
42
+ */
43
+ declare const runFormattingInlineAtomResultText: (node: Node) => string | null;
29
44
  declare const runFormattingInlineControlNodeName: (character: string) => string | null;
30
45
  declare const runFormattingInlineAtomDisposition: (node: Node) => RunFormattingInlineAtomDisposition | null;
31
46
  type RunFormattingCarrierRepresentation = {
@@ -74,4 +89,4 @@ declare const selectRunFormattingCarrierRepresentations: ({ doc, from, to }: Sel
74
89
  /** Deterministic visible text for one logical formatting revision carrier. */
75
90
  declare const runFormattingCarrierReviewText: (carrier: RunFormattingCarrier) => string;
76
91
  //#endregion
77
- export { RUN_FORMATTING_INLINE_ATOM_DISPOSITIONS, RunFormattingCarrier, RunFormattingCarrierRepresentation, RunFormattingInlineAtomDisposition, SelectedRunFormattingCarrierRepresentation, applyMarksToRunFormattingRepresentation, expandRunFormattingCarrier, runFormattingCarrierReviewText, runFormattingInlineAtomDisposition, runFormattingInlineControlCharacter, runFormattingInlineControlNodeName, selectRunFormattingCarrierRepresentations };
92
+ export { RUN_FORMATTING_INLINE_ATOM_DISPOSITIONS, RunFormattingCarrier, RunFormattingCarrierRepresentation, RunFormattingInlineAtomDisposition, SelectedRunFormattingCarrierRepresentation, applyMarksToRunFormattingRepresentation, expandRunFormattingCarrier, runFormattingCarrierReviewText, runFormattingInlineAtomCleanText, runFormattingInlineAtomDisposition, runFormattingInlineAtomResultText, runFormattingInlineControlCharacter, runFormattingInlineControlNodeName, selectRunFormattingCarrierRepresentations };
@@ -42,6 +42,25 @@ const runFormattingInlineControlCharacter = (node) => {
42
42
  if (disposition === null) return null;
43
43
  return CONTROL_CHARACTER_BY_DISPOSITION[disposition] ?? null;
44
44
  };
45
+ /**
46
+ * Text an inline atom contributes to a flattened, reader-facing projection.
47
+ *
48
+ * A control-character carrier contributes its character; a field contributes its
49
+ * authored result, so a cross-reference reads as the text Word shows instead of
50
+ * vanishing. A field with no result contributes nothing: the placeholder
51
+ * `getFieldVisibleText` paints for the editor is a rendering decision, not
52
+ * document text, and one of its branches is the current date.
53
+ */
54
+ const runFormattingInlineAtomCleanText = (node) => {
55
+ const disposition = runFormattingInlineAtomDisposition(node);
56
+ if (disposition === null) return null;
57
+ return runFormattingInlineAtomResultText(node) ?? CONTROL_CHARACTER_BY_DISPOSITION[disposition];
58
+ };
59
+ /**
60
+ * Document text an inline atom contributes, as opposed to a control character:
61
+ * today a field's authored result.
62
+ */
63
+ const runFormattingInlineAtomResultText = (node) => runFormattingInlineAtomDisposition(node) === "field-run" ? expectFieldAttrs(node).displayText ?? "" : null;
45
64
  const runFormattingInlineControlNodeName = (character) => {
46
65
  return Object.entries(RUN_FORMATTING_INLINE_ATOM_DISPOSITIONS).find(([, disposition]) => CONTROL_CHARACTER_BY_DISPOSITION[disposition] === character)?.[0] ?? null;
47
66
  };
@@ -148,4 +167,4 @@ const runFormattingCarrierReviewText = (carrier) => {
148
167
  }
149
168
  };
150
169
  //#endregion
151
- export { RUN_FORMATTING_INLINE_ATOM_DISPOSITIONS, applyMarksToRunFormattingRepresentation, expandRunFormattingCarrier, runFormattingCarrierReviewText, runFormattingInlineAtomDisposition, runFormattingInlineControlCharacter, runFormattingInlineControlNodeName, selectRunFormattingCarrierRepresentations };
170
+ export { RUN_FORMATTING_INLINE_ATOM_DISPOSITIONS, applyMarksToRunFormattingRepresentation, expandRunFormattingCarrier, runFormattingCarrierReviewText, runFormattingInlineAtomCleanText, runFormattingInlineAtomDisposition, runFormattingInlineAtomResultText, runFormattingInlineControlCharacter, runFormattingInlineControlNodeName, selectRunFormattingCarrierRepresentations };
@@ -292,10 +292,25 @@ type ImageAttrs = {
292
292
  cropRight?: number;
293
293
  cropBottom?: number;
294
294
  cropLeft?: number;
295
+ /**
296
+ * `wp:effectExtent` reservation, in EMU — not pixels like `dist*` above.
297
+ * Nothing renders it, and `emuToPixels` rounds (12700 EMU would land back
298
+ * as 9525), so the editor carries the authored units untouched.
299
+ */
300
+ paddingTop?: number;
301
+ paddingRight?: number;
302
+ paddingBottom?: number;
303
+ paddingLeft?: number;
295
304
  /** Position for floating images (horizontal and vertical alignment) */
296
305
  position?: ImagePositionAttrs;
297
306
  /** Use the containing table cell as the anchor's positioning scope (the OOXML default). */
298
307
  layoutInCell?: boolean;
308
+ /**
309
+ * Authored `a:graphicFrameLocks`. Carried through the editor so a resize,
310
+ * which forces the serializer to regenerate DrawingML, cannot silently
311
+ * relax a lock the author set.
312
+ */
313
+ frameLocks?: document_d_exports.ImageFrameLocks;
299
314
  /** Border width in pixels */
300
315
  borderWidth?: number;
301
316
  /** Border color as CSS color string */
@@ -312,6 +327,11 @@ type ImageAttrs = {
312
327
  _docxRawXml?: string;
313
328
  /** Raw XML preserved without an editable image projection. */
314
329
  _docxRawXmlMode?: document_d_exports.DrawingRawXmlMode;
330
+ /**
331
+ * The fingerprint captured with `_docxRawXml`. A preview-only drawing must
332
+ * compare against this rather than re-baseline on its own edited projection.
333
+ */
334
+ _docxRawImageFingerprint?: string;
315
335
  /** Embedded-object previews use their authored box as the exact line height. */
316
336
  _docxObjectPreview?: boolean;
317
337
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stll/folio-core",
3
- "version": "0.40.0",
3
+ "version": "0.41.0",
4
4
  "description": "Headless, framework-neutral core of folio: the OOXML (.docx) parser, document model, ProseMirror integration, and page-layout engine. No React.",
5
5
  "keywords": [
6
6
  "document-model",
@@ -121,7 +121,7 @@
121
121
  "perf": "bun scripts/profile-editor.ts"
122
122
  },
123
123
  "dependencies": {
124
- "@stll/docx-core": "^0.20.2",
124
+ "@stll/docx-core": "^0.21.0",
125
125
  "@stll/docx-utils": "^0.1.0",
126
126
  "@stll/template-conditions": ">=0.4.0 <1.0.0",
127
127
  "better-result": "3.0.1",