@harbour-enterprises/superdoc 0.17.1-next.1 → 0.18.0-next.1

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 (51) hide show
  1. package/dist/chunks/{PdfViewer-D3Mx67L7.cjs → PdfViewer-CNZTqGHw.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-Bh-V1GAU.es.js → PdfViewer-D5cujgSt.es.js} +1 -1
  3. package/dist/chunks/{index-DyfNSlgn.es.js → index-BDwD6Uex.es.js} +3 -2
  4. package/dist/chunks/{index-Dh6A5pUX.cjs → index-BDysJRQU.cjs} +3 -2
  5. package/dist/chunks/{super-editor.es-hh18Joow.es.js → super-editor.es-BoCmoEkp.es.js} +469 -254
  6. package/dist/chunks/{super-editor.es-DYmLwal7.cjs → super-editor.es-aOm7eWFU.cjs} +468 -253
  7. package/dist/core/SuperDoc.d.ts.map +1 -1
  8. package/dist/index.d.ts +2 -1
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/super-editor/ai-writer.es.js +2 -2
  11. package/dist/super-editor/chunks/{converter-4gJFeq_J.js → converter-DvdFP4MZ.js} +337 -144
  12. package/dist/super-editor/chunks/{docx-zipper-Cceby9KI.js → docx-zipper-CxFpxZUz.js} +1 -1
  13. package/dist/super-editor/chunks/{editor-Isy5ZiWC.js → editor-CeWNMKjc.js} +31 -3
  14. package/dist/super-editor/chunks/{toolbar-Bg9sFUKb.js → toolbar-Di2oAvyr.js} +2 -2
  15. package/dist/super-editor/converter.es.js +1 -1
  16. package/dist/super-editor/docx-zipper.es.js +2 -2
  17. package/dist/super-editor/editor.es.js +3 -3
  18. package/dist/super-editor/file-zipper.es.js +1 -1
  19. package/dist/super-editor/src/core/super-converter/exporter.d.ts +17 -0
  20. package/dist/super-editor/src/core/super-converter/v2/importer/lineBreakImporter.d.ts +3 -5
  21. package/dist/super-editor/src/core/super-converter/v2/importer/tabImporter.d.ts +2 -1
  22. package/dist/super-editor/src/core/super-converter/v2/importer/types/index.d.ts +75 -0
  23. package/dist/super-editor/src/core/super-converter/v2/types/index.d.ts +8 -0
  24. package/dist/super-editor/src/core/super-converter/v3/handlers/index.d.ts +8 -0
  25. package/dist/super-editor/src/core/super-converter/v3/handlers/w/br/attributes/index.d.ts +2 -0
  26. package/dist/super-editor/src/core/super-converter/v3/handlers/w/br/attributes/w-clear.d.ts +2 -0
  27. package/dist/super-editor/src/core/super-converter/v3/handlers/w/br/attributes/w-line-break-type.d.ts +2 -0
  28. package/dist/super-editor/src/core/super-converter/v3/handlers/w/br/br-translator.d.ts +7 -0
  29. package/dist/super-editor/src/core/super-converter/v3/handlers/w/br/index.d.ts +1 -0
  30. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tab/attributes/index.d.ts +3 -0
  31. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tab/attributes/w-tab-leader.d.ts +2 -0
  32. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tab/attributes/w-tab-pos.d.ts +2 -0
  33. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tab/attributes/w-tab-size.d.ts +2 -0
  34. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tab/index.d.ts +1 -0
  35. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tab/tab-translator.d.ts +7 -0
  36. package/dist/super-editor/src/core/super-converter/v3/node-translator/index.d.ts +1 -0
  37. package/dist/super-editor/src/core/super-converter/v3/node-translator/node-translator.d.ts +203 -0
  38. package/dist/super-editor/src/extensions/block-node/block-node.d.ts +0 -1
  39. package/dist/super-editor/src/index.d.ts +2 -1
  40. package/dist/super-editor/super-editor.es.js +12 -7
  41. package/dist/super-editor/toolbar.es.js +2 -2
  42. package/dist/super-editor.cjs +2 -1
  43. package/dist/super-editor.es.js +2 -1
  44. package/dist/superdoc.cjs +3 -2
  45. package/dist/superdoc.es.js +3 -2
  46. package/dist/superdoc.umd.js +590 -374
  47. package/dist/superdoc.umd.js.map +1 -1
  48. package/package.json +1 -1
  49. package/dist/super-editor/src/core/super-converter/v2/handlers/index.d.ts +0 -1
  50. package/dist/super-editor/src/extensions/field-annotation/field-annotation-marks-impl.d.ts +0 -5
  51. /package/dist/super-editor/src/{extensions/document-attributes → core/super-converter/v3/handlers/types}/index.d.ts +0 -0
@@ -1876,14 +1876,14 @@ function requireEvents() {
1876
1876
  err.context = er;
1877
1877
  throw err;
1878
1878
  }
1879
- var handler = events2[type2];
1880
- if (handler === void 0)
1879
+ var handler2 = events2[type2];
1880
+ if (handler2 === void 0)
1881
1881
  return false;
1882
- if (typeof handler === "function") {
1883
- ReflectApply(handler, this, args);
1882
+ if (typeof handler2 === "function") {
1883
+ ReflectApply(handler2, this, args);
1884
1884
  } else {
1885
- var len = handler.length;
1886
- var listeners = arrayClone(handler, len);
1885
+ var len = handler2.length;
1886
+ var listeners = arrayClone(handler2, len);
1887
1887
  for (var i = 0; i < len; ++i)
1888
1888
  ReflectApply(listeners[i], this, args);
1889
1889
  }
@@ -2123,9 +2123,9 @@ function requireEvents() {
2123
2123
  }
2124
2124
  });
2125
2125
  }
2126
- function addErrorHandlerIfEventEmitter(emitter, handler, flags) {
2126
+ function addErrorHandlerIfEventEmitter(emitter, handler2, flags) {
2127
2127
  if (typeof emitter.on === "function") {
2128
- eventTargetAgnosticAddListener(emitter, "error", handler, flags);
2128
+ eventTargetAgnosticAddListener(emitter, "error", handler2, flags);
2129
2129
  }
2130
2130
  }
2131
2131
  function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
@@ -6907,15 +6907,15 @@ function requireBrowser() {
6907
6907
  hasRequiredBrowser = 1;
6908
6908
  browser = deprecate;
6909
6909
  function deprecate(fn, msg) {
6910
- if (config("noDeprecation")) {
6910
+ if (config2("noDeprecation")) {
6911
6911
  return fn;
6912
6912
  }
6913
6913
  var warned = false;
6914
6914
  function deprecated() {
6915
6915
  if (!warned) {
6916
- if (config("throwDeprecation")) {
6916
+ if (config2("throwDeprecation")) {
6917
6917
  throw new Error(msg);
6918
- } else if (config("traceDeprecation")) {
6918
+ } else if (config2("traceDeprecation")) {
6919
6919
  console.trace(msg);
6920
6920
  } else {
6921
6921
  console.warn(msg);
@@ -6926,7 +6926,7 @@ function requireBrowser() {
6926
6926
  }
6927
6927
  return deprecated;
6928
6928
  }
6929
- function config(name) {
6929
+ function config2(name) {
6930
6930
  try {
6931
6931
  if (!commonjsGlobal.localStorage) return false;
6932
6932
  } catch (_2) {
@@ -9301,7 +9301,7 @@ function requireSax() {
9301
9301
  this._parser.end();
9302
9302
  return true;
9303
9303
  };
9304
- SAXStream.prototype.on = function(ev, handler) {
9304
+ SAXStream.prototype.on = function(ev, handler2) {
9305
9305
  var me = this;
9306
9306
  if (!me._parser["on" + ev] && streamWraps.indexOf(ev) !== -1) {
9307
9307
  me._parser["on" + ev] = function() {
@@ -9310,7 +9310,7 @@ function requireSax() {
9310
9310
  me.emit.apply(me, args);
9311
9311
  };
9312
9312
  }
9313
- return Stream.prototype.on.call(me, ev, handler);
9313
+ return Stream.prototype.on.call(me, ev, handler2);
9314
9314
  };
9315
9315
  var CDATA = "[CDATA[";
9316
9316
  var DOCTYPE = "DOCTYPE";
@@ -11469,8 +11469,8 @@ function requireHe() {
11469
11469
  var parseError = function(message) {
11470
11470
  throw Error("Parse error: " + message);
11471
11471
  };
11472
- var encode = function(string, options) {
11473
- options = merge(options, encode.options);
11472
+ var encode2 = function(string, options) {
11473
+ options = merge(options, encode2.options);
11474
11474
  var strict = options.strict;
11475
11475
  if (strict && regexInvalidRawCodePoint.test(string)) {
11476
11476
  parseError("forbidden code point");
@@ -11517,15 +11517,15 @@ function requireHe() {
11517
11517
  return escapeCodePoint(codePoint);
11518
11518
  }).replace(regexBmpWhitelist, escapeBmpSymbol);
11519
11519
  };
11520
- encode.options = {
11520
+ encode2.options = {
11521
11521
  "allowUnsafeSymbols": false,
11522
11522
  "encodeEverything": false,
11523
11523
  "strict": false,
11524
11524
  "useNamedReferences": false,
11525
11525
  "decimal": false
11526
11526
  };
11527
- var decode = function(html, options) {
11528
- options = merge(options, decode.options);
11527
+ var decode2 = function(html, options) {
11528
+ options = merge(options, decode2.options);
11529
11529
  var strict = options.strict;
11530
11530
  if (strict && regexInvalidEntity.test(html)) {
11531
11531
  parseError("malformed character reference");
@@ -11584,7 +11584,7 @@ function requireHe() {
11584
11584
  return $0;
11585
11585
  });
11586
11586
  };
11587
- decode.options = {
11587
+ decode2.options = {
11588
11588
  "isAttributeValue": false,
11589
11589
  "strict": false
11590
11590
  };
@@ -11595,10 +11595,10 @@ function requireHe() {
11595
11595
  };
11596
11596
  var he2 = {
11597
11597
  "version": "1.2.0",
11598
- "encode": encode,
11599
- "decode": decode,
11598
+ "encode": encode2,
11599
+ "decode": decode2,
11600
11600
  "escape": escape,
11601
- "unescape": decode
11601
+ "unescape": decode2
11602
11602
  };
11603
11603
  if (freeExports && !freeExports.nodeType) {
11604
11604
  if (freeModule) {
@@ -17364,24 +17364,24 @@ class FieldDesc {
17364
17364
  }
17365
17365
  const baseFields = [
17366
17366
  new FieldDesc("doc", {
17367
- init(config) {
17368
- return config.doc || config.schema.topNodeType.createAndFill();
17367
+ init(config2) {
17368
+ return config2.doc || config2.schema.topNodeType.createAndFill();
17369
17369
  },
17370
17370
  apply(tr) {
17371
17371
  return tr.doc;
17372
17372
  }
17373
17373
  }),
17374
17374
  new FieldDesc("selection", {
17375
- init(config, instance) {
17376
- return config.selection || Selection.atStart(instance.doc);
17375
+ init(config2, instance) {
17376
+ return config2.selection || Selection.atStart(instance.doc);
17377
17377
  },
17378
17378
  apply(tr) {
17379
17379
  return tr.selection;
17380
17380
  }
17381
17381
  }),
17382
17382
  new FieldDesc("storedMarks", {
17383
- init(config) {
17384
- return config.storedMarks || null;
17383
+ init(config2) {
17384
+ return config2.storedMarks || null;
17385
17385
  },
17386
17386
  apply(tr, _marks, _old, state2) {
17387
17387
  return state2.selection.$cursor ? tr.storedMarks : null;
@@ -17417,8 +17417,8 @@ class EditorState {
17417
17417
  /**
17418
17418
  @internal
17419
17419
  */
17420
- constructor(config) {
17421
- this.config = config;
17420
+ constructor(config2) {
17421
+ this.config = config2;
17422
17422
  }
17423
17423
  /**
17424
17424
  The schema of the state's document.
@@ -17509,11 +17509,11 @@ class EditorState {
17509
17509
  /**
17510
17510
  Create a new state.
17511
17511
  */
17512
- static create(config) {
17513
- let $config = new Configuration(config.doc ? config.doc.type.schema : config.schema, config.plugins);
17512
+ static create(config2) {
17513
+ let $config = new Configuration(config2.doc ? config2.doc.type.schema : config2.schema, config2.plugins);
17514
17514
  let instance = new EditorState($config);
17515
17515
  for (let i = 0; i < $config.fields.length; i++)
17516
- instance[$config.fields[i].name] = $config.fields[i].init(config, instance);
17516
+ instance[$config.fields[i].name] = $config.fields[i].init(config2, instance);
17517
17517
  return instance;
17518
17518
  }
17519
17519
  /**
@@ -17524,12 +17524,12 @@ class EditorState {
17524
17524
  [`init`](https://prosemirror.net/docs/ref/#state.StateField.init) method, passing in the new
17525
17525
  configuration object..
17526
17526
  */
17527
- reconfigure(config) {
17528
- let $config = new Configuration(this.schema, config.plugins);
17527
+ reconfigure(config2) {
17528
+ let $config = new Configuration(this.schema, config2.plugins);
17529
17529
  let fields = $config.fields, instance = new EditorState($config);
17530
17530
  for (let i = 0; i < fields.length; i++) {
17531
17531
  let name = fields[i].name;
17532
- instance[name] = this.hasOwnProperty(name) ? this[name] : fields[i].init(config, instance);
17532
+ instance[name] = this.hasOwnProperty(name) ? this[name] : fields[i].init(config2, instance);
17533
17533
  }
17534
17534
  return instance;
17535
17535
  }
@@ -17561,31 +17561,31 @@ class EditorState {
17561
17561
  to deserialize the state of plugins, by associating plugin
17562
17562
  instances with the property names they use in the JSON object.
17563
17563
  */
17564
- static fromJSON(config, json, pluginFields) {
17564
+ static fromJSON(config2, json, pluginFields) {
17565
17565
  if (!json)
17566
17566
  throw new RangeError("Invalid input for EditorState.fromJSON");
17567
- if (!config.schema)
17567
+ if (!config2.schema)
17568
17568
  throw new RangeError("Required config field 'schema' missing");
17569
- let $config = new Configuration(config.schema, config.plugins);
17569
+ let $config = new Configuration(config2.schema, config2.plugins);
17570
17570
  let instance = new EditorState($config);
17571
17571
  $config.fields.forEach((field) => {
17572
17572
  if (field.name == "doc") {
17573
- instance.doc = Node$1.fromJSON(config.schema, json.doc);
17573
+ instance.doc = Node$1.fromJSON(config2.schema, json.doc);
17574
17574
  } else if (field.name == "selection") {
17575
17575
  instance.selection = Selection.fromJSON(instance.doc, json.selection);
17576
17576
  } else if (field.name == "storedMarks") {
17577
17577
  if (json.storedMarks)
17578
- instance.storedMarks = json.storedMarks.map(config.schema.markFromJSON);
17578
+ instance.storedMarks = json.storedMarks.map(config2.schema.markFromJSON);
17579
17579
  } else {
17580
17580
  if (pluginFields)
17581
17581
  for (let prop in pluginFields) {
17582
17582
  let plugin = pluginFields[prop], state2 = plugin.spec.state;
17583
17583
  if (plugin.key == field.name && state2 && state2.fromJSON && Object.prototype.hasOwnProperty.call(json, prop)) {
17584
- instance[field.name] = state2.fromJSON.call(plugin, config, json[prop], instance);
17584
+ instance[field.name] = state2.fromJSON.call(plugin, config2, json[prop], instance);
17585
17585
  return;
17586
17586
  }
17587
17587
  }
17588
- instance[field.name] = field.init(config, instance);
17588
+ instance[field.name] = field.init(config2, instance);
17589
17589
  }
17590
17590
  });
17591
17591
  return instance;
@@ -23838,11 +23838,11 @@ function mergeSeparateLists(container) {
23838
23838
  return tempCont;
23839
23839
  }
23840
23840
  class InputRule {
23841
- constructor(config) {
23841
+ constructor(config2) {
23842
23842
  __publicField(this, "match");
23843
23843
  __publicField(this, "handler");
23844
- this.match = config.match;
23845
- this.handler = config.handler;
23844
+ this.match = config2.match;
23845
+ this.handler = config2.handler;
23846
23846
  }
23847
23847
  }
23848
23848
  const inputRuleMatcherHandler = (text, match) => {
@@ -23865,8 +23865,8 @@ const inputRuleMatcherHandler = (text, match) => {
23865
23865
  }
23866
23866
  return result;
23867
23867
  };
23868
- const run = (config) => {
23869
- const { editor, from, to, text, rules, plugin } = config;
23868
+ const run = (config2) => {
23869
+ const { editor, from, to, text, rules, plugin } = config2;
23870
23870
  const { view } = editor;
23871
23871
  if (view.composing) {
23872
23872
  return false;
@@ -23895,7 +23895,7 @@ const run = (config) => {
23895
23895
  editor,
23896
23896
  state: state2
23897
23897
  });
23898
- const handler = rule.handler({
23898
+ const handler2 = rule.handler({
23899
23899
  state: state2,
23900
23900
  range: range2,
23901
23901
  match,
@@ -23903,7 +23903,7 @@ const run = (config) => {
23903
23903
  chain,
23904
23904
  can
23905
23905
  });
23906
- if (handler === null || !tr.steps.length) {
23906
+ if (handler2 === null || !tr.steps.length) {
23907
23907
  return;
23908
23908
  }
23909
23909
  tr.setMeta(plugin, {
@@ -25392,6 +25392,250 @@ const generateSdtPrTagForDocumentSection = (id, title, tag) => {
25392
25392
  ]
25393
25393
  };
25394
25394
  };
25395
+ const TranslatorTypes = Object.freeze({
25396
+ NODE: "node",
25397
+ ATTRIBUTE: "attribute"
25398
+ });
25399
+ const _NodeTranslator = class _NodeTranslator {
25400
+ /**
25401
+ * @param {string} xmlName
25402
+ * @param {string} sdNodeOrKeyName
25403
+ * @param {NodeTranslatorEncodeFn} encode
25404
+ * @param {NodeTranslatorDecodeFn} decode
25405
+ * @param {number} [priority]
25406
+ * @param {MatchesEncodeFn} [matchesEncode]
25407
+ * @param {MatchesDecodeFn} [matchesDecode]
25408
+ * @param {AttributesHandlerList[]} [attributes]
25409
+ */
25410
+ constructor(xmlName, sdNodeOrKeyName, encode2, decode2, priority, matchesEncode, matchesDecode, attributes) {
25411
+ /** @type {string} */
25412
+ __publicField(this, "xmlName");
25413
+ /** @type {string} */
25414
+ __publicField(this, "sdNodeOrKeyName");
25415
+ /** @type {number} */
25416
+ __publicField(this, "priority");
25417
+ /** @type {NodeTranslatorEncodeFn} */
25418
+ __publicField(this, "encodeFn");
25419
+ /** @type {NodeTranslatorDecodeFn} */
25420
+ __publicField(this, "decodeFn");
25421
+ /** @type {MatchesEncodeFn} */
25422
+ __publicField(this, "matchesEncode");
25423
+ /** @type {MatchesDecodeFn} */
25424
+ __publicField(this, "matchesDecode");
25425
+ /** @type {AttributesHandlerList[]} */
25426
+ __publicField(this, "attributes");
25427
+ this.xmlName = xmlName;
25428
+ this.sdNodeOrKeyName = sdNodeOrKeyName;
25429
+ this.encodeFn = encode2;
25430
+ this.decodeFn = decode2;
25431
+ this.attributes = attributes || [];
25432
+ this.priority = typeof priority === "number" ? priority : 0;
25433
+ this.matchesEncode = typeof matchesEncode === "function" ? matchesEncode : () => true;
25434
+ this.matchesDecode = typeof matchesDecode === "function" ? matchesDecode : () => true;
25435
+ }
25436
+ /**
25437
+ * Encode the attributes for the node.
25438
+ * @param {SCEncoderConfig} params
25439
+ * @returns {Object} Encoded attributes object.
25440
+ */
25441
+ encodeAttributes(params) {
25442
+ const { nodes = [] } = params || {};
25443
+ const node2 = nodes[0];
25444
+ const { attributes = {} } = node2 || {};
25445
+ const encodedAttrs = {};
25446
+ this.attributes.forEach(({ sdName, encode: encode2 }) => {
25447
+ if (!encode2) return;
25448
+ const encodedAttr = encode2(attributes);
25449
+ if (encodedAttr !== void 0 && encodedAttr !== null) {
25450
+ encodedAttrs[sdName] = encodedAttr;
25451
+ }
25452
+ });
25453
+ return encodedAttrs;
25454
+ }
25455
+ /**
25456
+ * Decode the attributes for the node.
25457
+ * @param {SCDecoderConfig} params
25458
+ * @returns {Object} Decoded attributes object.
25459
+ */
25460
+ decodeAttributes(params) {
25461
+ const { node: node2 } = params || {};
25462
+ const { attrs = {} } = node2 || {};
25463
+ const decodedAttrs = {};
25464
+ this.attributes.forEach(({ xmlName, decode: decode2 }) => {
25465
+ if (!decode2) return;
25466
+ const decodedAttr = decode2(attrs);
25467
+ if (decodedAttr !== void 0 && decodedAttr !== null) {
25468
+ decodedAttrs[xmlName] = decodedAttr;
25469
+ }
25470
+ });
25471
+ return decodedAttrs;
25472
+ }
25473
+ /**
25474
+ * Decode the attributes for the node.
25475
+ * @param {SCDecoderConfig} params
25476
+ * @returns {Object} Decoded attributes object.
25477
+ */
25478
+ decode(params) {
25479
+ const decodedAttrs = this.decodeAttributes(params);
25480
+ return this.decodeFn ? this.decodeFn(params, decodedAttrs) : void 0;
25481
+ }
25482
+ /**
25483
+ * Encode the attributes for the node.
25484
+ * @param {SCEncoderConfig} params
25485
+ * @returns {Object} Encoded attributes object.
25486
+ */
25487
+ encode(params) {
25488
+ const encodedAttrs = this.encodeAttributes(params);
25489
+ return this.encodeFn ? this.encodeFn(params, encodedAttrs) : void 0;
25490
+ }
25491
+ /**
25492
+ * Create a new NodeTranslator instance from a configuration object.
25493
+ * @param {NodeTranslatorConfig} config - The configuration object.
25494
+ * @returns {NodeTranslator} The created NodeTranslator instance.
25495
+ */
25496
+ static from(config2) {
25497
+ const { xmlName, sdNodeOrKeyName, encode: encode2, decode: decode2, priority = 0, matchesEncode, matchesDecode, attributes } = config2;
25498
+ if (typeof encode2 !== "function" || !!decode2 && typeof decode2 !== "function") {
25499
+ throw new TypeError(`${xmlName}: encode/decode must be functions`);
25500
+ }
25501
+ const inst = new _NodeTranslator(
25502
+ xmlName,
25503
+ sdNodeOrKeyName,
25504
+ encode2,
25505
+ decode2,
25506
+ priority,
25507
+ matchesEncode,
25508
+ matchesDecode,
25509
+ attributes
25510
+ );
25511
+ return Object.freeze(inst);
25512
+ }
25513
+ /**
25514
+ * Convert the NodeTranslator instance to a string representation.
25515
+ * @returns {string} - The string representation of the NodeTranslator instance.
25516
+ */
25517
+ toString() {
25518
+ return `NodeTranslator(${this.xmlName}, priority=${this.priority})`;
25519
+ }
25520
+ };
25521
+ /** @type {typeof TranslatorTypes} */
25522
+ __publicField(_NodeTranslator, "translatorTypes", TranslatorTypes);
25523
+ let NodeTranslator = _NodeTranslator;
25524
+ const lineBreakTypeEncoder = (attributes) => {
25525
+ return attributes["w:type"];
25526
+ };
25527
+ const lineBreakTypeDecoder = (attrs) => {
25528
+ const { lineBreakType } = attrs;
25529
+ return lineBreakType;
25530
+ };
25531
+ const wClearEncoder = (attributes) => {
25532
+ const xmlAttrValue = attributes["w:clear"];
25533
+ return xmlAttrValue;
25534
+ };
25535
+ const wClearDecoder = (attrs) => {
25536
+ const { clear } = attrs;
25537
+ return clear;
25538
+ };
25539
+ const XML_NODE_NAME$1 = "w:br";
25540
+ const SD_NODE_NAME$1 = "lineBreak";
25541
+ const validXmlAttributes$1 = [
25542
+ { xmlName: "w:type", sdName: "lineBreakType", encode: lineBreakTypeEncoder, decode: lineBreakTypeDecoder },
25543
+ { xmlName: "w:clear", sdName: "clear", encode: wClearEncoder, decode: wClearDecoder }
25544
+ ];
25545
+ const encode$1 = (_2, encodedAttrs) => {
25546
+ const isPageBreak = encodedAttrs?.lineBreakType === "page";
25547
+ const translated = {
25548
+ type: isPageBreak ? "hardBreak" : "lineBreak"
25549
+ };
25550
+ if (encodedAttrs) {
25551
+ translated.attrs = { ...encodedAttrs };
25552
+ }
25553
+ return translated;
25554
+ };
25555
+ const decode$1 = (params, decodedAttrs) => {
25556
+ const { node: node2 } = params;
25557
+ if (!node2) return;
25558
+ const wBreak = { name: "w:br" };
25559
+ if (decodedAttrs) {
25560
+ wBreak.attributes = { ...decodedAttrs };
25561
+ }
25562
+ const isPageBreak = node2.type === "hardBreak";
25563
+ if (isPageBreak && (!wBreak.attributes || !wBreak.attributes["w:type"])) {
25564
+ wBreak.attributes = { ...wBreak.attributes, "w:type": "page" };
25565
+ }
25566
+ const translated = {
25567
+ name: "w:r",
25568
+ elements: [wBreak]
25569
+ };
25570
+ return translated;
25571
+ };
25572
+ const config$1 = {
25573
+ xmlName: XML_NODE_NAME$1,
25574
+ sdNodeOrKeyName: SD_NODE_NAME$1,
25575
+ type: NodeTranslator.translatorTypes.NODE,
25576
+ encode: encode$1,
25577
+ decode: decode$1,
25578
+ attributes: validXmlAttributes$1
25579
+ };
25580
+ const translator$1 = NodeTranslator.from(config$1);
25581
+ const tabSizeEncoder = (attributes) => {
25582
+ return attributes["w:val"];
25583
+ };
25584
+ const tabSizeDecoder = (attrs) => {
25585
+ const { tabSize } = attrs;
25586
+ return tabSize;
25587
+ };
25588
+ const tabLeaderEncoder = (attributes) => {
25589
+ return attributes["w:leader"];
25590
+ };
25591
+ const tabLeaderDecoder = (attrs) => {
25592
+ const { leader } = attrs;
25593
+ return leader;
25594
+ };
25595
+ const tabPositionEncoder = (attributes) => {
25596
+ return attributes["w:pos"];
25597
+ };
25598
+ const tabPositionDecoder = (attrs) => {
25599
+ const { pos } = attrs;
25600
+ return pos;
25601
+ };
25602
+ const XML_NODE_NAME = "w:tab";
25603
+ const SD_NODE_NAME = "tab";
25604
+ const validXmlAttributes = [
25605
+ { xmlName: "w:val", sdName: "tabSize", encode: tabSizeEncoder, decode: tabSizeDecoder },
25606
+ { xmlName: "w:pos", sdName: "pos", encode: tabPositionEncoder, decode: tabPositionDecoder },
25607
+ { xmlName: "w:leader", sdName: "leader", encode: tabLeaderEncoder, decode: tabLeaderDecoder }
25608
+ ];
25609
+ const encode = (_2, encodedAttrs = {}) => {
25610
+ const translated = { type: "tab" };
25611
+ if (encodedAttrs) translated.attrs = { ...encodedAttrs };
25612
+ return translated;
25613
+ };
25614
+ const decode = (params, decodedAttrs = {}) => {
25615
+ const { node: node2 } = params || {};
25616
+ if (!node2) return;
25617
+ const wTab = { name: "w:tab" };
25618
+ if (decodedAttrs) wTab.attributes = { ...decodedAttrs };
25619
+ const translated = {
25620
+ name: "w:r",
25621
+ elements: [wTab]
25622
+ };
25623
+ const { marks: nodeMarks = [] } = node2;
25624
+ const outputMarks = processOutputMarks(nodeMarks);
25625
+ if (outputMarks.length) {
25626
+ translated.elements.unshift(generateRunProps(outputMarks));
25627
+ }
25628
+ return translated;
25629
+ };
25630
+ const config = {
25631
+ xmlName: XML_NODE_NAME,
25632
+ sdNodeOrKeyName: SD_NODE_NAME,
25633
+ type: NodeTranslator.translatorTypes.NODE,
25634
+ encode,
25635
+ decode,
25636
+ attributes: validXmlAttributes
25637
+ };
25638
+ const translator = NodeTranslator.from(config);
25395
25639
  function exportSchemaToJson(params) {
25396
25640
  const { type: type2 } = params.node || {};
25397
25641
  const router = {
@@ -25402,15 +25646,15 @@ function exportSchemaToJson(params) {
25402
25646
  text: translateTextNode,
25403
25647
  bulletList: translateList,
25404
25648
  orderedList: translateList,
25405
- lineBreak: translateLineBreak,
25649
+ lineBreak: translator$1,
25406
25650
  table: translateTable,
25407
25651
  tableRow: translateTableRow,
25408
25652
  tableCell: translateTableCell,
25409
25653
  bookmarkStart: translateBookmarkStart,
25410
25654
  fieldAnnotation: translateFieldAnnotation,
25411
- tab: translateTab,
25655
+ tab: translator,
25412
25656
  image: translateImageNode,
25413
- hardBreak: translateHardBreak,
25657
+ hardBreak: translator$1,
25414
25658
  commentRangeStart: () => translateCommentNode(params, "Start"),
25415
25659
  commentRangeEnd: () => translateCommentNode(params, "End"),
25416
25660
  commentReference: () => null,
@@ -25423,11 +25667,15 @@ function exportSchemaToJson(params) {
25423
25667
  "page-number": translatePageNumberNode,
25424
25668
  "total-page-number": translateTotalPageNumberNode
25425
25669
  };
25426
- if (!router[type2]) {
25670
+ let handler2 = router[type2];
25671
+ if (handler2 && "decode" in handler2 && typeof handler2.decode === "function") {
25672
+ return handler2.decode(params);
25673
+ }
25674
+ if (!handler2) {
25427
25675
  console.error("No translation function found for node type:", type2);
25428
25676
  return null;
25429
25677
  }
25430
- return router[type2](params);
25678
+ return handler2(params);
25431
25679
  }
25432
25680
  function translateBodyNode(params) {
25433
25681
  let sectPr = params.bodyNode?.elements.find((n) => n.name === "w:sectPr") || {};
@@ -25621,9 +25869,10 @@ function generateParagraphProperties(node2) {
25621
25869
  const { tabStops } = attrs;
25622
25870
  if (tabStops && tabStops.length > 0) {
25623
25871
  const tabElements = tabStops.map((tab) => {
25872
+ const posValue = tab.originalPos !== void 0 ? tab.originalPos : pixelsToTwips(tab.pos).toString();
25624
25873
  const tabAttributes = {
25625
25874
  "w:val": tab.val || "start",
25626
- "w:pos": pixelsToTwips(tab.pos).toString()
25875
+ "w:pos": posValue
25627
25876
  };
25628
25877
  if (tab.leader) {
25629
25878
  tabAttributes["w:leader"] = tab.leader;
@@ -26047,23 +26296,6 @@ const generateNumPrTag = (numId, level) => {
26047
26296
  ]
26048
26297
  };
26049
26298
  };
26050
- function translateLineBreak(params) {
26051
- const attributes = {};
26052
- const { lineBreakType } = params.node?.attrs || {};
26053
- if (lineBreakType) {
26054
- attributes["w:type"] = lineBreakType;
26055
- }
26056
- return {
26057
- name: "w:r",
26058
- elements: [
26059
- {
26060
- name: "w:br",
26061
- attributes
26062
- }
26063
- ],
26064
- attributes
26065
- };
26066
- }
26067
26299
  function translateTable(params) {
26068
26300
  params.node = preProcessVerticalMergeCells(params.node, params);
26069
26301
  const elements = translateChildNodes(params);
@@ -26110,14 +26342,6 @@ function preProcessVerticalMergeCells(table, { editorSchema }) {
26110
26342
  }
26111
26343
  return table;
26112
26344
  }
26113
- function translateTab(params) {
26114
- const { marks = [] } = params.node;
26115
- const outputMarks = processOutputMarks(marks);
26116
- const tabNode = {
26117
- name: "w:tab"
26118
- };
26119
- return wrapTextInRun(tabNode, outputMarks);
26120
- }
26121
26345
  function generateTableProperties(node2) {
26122
26346
  const elements = [];
26123
26347
  const { attrs } = node2;
@@ -26956,22 +27180,6 @@ function translateFieldAnnotation(params) {
26956
27180
  };
26957
27181
  return result;
26958
27182
  }
26959
- function translateHardBreak(params) {
26960
- const { node: node2 = {} } = params;
26961
- const { attrs = {} } = node2;
26962
- const { pageBreakSource } = attrs;
26963
- if (pageBreakSource === "sectPr") return null;
26964
- return {
26965
- name: "w:r",
26966
- elements: [
26967
- {
26968
- name: "w:br",
26969
- type: "element",
26970
- attributes: { "w:type": "page" }
26971
- }
26972
- ]
26973
- };
26974
- }
26975
27183
  function translateShapeContainer(params) {
26976
27184
  const { node: node2 } = params;
26977
27185
  const elements = translateChildNodes(params);
@@ -28471,10 +28679,14 @@ const handleParagraphNode = (params) => {
28471
28679
  } else if (val == "right") {
28472
28680
  val = "end";
28473
28681
  }
28682
+ const rawPos = tab.attributes["w:pos"];
28474
28683
  const tabStop = {
28475
28684
  val,
28476
- pos: twipsToPixels(tab.attributes["w:pos"])
28685
+ pos: twipsToPixels(rawPos)
28477
28686
  };
28687
+ if (rawPos !== void 0) {
28688
+ tabStop.originalPos = rawPos;
28689
+ }
28478
28690
  if (tab.attributes["w:leader"]) {
28479
28691
  tabStop.leader = tab.attributes["w:leader"];
28480
28692
  }
@@ -28827,8 +29039,8 @@ const handleDocPartObj = (params) => {
28827
29039
  return { nodes: [], consumed: 0 };
28828
29040
  }
28829
29041
  const content = node2?.elements.find((el) => el.name === "w:sdtContent");
28830
- const handler = validGalleryTypeMap[docPartGalleryType];
28831
- const result = handler({ ...params, nodes: [content] });
29042
+ const handler2 = validGalleryTypeMap[docPartGalleryType];
29043
+ const result = handler2({ ...params, nodes: [content] });
28832
29044
  return {
28833
29045
  nodes: result,
28834
29046
  consumed: 1
@@ -29094,25 +29306,21 @@ const standardNodeHandlerEntity = {
29094
29306
  handlerName: "standardNodeHandler",
29095
29307
  handler: handleStandardNode
29096
29308
  };
29097
- const handleLineBreakNode = (params) => {
29309
+ const handler = (params) => {
29098
29310
  const { nodes } = params;
29099
29311
  if (nodes.length === 0 || nodes[0].name !== "w:br") {
29100
29312
  return { nodes: [], consumed: 0 };
29101
29313
  }
29102
- const lineBreakType = nodes[0].attributes?.["w:type"];
29103
- const breakType = lineBreakType === "page" ? "hardBreak" : "lineBreak";
29314
+ const result = translator$1.encode(params);
29315
+ if (!result) return { nodes: [], consumed: 0 };
29104
29316
  return {
29105
- nodes: [
29106
- {
29107
- type: breakType
29108
- }
29109
- ],
29317
+ nodes: [result],
29110
29318
  consumed: 1
29111
29319
  };
29112
29320
  };
29113
29321
  const lineBreakNodeHandlerEntity = {
29114
29322
  handlerName: "lineBreakNodeHandler",
29115
- handler: handleLineBreakNode
29323
+ handler
29116
29324
  };
29117
29325
  const handleBookmarkNode = (params) => {
29118
29326
  const { nodes, nodeListHandler: nodeListHandler2, editor } = params;
@@ -29237,34 +29445,6 @@ const autoTotalPageCountEntity = {
29237
29445
  handlerName: "autoTotalPageCountEntity",
29238
29446
  handler: handleAutoTotalPageNumber
29239
29447
  };
29240
- const handleTabNode = (params) => {
29241
- const { nodes, docx, parentStyleId } = params;
29242
- if (nodes.length === 0 || nodes[0].name !== "w:tab") {
29243
- return { nodes: [], consumed: 0 };
29244
- }
29245
- const node2 = nodes[0];
29246
- const styles = docx["word/styles.xml"];
29247
- if (styles && styles.elements?.length) {
29248
- const style = styles.elements[0]?.elements?.find((s) => s.attributes?.["w:styleId"] === parentStyleId);
29249
- const pPr = style?.elements?.find((s) => s.name === "w:pPr");
29250
- const tabsDef = pPr?.elements?.find((s) => s.name === "w:tabs");
29251
- const firstTab = tabsDef?.elements?.find((s) => s.name === "w:tab");
29252
- twipsToPixels(firstTab?.attributes?.["w:pos"]);
29253
- }
29254
- const { attributes = {} } = node2;
29255
- const processedNode = {
29256
- type: "tab",
29257
- attrs: {
29258
- tabSize: attributes["w:val"] || 48
29259
- },
29260
- content: []
29261
- };
29262
- return { nodes: [processedNode], consumed: 1 };
29263
- };
29264
- const tabNodeEntityHandler = {
29265
- handlerName: "tabNodeHandler",
29266
- handler: handleTabNode
29267
- };
29268
29448
  const handlePictNode = (params) => {
29269
29449
  const { nodes } = params;
29270
29450
  if (!nodes.length || nodes[0].name !== "w:p") {
@@ -29564,6 +29744,18 @@ const getExtendedDetails = (commentEx) => {
29564
29744
  };
29565
29745
  const IGNORED_NODE_NAMES = ["w:proofErr", "w:lastRenderedPageBreak"];
29566
29746
  const pruneIgnoredNodes = (nodes = []) => nodes.filter((node2) => !IGNORED_NODE_NAMES.includes(node2.name)).map((node2) => node2.elements ? { ...node2, elements: pruneIgnoredNodes(node2.elements) } : node2);
29747
+ const handleTabNode = (params) => {
29748
+ const { nodes } = params;
29749
+ if (!nodes.length || nodes[0].name !== "w:tab") {
29750
+ return { nodes: [], consumed: 0 };
29751
+ }
29752
+ const node2 = translator.encode(params);
29753
+ return { nodes: [node2], consumed: 1 };
29754
+ };
29755
+ const tabNodeEntityHandler = {
29756
+ handlerName: "w:tabTranslator",
29757
+ handler: handleTabNode
29758
+ };
29567
29759
  const createDocumentJson = (docx, converter, editor) => {
29568
29760
  const json = carbonCopy(getInitialJSON(docx));
29569
29761
  if (!json) return null;
@@ -29648,11 +29840,10 @@ const defaultNodeListHandler = () => {
29648
29840
  autoPageHandlerEntity,
29649
29841
  autoTotalPageCountEntity,
29650
29842
  standardNodeHandlerEntity
29651
- // This is the last one as it can handle everything
29652
29843
  ];
29653
- const handler = createNodeListHandler(entities);
29844
+ const handler2 = createNodeListHandler(entities);
29654
29845
  return {
29655
- handler,
29846
+ handler: handler2,
29656
29847
  handlerEntities: entities
29657
29848
  };
29658
29849
  };
@@ -29697,9 +29888,9 @@ const createNodeListHandler = (nodeHandlers) => {
29697
29888
  continue;
29698
29889
  }
29699
29890
  const { nodes, consumed, unhandled } = nodeHandlers.reduce(
29700
- (res, handler) => {
29891
+ (res, handler2) => {
29701
29892
  if (res.consumed > 0) return res;
29702
- return handler.handler({
29893
+ return handler2.handler({
29703
29894
  nodes: nodesToHandle,
29704
29895
  docx,
29705
29896
  nodeListHandler: { handler: nodeListHandlerFn, handlerEntities: nodeHandlers },
@@ -30714,7 +30905,9 @@ export {
30714
30905
  readFromClipboard as aB,
30715
30906
  handleClipboardPaste as aC,
30716
30907
  getFileObject as aD,
30717
- _sfc_main as aE,
30908
+ translator as aE,
30909
+ translator$1 as aF,
30910
+ _sfc_main as aG,
30718
30911
  isActive as aa,
30719
30912
  unflattenListsInHtml as ab,
30720
30913
  parseSizeUnit as ac,