oasis-editor 0.0.2 → 0.0.4

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.
@@ -34,6 +34,10 @@ export interface EditorParagraphListStyle {
34
34
  * tab stop (or a space / nothing). Undefined is treated as "tab".
35
35
  */
36
36
  suffix?: "tab" | "space" | "nothing";
37
+ /** Literal bullet character from `w:lvlText` (bullet lists only). */
38
+ bulletGlyph?: string;
39
+ /** Font family used to render the bullet glyph (e.g. "Symbol", "Wingdings"). */
40
+ bulletFont?: string;
37
41
  }
38
42
  /**
39
43
  * Image crop, mapped from DrawingML `a:srcRect`. Values are fractions of the
@@ -1,17 +1,22 @@
1
1
  import { EditorBlockNode, EditorImageCrop, EditorImageFillMode, EditorImageFloatingLayout, EditorParagraphListStyle, EditorWrapPolygonPoint } from '../../../../core/model.js';
2
2
  import { BookmarkEventsByParagraph } from '../../bookmarksXml.js';
3
3
 
4
+ export interface NumberingDefinition {
5
+ kind: EditorParagraphListStyle["kind"];
6
+ level: number;
7
+ abstractNumId: number;
8
+ numId: number;
9
+ format?: NonNullable<EditorParagraphListStyle["format"]>;
10
+ startAt?: number;
11
+ bulletGlyph?: string;
12
+ bulletFont?: string;
13
+ }
4
14
  export interface DocContext {
5
15
  numberingInfo: Map<string, {
6
16
  numId: number;
7
17
  level: number;
8
18
  }>;
9
- definitions: Array<{
10
- kind: EditorParagraphListStyle["kind"];
11
- level: number;
12
- abstractNumId: number;
13
- numId: number;
14
- }>;
19
+ definitions: NumberingDefinition[];
15
20
  images: Array<{
16
21
  rId: string;
17
22
  target: string;
@@ -65,12 +70,7 @@ export interface NumberingContext {
65
70
  numId: number;
66
71
  level: number;
67
72
  }>;
68
- definitions: Array<{
69
- kind: EditorParagraphListStyle["kind"];
70
- level: number;
71
- abstractNumId: number;
72
- numId: number;
73
- }>;
73
+ definitions: NumberingDefinition[];
74
74
  }
75
75
  export interface ExportBuildState {
76
76
  nextImageId: number;
@@ -11,8 +11,25 @@ export interface NumberingMaps {
11
11
  }>;
12
12
  /** Suffix (`w:suff`) per level, keyed by "abstractNumId:ilvl". */
13
13
  abstractSuffixes: Map<string, EditorParagraphListStyle["suffix"]>;
14
+ /** numFmt mapped to editor format, keyed by "abstractNumId:ilvl". */
15
+ abstractFormats: Map<string, NonNullable<EditorParagraphListStyle["format"]>>;
16
+ /** Starting number from `w:start`, keyed by "abstractNumId:ilvl". OOXML default is 1. */
17
+ abstractStarts: Map<string, number>;
18
+ /** Literal bullet glyph from `w:lvlText`, keyed by "abstractNumId:ilvl". */
19
+ abstractBulletGlyphs: Map<string, string>;
20
+ /** Font name from `w:lvl/w:rPr/w:rFonts`, keyed by "abstractNumId:ilvl". */
21
+ abstractBulletFonts: Map<string, string>;
22
+ /** `w:startOverride` values from `w:num/w:lvlOverride`, keyed by "numId:ilvl". */
23
+ numStartOverrides: Map<string, number>;
14
24
  /** numId → abstractNumId */
15
25
  numToAbstractId: Map<string, string>;
26
+ /**
27
+ * Tracks which "numId:ilvl" pairs have been seen during paragraph parsing.
28
+ * The first paragraph for each pair carries the level's `startAt` value;
29
+ * subsequent paragraphs in the same list instance do not, so the counter
30
+ * continues from the previous ordinal instead of resetting.
31
+ */
32
+ seenInstances: Set<string>;
16
33
  }
17
34
  export declare function parseNumbering(numberingXml: string | null): NumberingMaps;
18
35
  export declare function parseParagraphList(paragraphProperties: XmlElement | null, numberingMaps: NumberingMaps): {
@@ -2270,7 +2270,7 @@ function OasisEditorAppLazy(props = {}) {
2270
2270
  onCleanup(() => {
2271
2271
  cancelled = true;
2272
2272
  });
2273
- import("./OasisEditorApp-DEnDLTaw.js").then((m) => {
2273
+ import("./OasisEditorApp-DD-ts2_v.js").then((m) => {
2274
2274
  cancelled = true;
2275
2275
  setProgress(1);
2276
2276
  setTimeout(() => setApp(() => m.OasisEditorApp), 180);
@@ -14226,7 +14226,8 @@ function getListOrdinals(document2) {
14226
14226
  continue;
14227
14227
  }
14228
14228
  const level = list.level ?? 0;
14229
- const next = (counters.get(level) ?? 0) + 1;
14229
+ const prev = counters.get(level);
14230
+ const next = prev !== void 0 ? prev + 1 : list.startAt ?? 1;
14230
14231
  counters.set(level, next);
14231
14232
  result.set(paragraph.id, next);
14232
14233
  }
@@ -14286,6 +14287,31 @@ function toRoman(value) {
14286
14287
  }
14287
14288
  return out;
14288
14289
  }
14290
+ const PUA_BULLET_MAP = {
14291
+ 61623: "•",
14292
+ // Symbol: filled circle bullet
14293
+ 61548: "·",
14294
+ // Wingdings: medium bullet
14295
+ 61607: "▪",
14296
+ // Wingdings 2: black small square
14297
+ 61656: "➢",
14298
+ // Wingdings: arrowhead
14299
+ 61559: "✓",
14300
+ // Wingdings: check mark
14301
+ 61692: "✓",
14302
+ // Wingdings: check mark (alt)
14303
+ 61671: "⚡",
14304
+ // Wingdings: lightning
14305
+ 61472: " "
14306
+ // Symbol/Wingdings: space
14307
+ };
14308
+ function normalizeBulletGlyph(glyph) {
14309
+ const code2 = glyph.codePointAt(0);
14310
+ if (code2 !== void 0 && code2 >= 57344 && code2 <= 63743) {
14311
+ return PUA_BULLET_MAP[code2] ?? "•";
14312
+ }
14313
+ return glyph;
14314
+ }
14289
14315
  const BULLET_GLYPHS = ["•", "○", "▪", "•", "○", "▪"];
14290
14316
  const ORDERED_DEFAULT_FORMATS = [
14291
14317
  "decimal",
@@ -14299,6 +14325,8 @@ function resolveListPrefix(paragraph, document2) {
14299
14325
  if (!paragraph.list) return "";
14300
14326
  const level = paragraph.list.level ?? 0;
14301
14327
  if (paragraph.list.kind === "bullet") {
14328
+ const raw = paragraph.list.bulletGlyph;
14329
+ if (raw) return normalizeBulletGlyph(raw);
14302
14330
  return BULLET_GLYPHS[level % BULLET_GLYPHS.length] ?? "•";
14303
14331
  }
14304
14332
  const ordinal = getListOrdinals(document2).get(paragraph.id) ?? paragraph.list.startAt ?? 1;
@@ -29256,35 +29284,46 @@ function parseSettings(xml) {
29256
29284
  }
29257
29285
  return settings;
29258
29286
  }
29287
+ const FORMAT_MAP = {
29288
+ decimal: "decimal",
29289
+ lowerLetter: "lowerLetter",
29290
+ upperLetter: "upperLetter",
29291
+ lowerRoman: "lowerRoman",
29292
+ upperRoman: "upperRoman",
29293
+ bullet: "bullet"
29294
+ };
29259
29295
  function parseNumbering(numberingXml) {
29260
29296
  const abstractKinds = /* @__PURE__ */ new Map();
29261
29297
  const numKinds = /* @__PURE__ */ new Map();
29262
29298
  const abstractIndents = /* @__PURE__ */ new Map();
29263
29299
  const abstractSuffixes = /* @__PURE__ */ new Map();
29300
+ const abstractFormats = /* @__PURE__ */ new Map();
29301
+ const abstractStarts = /* @__PURE__ */ new Map();
29302
+ const abstractBulletGlyphs = /* @__PURE__ */ new Map();
29303
+ const abstractBulletFonts = /* @__PURE__ */ new Map();
29304
+ const numStartOverrides = /* @__PURE__ */ new Map();
29264
29305
  const numToAbstractId = /* @__PURE__ */ new Map();
29265
- if (!numberingXml) {
29266
- return {
29267
- abstractKinds,
29268
- numKinds,
29269
- abstractIndents,
29270
- abstractSuffixes,
29271
- numToAbstractId
29272
- };
29273
- }
29306
+ const seenInstances = /* @__PURE__ */ new Set();
29307
+ const emptyResult = () => ({
29308
+ abstractKinds,
29309
+ numKinds,
29310
+ abstractIndents,
29311
+ abstractSuffixes,
29312
+ abstractFormats,
29313
+ abstractStarts,
29314
+ abstractBulletGlyphs,
29315
+ abstractBulletFonts,
29316
+ numStartOverrides,
29317
+ numToAbstractId,
29318
+ seenInstances
29319
+ });
29320
+ if (!numberingXml) return emptyResult();
29274
29321
  const document2 = new DOMParser$1().parseFromString(
29275
29322
  numberingXml,
29276
29323
  "application/xml"
29277
29324
  );
29278
29325
  const numbering = document2.documentElement;
29279
- if (!numbering) {
29280
- return {
29281
- abstractKinds,
29282
- numKinds,
29283
- abstractIndents,
29284
- abstractSuffixes,
29285
- numToAbstractId
29286
- };
29287
- }
29326
+ if (!numbering) return emptyResult();
29288
29327
  const abstractNums = numbering.getElementsByTagNameNS(WORD_NS, "abstractNum");
29289
29328
  for (let index = 0; index < abstractNums.length; index += 1) {
29290
29329
  const abstractNum = abstractNums[index];
@@ -29292,11 +29331,12 @@ function parseNumbering(numberingXml) {
29292
29331
  if (!abstractId) continue;
29293
29332
  for (const level of getChildrenByTagNameNS(abstractNum, WORD_NS, "lvl")) {
29294
29333
  const ilvl = getAttributeValue(level, "ilvl") ?? "0";
29334
+ const levelKey = `${abstractId}:${ilvl}`;
29295
29335
  const numFmt = getFirstChildByTagNameNS(level, WORD_NS, "numFmt");
29296
29336
  const format = getAttributeValue(numFmt, "val");
29297
29337
  if (format) {
29298
29338
  abstractKinds.set(
29299
- `${abstractId}:${ilvl}`,
29339
+ levelKey,
29300
29340
  format === "bullet" ? "bullet" : "ordered"
29301
29341
  );
29302
29342
  if (ilvl === "0") {
@@ -29305,14 +29345,33 @@ function parseNumbering(numberingXml) {
29305
29345
  format === "bullet" ? "bullet" : "ordered"
29306
29346
  );
29307
29347
  }
29348
+ const editorFormat = FORMAT_MAP[format];
29349
+ if (editorFormat) abstractFormats.set(levelKey, editorFormat);
29308
29350
  }
29309
29351
  const suffRaw = getAttributeValue(
29310
29352
  getFirstChildByTagNameNS(level, WORD_NS, "suff"),
29311
29353
  "val"
29312
29354
  );
29313
29355
  if (suffRaw === "space" || suffRaw === "nothing" || suffRaw === "tab") {
29314
- abstractSuffixes.set(`${abstractId}:${ilvl}`, suffRaw);
29356
+ abstractSuffixes.set(levelKey, suffRaw);
29315
29357
  }
29358
+ const startRaw = getAttributeValue(
29359
+ getFirstChildByTagNameNS(level, WORD_NS, "start"),
29360
+ "val"
29361
+ );
29362
+ if (startRaw != null) {
29363
+ const n = parseInt(startRaw, 10);
29364
+ if (!isNaN(n)) abstractStarts.set(levelKey, n);
29365
+ }
29366
+ if (format === "bullet") {
29367
+ const lvlTextEl = getFirstChildByTagNameNS(level, WORD_NS, "lvlText");
29368
+ const glyph = getAttributeValue(lvlTextEl, "val");
29369
+ if (glyph) abstractBulletGlyphs.set(levelKey, glyph);
29370
+ }
29371
+ const rPr = getFirstChildByTagNameNS(level, WORD_NS, "rPr");
29372
+ const rFonts = getFirstChildByTagNameNS(rPr, WORD_NS, "rFonts");
29373
+ const fontName = getAttributeValue(rFonts, "ascii") ?? getAttributeValue(rFonts, "hAnsi");
29374
+ if (fontName) abstractBulletFonts.set(levelKey, fontName);
29316
29375
  const pPr = getFirstChildByTagNameNS(level, WORD_NS, "pPr");
29317
29376
  const ind = getFirstChildByTagNameNS(pPr, WORD_NS, "ind");
29318
29377
  if (ind) {
@@ -29321,7 +29380,7 @@ function parseNumbering(numberingXml) {
29321
29380
  const left = leftRaw != null ? twipsToPx(leftRaw, 0) : void 0;
29322
29381
  const hanging = hangingRaw != null ? twipsToPx(hangingRaw, 0) : void 0;
29323
29382
  if (left !== void 0 || hanging !== void 0) {
29324
- abstractIndents.set(`${abstractId}:${ilvl}`, { left, hanging });
29383
+ abstractIndents.set(levelKey, { left, hanging });
29325
29384
  }
29326
29385
  }
29327
29386
  }
@@ -29341,13 +29400,33 @@ function parseNumbering(numberingXml) {
29341
29400
  }
29342
29401
  numToAbstractId.set(numId, abstractNumId);
29343
29402
  numKinds.set(numId, abstractKinds.get(abstractNumId) ?? "ordered");
29403
+ for (const override of getChildrenByTagNameNS(num, WORD_NS, "lvlOverride")) {
29404
+ const overrideIlvl = getAttributeValue(override, "ilvl");
29405
+ if (!overrideIlvl) continue;
29406
+ const startOverrideEl = getFirstChildByTagNameNS(
29407
+ override,
29408
+ WORD_NS,
29409
+ "startOverride"
29410
+ );
29411
+ const startOverrideRaw = getAttributeValue(startOverrideEl, "val");
29412
+ if (startOverrideRaw != null) {
29413
+ const n = parseInt(startOverrideRaw, 10);
29414
+ if (!isNaN(n)) numStartOverrides.set(`${numId}:${overrideIlvl}`, n);
29415
+ }
29416
+ }
29344
29417
  }
29345
29418
  return {
29346
29419
  abstractKinds,
29347
29420
  numKinds,
29348
29421
  abstractIndents,
29349
29422
  abstractSuffixes,
29350
- numToAbstractId
29423
+ abstractFormats,
29424
+ abstractStarts,
29425
+ abstractBulletGlyphs,
29426
+ abstractBulletFonts,
29427
+ numStartOverrides,
29428
+ numToAbstractId,
29429
+ seenInstances
29351
29430
  };
29352
29431
  }
29353
29432
  function parseParagraphList(paragraphProperties, numberingMaps) {
@@ -29371,13 +29450,31 @@ function parseParagraphList(paragraphProperties, numberingMaps) {
29371
29450
  ) ?? "0";
29372
29451
  const level = Number(ilvlValue);
29373
29452
  const abstractId = numberingMaps.numToAbstractId.get(numId);
29374
- const indent = abstractId ? numberingMaps.abstractIndents.get(`${abstractId}:${ilvlValue}`) : void 0;
29375
- const suffix = (abstractId ? numberingMaps.abstractSuffixes.get(`${abstractId}:${ilvlValue}`) : void 0) ?? "tab";
29453
+ const levelKey = abstractId ? `${abstractId}:${ilvlValue}` : void 0;
29454
+ const indent = levelKey ? numberingMaps.abstractIndents.get(levelKey) : void 0;
29455
+ const suffix = (levelKey ? numberingMaps.abstractSuffixes.get(levelKey) : void 0) ?? "tab";
29456
+ const format = levelKey ? numberingMaps.abstractFormats.get(levelKey) : void 0;
29457
+ const bulletGlyph = levelKey ? numberingMaps.abstractBulletGlyphs.get(levelKey) : void 0;
29458
+ const bulletFont = levelKey ? numberingMaps.abstractBulletFonts.get(levelKey) : void 0;
29459
+ const instanceKey = `${numId}:${ilvlValue}`;
29460
+ const isFirstInInstance = !numberingMaps.seenInstances.has(instanceKey);
29461
+ numberingMaps.seenInstances.add(instanceKey);
29462
+ let startAt;
29463
+ if (isFirstInInstance) {
29464
+ const override = numberingMaps.numStartOverrides.get(instanceKey);
29465
+ const abstractStart = levelKey ? numberingMaps.abstractStarts.get(levelKey) : void 0;
29466
+ const effectiveStart = override ?? abstractStart ?? 1;
29467
+ if (effectiveStart !== 1) startAt = effectiveStart;
29468
+ }
29376
29469
  return {
29377
29470
  list: {
29378
29471
  kind: numberingMaps.numKinds.get(numId) ?? "ordered",
29379
29472
  level: Number.isFinite(level) ? level : 0,
29380
- suffix
29473
+ suffix,
29474
+ ...format !== void 0 && { format },
29475
+ ...startAt !== void 0 && { startAt },
29476
+ ...bulletGlyph !== void 0 && { bulletGlyph },
29477
+ ...bulletFont !== void 0 && { bulletFont }
29381
29478
  },
29382
29479
  indent
29383
29480
  };
@@ -33005,7 +33102,7 @@ function importDocxInWorker(buffer, options = {}) {
33005
33102
  const worker = new Worker(
33006
33103
  new URL(
33007
33104
  /* @vite-ignore */
33008
- "" + new URL("assets/importDocxWorker-R5rI6JIO.js", import.meta.url).href,
33105
+ "" + new URL("assets/importDocxWorker-CVDgFleW.js", import.meta.url).href,
33009
33106
  import.meta.url
33010
33107
  ),
33011
33108
  {
@@ -1,4 +1,4 @@
1
- import { aM, bB, bC, bD, bE, bF, b1, bG, aN, aI, bH, bI, bJ, aL, bK, aG, bL, bM, bN, bO, bP, bx, bQ, bR, bS, bT, bU, bV, bW, bX, bY, bZ, b6, b_, bw, b$, bD as bD2, bI as bI2, bK as bK2, bS as bS2, bU as bU2, bZ as bZ2, aK, aE, c0, c1, c2, aH, c3, c4, aJ } from "./index-DuS88s1l.js";
1
+ import { aM, bB, bC, bD, bE, bF, b1, bG, aN, aI, bH, bI, bJ, aL, bK, aG, bL, bM, bN, bO, bP, bx, bQ, bR, bS, bT, bU, bV, bW, bX, bY, bZ, b6, b_, bw, b$, bD as bD2, bI as bI2, bK as bK2, bS as bS2, bU as bU2, bZ as bZ2, aK, aE, c0, c1, c2, aH, c3, c4, aJ } from "./index-C-nGWNHh.js";
2
2
  export {
3
3
  aM as BalloonShell,
4
4
  bB as Button,