oasis-editor 0.0.44 → 0.0.46

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.
@@ -0,0 +1,17 @@
1
+ import { EditorTextStyle } from '../../../core/model.js';
2
+ import { DocContext } from '../docxTypes.js';
3
+
4
+ type NoteKind = "footnote" | "endnote";
5
+ /** The auto-numbered reference marker emitted inside a note body. */
6
+ export declare function serializeNoteRefMarker(kind: NoteKind): string;
7
+ /**
8
+ * Serializes a footnote/endnote reference run. Footnotes and endnotes share the
9
+ * exact same OOXML shape, so a single parameterized serializer handles both —
10
+ * `kind` selects the id map, reference style and `w:footnoteReference` /
11
+ * `w:endnoteReference` element (N1 dedup).
12
+ */
13
+ export declare function serializeNoteReference(kind: NoteKind, reference: {
14
+ noteId: string;
15
+ customMark?: string;
16
+ } | undefined, materializedRunStyle: EditorTextStyle | undefined, context: DocContext): string | null;
17
+ export {};
@@ -9,7 +9,7 @@ export interface ParsedFootnotes {
9
9
  byDocxId: Map<string, EditorFootnote>;
10
10
  /** Final shape ready to be assigned to `EditorDocument.footnotes`. */
11
11
  footnotes: EditorFootnotes;
12
- /** Imported "separator" part, if any (rarely useful for MVP rendering). */
12
+ /** Imported "separator" part, if any. */
13
13
  separator?: EditorBlockNode[];
14
14
  /** Imported "continuationSeparator" part, if any. */
15
15
  continuationSeparator?: EditorBlockNode[];
@@ -0,0 +1,33 @@
1
+ import { default as JSZip } from 'jszip';
2
+ import { EditorBlockNode, EditorNamedStyle } from '../../core/model.js';
3
+ import { AssetRegistry } from './assetRegistry.js';
4
+ import { DocxImportTheme } from './theme.js';
5
+ import { NumberingMaps } from './numbering.js';
6
+
7
+ /** Common body shape of a footnote/endnote (structurally identical). */
8
+ export interface DocxNoteBody {
9
+ id: string;
10
+ blocks: EditorBlockNode[];
11
+ docxId?: number;
12
+ }
13
+ export interface ParsedDocxNotes<TNote extends DocxNoteBody> {
14
+ /** Map from DOCX `w:id` (string) to the parsed note. */
15
+ byDocxId: Map<string, TNote>;
16
+ /** Final shape ready to be assigned to the document's notes slot. */
17
+ notes: {
18
+ items: Record<string, TNote>;
19
+ separator?: EditorBlockNode[];
20
+ continuationSeparator?: EditorBlockNode[];
21
+ };
22
+ /** Imported "separator" part, if any. */
23
+ separator?: EditorBlockNode[];
24
+ /** Imported "continuationSeparator" part, if any. */
25
+ continuationSeparator?: EditorBlockNode[];
26
+ }
27
+ /**
28
+ * Parses a DOCX `footnotes.xml` / `endnotes.xml` part into the editor note
29
+ * model. Footnotes and endnotes have byte-identical structure in OOXML, so a
30
+ * single parameterized parser handles both — `kind` selects the `w:footnote` /
31
+ * `w:endnote` element name and the imported-id prefix (N1 dedup).
32
+ */
33
+ export declare function parseDocxNotesXml<TNote extends DocxNoteBody>(kind: "footnote" | "endnote", xmlContent: string | null, numberingMaps: NumberingMaps, zip: JSZip, relsMap: Map<string, string>, assets: AssetRegistry, theme: DocxImportTheme, styles?: Record<string, EditorNamedStyle>): Promise<ParsedDocxNotes<TNote>>;
@@ -2483,7 +2483,7 @@ function OasisEditorAppLazy(props = {}) {
2483
2483
  onCleanup(() => {
2484
2484
  cancelled = true;
2485
2485
  });
2486
- import("./OasisEditorApp-Cu1s1H7A.js").then((m) => {
2486
+ import("./OasisEditorApp-ByWoTv0F.js").then((m) => {
2487
2487
  cancelled = true;
2488
2488
  setProgress(1);
2489
2489
  setTimeout(() => setApp(() => m.OasisEditorApp), 180);
@@ -34685,15 +34685,15 @@ async function parseHeaderFooterXml(xmlContent, numberingMaps, zip, relsMap, ass
34685
34685
  }
34686
34686
  return blocks;
34687
34687
  }
34688
- const SPECIAL_TYPES$1 = /* @__PURE__ */ new Set([
34688
+ const SPECIAL_TYPES = /* @__PURE__ */ new Set([
34689
34689
  "separator",
34690
34690
  "continuationSeparator",
34691
34691
  "continuationNotice"
34692
34692
  ]);
34693
- async function parseFootnotesXml(xmlContent, numberingMaps, zip, relsMap, assets, theme, styles) {
34693
+ async function parseDocxNotesXml(kind, xmlContent, numberingMaps, zip, relsMap, assets, theme, styles) {
34694
34694
  const empty = {
34695
34695
  byDocxId: /* @__PURE__ */ new Map(),
34696
- footnotes: { items: {} }
34696
+ notes: { items: {} }
34697
34697
  };
34698
34698
  if (!xmlContent) {
34699
34699
  return empty;
@@ -34707,7 +34707,7 @@ async function parseFootnotesXml(xmlContent, numberingMaps, zip, relsMap, assets
34707
34707
  const byDocxId = /* @__PURE__ */ new Map();
34708
34708
  let separator;
34709
34709
  let continuationSeparator;
34710
- const footnoteElements = getChildrenByTagNameNS(root, WORD_NS, "footnote");
34710
+ const noteElements = getChildrenByTagNameNS(root, WORD_NS, kind);
34711
34711
  let counter2 = 0;
34712
34712
  const parseNestedBlocks = createNestedBlockParser(
34713
34713
  numberingMaps,
@@ -34716,12 +34716,12 @@ async function parseFootnotesXml(xmlContent, numberingMaps, zip, relsMap, assets
34716
34716
  assets,
34717
34717
  theme
34718
34718
  );
34719
- for (const footnoteEl of footnoteElements) {
34720
- const idAttr = getAttributeValue(footnoteEl, "id") ?? "";
34721
- const type = getAttributeValue(footnoteEl, "type") ?? "";
34719
+ for (const noteEl of noteElements) {
34720
+ const idAttr = getAttributeValue(noteEl, "id") ?? "";
34721
+ const type = getAttributeValue(noteEl, "type") ?? "";
34722
34722
  const blocks = [];
34723
- for (let i = 0; i < footnoteEl.childNodes.length; i += 1) {
34724
- const node = footnoteEl.childNodes[i];
34723
+ for (let i = 0; i < noteEl.childNodes.length; i += 1) {
34724
+ const node = noteEl.childNodes[i];
34725
34725
  if ((node == null ? void 0 : node.nodeType) !== node.ELEMENT_NODE) continue;
34726
34726
  const element = node;
34727
34727
  if (element.namespaceURI !== WORD_NS) continue;
@@ -34752,7 +34752,7 @@ async function parseFootnotesXml(xmlContent, numberingMaps, zip, relsMap, assets
34752
34752
  );
34753
34753
  }
34754
34754
  }
34755
- if (SPECIAL_TYPES$1.has(type)) {
34755
+ if (SPECIAL_TYPES.has(type)) {
34756
34756
  if (type === "separator") separator = blocks;
34757
34757
  else if (type === "continuationSeparator") continuationSeparator = blocks;
34758
34758
  continue;
@@ -34761,126 +34761,59 @@ async function parseFootnotesXml(xmlContent, numberingMaps, zip, relsMap, assets
34761
34761
  continue;
34762
34762
  }
34763
34763
  counter2 += 1;
34764
- const localId = `footnote:imported:${counter2}`;
34764
+ const localId = `${kind}:imported:${counter2}`;
34765
34765
  const numericId = Number.parseInt(idAttr, 10);
34766
- const footnote = {
34766
+ const note = {
34767
34767
  id: localId,
34768
34768
  blocks: blocks.length > 0 ? blocks : [],
34769
34769
  docxId: Number.isFinite(numericId) ? numericId : void 0
34770
34770
  };
34771
- items[localId] = footnote;
34771
+ items[localId] = note;
34772
34772
  if (idAttr) {
34773
- byDocxId.set(idAttr, footnote);
34773
+ byDocxId.set(idAttr, note);
34774
34774
  }
34775
34775
  }
34776
34776
  return {
34777
34777
  byDocxId,
34778
- footnotes: {
34779
- items,
34780
- separator,
34781
- continuationSeparator
34782
- },
34778
+ notes: { items, separator, continuationSeparator },
34783
34779
  separator,
34784
34780
  continuationSeparator
34785
34781
  };
34786
34782
  }
34787
- const SPECIAL_TYPES = /* @__PURE__ */ new Set([
34788
- "separator",
34789
- "continuationSeparator",
34790
- "continuationNotice"
34791
- ]);
34792
- async function parseEndnotesXml(xmlContent, numberingMaps, zip, relsMap, assets, theme, styles) {
34793
- const empty = {
34794
- byDocxId: /* @__PURE__ */ new Map(),
34795
- endnotes: { items: {} }
34783
+ async function parseFootnotesXml(xmlContent, numberingMaps, zip, relsMap, assets, theme, styles) {
34784
+ const parsed = await parseDocxNotesXml(
34785
+ "footnote",
34786
+ xmlContent,
34787
+ numberingMaps,
34788
+ zip,
34789
+ relsMap,
34790
+ assets,
34791
+ theme,
34792
+ styles
34793
+ );
34794
+ return {
34795
+ byDocxId: parsed.byDocxId,
34796
+ footnotes: parsed.notes,
34797
+ separator: parsed.separator,
34798
+ continuationSeparator: parsed.continuationSeparator
34796
34799
  };
34797
- if (!xmlContent) {
34798
- return empty;
34799
- }
34800
- const doc = new DOMParser$1().parseFromString(xmlContent, "application/xml");
34801
- const root = doc.documentElement;
34802
- if (!root) {
34803
- return empty;
34804
- }
34805
- const items = {};
34806
- const byDocxId = /* @__PURE__ */ new Map();
34807
- let separator;
34808
- let continuationSeparator;
34809
- const endnoteElements = getChildrenByTagNameNS(root, WORD_NS, "endnote");
34810
- let counter2 = 0;
34811
- const parseNestedBlocks = createNestedBlockParser(
34800
+ }
34801
+ async function parseEndnotesXml(xmlContent, numberingMaps, zip, relsMap, assets, theme, styles) {
34802
+ const parsed = await parseDocxNotesXml(
34803
+ "endnote",
34804
+ xmlContent,
34812
34805
  numberingMaps,
34813
34806
  zip,
34814
34807
  relsMap,
34815
34808
  assets,
34816
- theme
34809
+ theme,
34810
+ styles
34817
34811
  );
34818
- for (const endnoteEl of endnoteElements) {
34819
- const idAttr = getAttributeValue(endnoteEl, "id") ?? "";
34820
- const type = getAttributeValue(endnoteEl, "type") ?? "";
34821
- const blocks = [];
34822
- for (let i = 0; i < endnoteEl.childNodes.length; i += 1) {
34823
- const node = endnoteEl.childNodes[i];
34824
- if ((node == null ? void 0 : node.nodeType) !== node.ELEMENT_NODE) continue;
34825
- const element = node;
34826
- if (element.namespaceURI !== WORD_NS) continue;
34827
- if (element.localName === "p") {
34828
- blocks.push(
34829
- await parseParagraphNode(
34830
- element,
34831
- numberingMaps,
34832
- zip,
34833
- relsMap,
34834
- assets,
34835
- theme,
34836
- parseNestedBlocks
34837
- )
34838
- );
34839
- } else if (element.localName === "tbl") {
34840
- blocks.push(
34841
- await parseTableNode(
34842
- element,
34843
- numberingMaps,
34844
- zip,
34845
- relsMap,
34846
- assets,
34847
- theme,
34848
- parseNestedBlocks,
34849
- styles
34850
- )
34851
- );
34852
- }
34853
- }
34854
- if (SPECIAL_TYPES.has(type)) {
34855
- if (type === "separator") separator = blocks;
34856
- else if (type === "continuationSeparator") continuationSeparator = blocks;
34857
- continue;
34858
- }
34859
- if ((idAttr === "-1" || idAttr === "0") && blocks.length === 0) {
34860
- continue;
34861
- }
34862
- counter2 += 1;
34863
- const localId = `endnote:imported:${counter2}`;
34864
- const numericId = Number.parseInt(idAttr, 10);
34865
- const endnote = {
34866
- id: localId,
34867
- blocks: blocks.length > 0 ? blocks : [],
34868
- docxId: Number.isFinite(numericId) ? numericId : void 0
34869
- };
34870
- items[localId] = endnote;
34871
- if (idAttr) {
34872
- byDocxId.set(idAttr, endnote);
34873
- }
34874
- }
34875
34812
  return {
34876
- byDocxId,
34877
- endnotes: {
34878
- items,
34879
- separator,
34880
- continuationSeparator
34881
- },
34882
- separator,
34883
- continuationSeparator
34813
+ byDocxId: parsed.byDocxId,
34814
+ endnotes: parsed.notes,
34815
+ separator: parsed.separator,
34816
+ continuationSeparator: parsed.continuationSeparator
34884
34817
  };
34885
34818
  }
34886
34819
  const RESERVED_BOOKMARK_NAMES = /* @__PURE__ */ new Set(["_GoBack"]);
@@ -35599,7 +35532,7 @@ function importDocxInWorker(buffer, options = {}) {
35599
35532
  const worker = new Worker(
35600
35533
  new URL(
35601
35534
  /* @vite-ignore */
35602
- "" + new URL("assets/importDocxWorker-BFWGoKvI.js", import.meta.url).href,
35535
+ "" + new URL("assets/importDocxWorker-DbI0FKvR.js", import.meta.url).href,
35603
35536
  import.meta.url
35604
35537
  ),
35605
35538
  {
@@ -39935,57 +39868,57 @@ const OASIS_MENU_ITEMS = {
39935
39868
  formatListsNumbered: "format_lists_numbered"
39936
39869
  };
39937
39870
  export {
39938
- EMU_PER_PT as $,
39939
- createFootnoteReferenceRun as A,
39940
- renumberFootnotes as B,
39941
- iterateFootnoteReferenceRuns as C,
39942
- getFootnoteDisplayMarker as D,
39871
+ iterateEndnoteReferenceRuns as $,
39872
+ createEffect as A,
39873
+ onCleanup as B,
39874
+ buildCanvasLayoutSnapshot as C,
39875
+ on as D,
39943
39876
  EMU_PER_PX as E,
39944
- createSignal as F,
39945
- createEffect as G,
39946
- onCleanup as H,
39947
- buildCanvasLayoutSnapshot as I,
39948
- on as J,
39949
- onMount as K,
39950
- debounce as L,
39951
- unwrap as M,
39952
- getDocumentParagraphs as N,
39953
- getDocumentSectionsCanonical as O,
39877
+ onMount as F,
39878
+ debounce as G,
39879
+ unwrap as H,
39880
+ getDocumentParagraphs as I,
39881
+ createEditorTableCell as J,
39882
+ createEditorTableRow as K,
39883
+ createEditorTable as L,
39884
+ getDocumentSectionsCanonical as M,
39885
+ createEditorDocument as N,
39886
+ getPageContentWidth as O,
39954
39887
  PT_PER_PX as P,
39955
- createEditorDocument as Q,
39956
- getPageContentWidth as R,
39957
- getDocumentPageSettings as S,
39958
- getTableCellContentWidthForParagraph as T,
39959
- resolveResizedDimensions as U,
39960
- resolveTextBoxRenderHeight as V,
39961
- TWIPS_PER_POINT as W,
39962
- PX_PER_INCH as X,
39963
- TWIPS_PER_INCH as Y,
39964
- resolveEffectiveParagraphStyle as Z,
39965
- resolveEffectiveTextStyleForParagraph as _,
39888
+ getDocumentPageSettings as Q,
39889
+ getTableCellContentWidthForParagraph as R,
39890
+ resolveResizedDimensions as S,
39891
+ resolveImageSrc as T,
39892
+ resolveTextBoxRenderHeight as U,
39893
+ TWIPS_PER_POINT as V,
39894
+ PX_PER_INCH as W,
39895
+ TWIPS_PER_INCH as X,
39896
+ resolveEffectiveParagraphStyle as Y,
39897
+ resolveEffectiveTextStyleForParagraph as Z,
39898
+ EMU_PER_PT as _,
39966
39899
  getParagraphLength as a,
39967
39900
  resolveCommandRef as a$,
39968
- iterateEndnoteReferenceRuns as a0,
39969
- JSZip as a1,
39970
- imageContentTypeDefaults as a2,
39971
- imageExtensionFromMime as a3,
39972
- pxToPt as a4,
39973
- resolveFloatingObjectRect as a5,
39974
- getTextBoxFloatingGeometry as a6,
39975
- getPresetPathSegments as a7,
39976
- projectBlocksLayout as a8,
39977
- buildListLabels as a9,
39978
- FOOTNOTE_MARKER_GUTTER_PX as aA,
39979
- resolveImporterForFile as aB,
39980
- createEditorStateFromDocument as aC,
39981
- getDocumentParagraphsCanonical as aD,
39982
- getToolbarStyleState as aE,
39983
- STANDARD_FONT_SIZES_PT as aF,
39984
- fontSizePxToPt as aG,
39985
- probeLocalFontFamilies as aH,
39986
- createInitialEditorState as aI,
39987
- parseFontSizePtToPx as aJ,
39988
- formatFontSizePt as aK,
39901
+ JSZip as a0,
39902
+ imageContentTypeDefaults as a1,
39903
+ imageExtensionFromMime as a2,
39904
+ pxToPt as a3,
39905
+ resolveFloatingObjectRect as a4,
39906
+ getTextBoxFloatingGeometry as a5,
39907
+ getPresetPathSegments as a6,
39908
+ projectBlocksLayout as a7,
39909
+ buildListLabels as a8,
39910
+ textStyleToFontSizePt as a9,
39911
+ resolveImporterForFile as aA,
39912
+ createEditorStateFromDocument as aB,
39913
+ getDocumentParagraphsCanonical as aC,
39914
+ getToolbarStyleState as aD,
39915
+ STANDARD_FONT_SIZES_PT as aE,
39916
+ fontSizePxToPt as aF,
39917
+ probeLocalFontFamilies as aG,
39918
+ createInitialEditorState as aH,
39919
+ parseFontSizePtToPx as aI,
39920
+ formatFontSizePt as aJ,
39921
+ underlineStyleToCssDecorationStyle as aK,
39989
39922
  listKindForTag as aL,
39990
39923
  isParagraphTag as aM,
39991
39924
  collectInlineRuns as aN,
@@ -40002,32 +39935,32 @@ export {
40002
39935
  MenuRegistry as aY,
40003
39936
  createToolbarRegistry as aZ,
40004
39937
  Editor as a_,
40005
- textStyleToFontSizePt as aa,
40006
- PX_PER_POINT as ab,
40007
- DEFAULT_FONT_SIZE_PX as ac,
40008
- isDoubleUnderlineStyle as ad,
40009
- isWavyUnderlineStyle as ae,
40010
- underlineStyleLineWidthPx as af,
40011
- underlineStyleDashArray as ag,
40012
- resolveListLabel as ah,
40013
- getListLabelInset as ai,
40014
- getAlignedListLabelInset as aj,
40015
- getParagraphBorderInsets as ak,
40016
- buildSegmentTable as al,
40017
- buildCanvasTableLayout as am,
40018
- normalizeFamily as an,
40019
- ROBOTO_FONT_FILES as ao,
40020
- loadFontAsset as ap,
40021
- OFFICE_COMPAT_FONT_FAMILIES as aq,
40022
- buildSfnt as ar,
40023
- defaultFontDecoderRegistry as as,
40024
- SfntFontProgram as at,
40025
- collectPdfFontFamilies as au,
40026
- projectDocumentLayout as av,
40027
- getPageHeaderZoneTop as aw,
40028
- getPageBodyTop as ax,
40029
- getPageColumnRects as ay,
40030
- findFootnoteReference as az,
39938
+ PX_PER_POINT as aa,
39939
+ DEFAULT_FONT_SIZE_PX as ab,
39940
+ isDoubleUnderlineStyle as ac,
39941
+ isWavyUnderlineStyle as ad,
39942
+ underlineStyleLineWidthPx as ae,
39943
+ underlineStyleDashArray as af,
39944
+ resolveListLabel as ag,
39945
+ getListLabelInset as ah,
39946
+ getAlignedListLabelInset as ai,
39947
+ getParagraphBorderInsets as aj,
39948
+ buildSegmentTable as ak,
39949
+ buildCanvasTableLayout as al,
39950
+ normalizeFamily as am,
39951
+ ROBOTO_FONT_FILES as an,
39952
+ loadFontAsset as ao,
39953
+ OFFICE_COMPAT_FONT_FAMILIES as ap,
39954
+ buildSfnt as aq,
39955
+ defaultFontDecoderRegistry as ar,
39956
+ SfntFontProgram as as,
39957
+ collectPdfFontFamilies as at,
39958
+ projectDocumentLayout as au,
39959
+ getPageHeaderZoneTop as av,
39960
+ getPageBodyTop as aw,
39961
+ getPageColumnRects as ax,
39962
+ findFootnoteReference as ay,
39963
+ FOOTNOTE_MARKER_GUTTER_PX as az,
40031
39964
  createEditorRun as b,
40032
39965
  FloatingActionButton as b$,
40033
39966
  commandRefName as b0,
@@ -40136,12 +40069,12 @@ export {
40136
40069
  positionToParagraphOffset as p,
40137
40070
  createEditorParagraph as q,
40138
40071
  getBlockParagraphs as r,
40139
- findParagraphTableLocation as s,
40140
- buildTableCellLayout as t,
40141
- createEditorTableCell as u,
40142
- createEditorTableRow as v,
40143
- createEditorTable as w,
40144
- underlineStyleToCssDecorationStyle as x,
40145
- resolveImageSrc as y,
40146
- createEditorFootnote as z
40072
+ createEditorFootnote as s,
40073
+ createFootnoteReferenceRun as t,
40074
+ renumberFootnotes as u,
40075
+ iterateFootnoteReferenceRuns as v,
40076
+ getFootnoteDisplayMarker as w,
40077
+ findParagraphTableLocation as x,
40078
+ buildTableCellLayout as y,
40079
+ createSignal as z
40147
40080
  };
@@ -1,4 +1,4 @@
1
- import { b2, bV, bW, bX, bY, bZ, bk, b_, b3, a_, b$, c0, c1, b1, c2, aY, c3, c4, c5, c6, c7, bQ, c8, c9, ca, cb, cc, cd, ce, cf, cg, ch, ci, bp, cj, bP, ck, bX as bX2, c0 as c02, c2 as c22, cb as cb2, cd as cd2, ci as ci2, cl, b0, aX, cm, cn, co, aZ, cp, cq, a$ } from "./index-c-mRZBWM.js";
1
+ import { b2, bV, bW, bX, bY, bZ, bk, b_, b3, a_, b$, c0, c1, b1, c2, aY, c3, c4, c5, c6, c7, bQ, c8, c9, ca, cb, cc, cd, ce, cf, cg, ch, ci, bp, cj, bP, ck, bX as bX2, c0 as c02, c2 as c22, cb as cb2, cd as cd2, ci as ci2, cl, b0, aX, cm, cn, co, aZ, cp, cq, a$ } from "./index-Cz7QAkQ8.js";
2
2
  export {
3
3
  b2 as BalloonShell,
4
4
  bV as Button,