oasis-editor 0.0.45 → 0.0.47

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.
@@ -9,16 +9,7 @@ export declare function insertPlainTextAtSelection(state: EditorState, text: str
9
9
  export declare function deleteBackward(state: EditorState): EditorState;
10
10
  export declare function deleteForward(state: EditorState): EditorState;
11
11
  export declare function toggleTextStyle(state: EditorState, key: ToggleableTextStyleKey): EditorState;
12
- export type TextCaseMode = "sentence" | "lower" | "upper" | "capitalize" | "toggle";
13
- /**
14
- * Transforms the text of the selected runs in place. The transform must return
15
- * a string of the same length so per-run boundaries (and thus styles) are
16
- * preserved. The transform is applied to each paragraph's selected text
17
- * independently so sentence/word boundaries reset at paragraph breaks.
18
- */
19
- export declare function transformSelectedText(state: EditorState, transform: (text: string) => string): EditorState;
20
- /** Change the letter case of the selected text, preserving runs and styles. */
21
- export declare function changeSelectedTextCase(state: EditorState, mode: TextCaseMode): EditorState;
12
+ export { type TextCaseMode, transformSelectedText, changeSelectedTextCase, } from './textCase.js';
22
13
  /**
23
14
  * Remove direct (local) text formatting from the selected runs, preserving the
24
15
  * text content, revisions, and links.
@@ -0,0 +1,12 @@
1
+ import { EditorState } from '../model.js';
2
+
3
+ export type TextCaseMode = "sentence" | "lower" | "upper" | "capitalize" | "toggle";
4
+ /**
5
+ * Transforms the text of the selected runs in place. The transform must return
6
+ * a string of the same length so per-run boundaries (and thus styles) are
7
+ * preserved. The transform is applied to each paragraph's selected text
8
+ * independently so sentence/word boundaries reset at paragraph breaks.
9
+ */
10
+ export declare function transformSelectedText(state: EditorState, transform: (text: string) => string): EditorState;
11
+ /** Change the letter case of the selected text, preserving runs and styles. */
12
+ export declare function changeSelectedTextCase(state: EditorState, mode: TextCaseMode): EditorState;
@@ -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-BicXOvEM.js").then((m) => {
2486
+ import("./OasisEditorApp-9bkqRYbl.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
  {
@@ -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-OhHCISs2.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-o6IKPcPL.js";
2
2
  export {
3
3
  b2 as BalloonShell,
4
4
  bV as Button,