superdoc 1.2.1 → 1.3.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.
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const vue = require("./vue-De9wkgLl.cjs");
4
- const superdoc = require("./index-CQcBu0ln.cjs");
5
- const index = require("./index-MvYBJo1p.cjs");
4
+ const superdoc = require("./index-BbvMtiJY.cjs");
5
+ const index = require("./index-BNpbdx2a.cjs");
6
6
  function self(vars) {
7
7
  const {
8
8
  opacityDisabled,
@@ -1,6 +1,6 @@
1
1
  import { d as defineComponent, h, T as Transition, p as process$1, w as watchEffect, c as computed, r as ref, f as onMounted, X as onUnmounted, E as createElementBlock, G as openBlock, K as createBaseVNode, M as createCommentVNode, I as createVNode, v as unref } from "./vue-BnBKJwCW.es.js";
2
- import { N as NBaseLoading, u as useSuperdocStore, s as storeToRefs, a as useSelection } from "./index-L4O68_fZ.es.js";
3
- import { C as derived, r as c, q as cB, aF as fadeInTransition, y as cM, I as warnOnce, J as useConfig, N as useTheme, aG as pxfy, P as createKey, Q as useThemeClass, aH as useCompitable, ai as _export_sfc } from "./index-DUHBiOz0.es.js";
2
+ import { N as NBaseLoading, u as useSuperdocStore, s as storeToRefs, a as useSelection } from "./index-C31VY_46.es.js";
3
+ import { C as derived, r as c, q as cB, aF as fadeInTransition, y as cM, I as warnOnce, J as useConfig, N as useTheme, aG as pxfy, P as createKey, Q as useThemeClass, aH as useCompitable, ai as _export_sfc } from "./index-wwGlJ58Z.es.js";
4
4
  function self(vars) {
5
5
  const {
6
6
  opacityDisabled,
@@ -1,5 +1,5 @@
1
1
  import { B as Buffer, c as commonjsGlobal, g as getDefaultExportFromCjs$1 } from "./jszip-B1fkPkPJ.es.js";
2
- import { h as getDocxHighlightKeywordFromHex, n as normalizeHexColor, p as ptToTwips, j as isValidHexColor, k as getHexColorFromDocxSystem, m as twipsToPt, o as halfPointToPoints, c as twipsToPixels, q as eighthPointsToPixels, l as linesToTwips, a as twipsToLines, t as twipsToInches, b as pixelsToTwips, i as inchesToTwips, r as pixelsToEightPoints, s as emuToPixels, u as polygonToObj, v as rotToDegrees, w as pointsToTwips, x as pixelsToEmu, y as degreesToRot, z as objToPolygon, f as libExports, A as rgbToHex, B as deobfuscateFont, C as getArrayBufferFromUrl } from "./helpers-CAUq8coh.es.js";
2
+ import { j as getDocxHighlightKeywordFromHex, n as normalizeHexColor, p as ptToTwips, k as isValidHexColor, m as getHexColorFromDocxSystem, h as halfPointToPoints, o as twipsToPt, c as twipsToPixels, q as eighthPointsToPixels, l as linesToTwips, a as twipsToLines, t as twipsToInches, b as pixelsToTwips, i as inchesToTwips, r as pixelsToEightPoints, s as emuToPixels, u as polygonToObj, v as rotToDegrees, w as pointsToTwips, x as pixelsToEmu, y as degreesToRot, z as objToPolygon, f as libExports, A as rgbToHex, B as deobfuscateFont, C as getArrayBufferFromUrl } from "./helpers-C8e9wR5l.es.js";
3
3
  import { v as v4 } from "./uuid-CjlX8hrF.es.js";
4
4
  function getDefaultExportFromCjs(x2) {
5
5
  return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
@@ -7483,8 +7483,18 @@ function getUnderlineCssString({ type = "single", color = null, thickness = null
7483
7483
  if (color) add("text-decoration-color", color);
7484
7484
  return parts.join("; ");
7485
7485
  }
7486
- const INLINE_OVERRIDE_PROPERTIES = ["fontSize", "bold", "italic", "strike", "underline", "letterSpacing"];
7486
+ const INLINE_OVERRIDE_PROPERTIES = [
7487
+ "fontSize",
7488
+ "bold",
7489
+ "italic",
7490
+ "strike",
7491
+ "underline",
7492
+ "letterSpacing",
7493
+ "vertAlign",
7494
+ "position"
7495
+ ];
7487
7496
  const DEFAULT_FONT_SIZE_HALF_POINTS = 20;
7497
+ const SUBSCRIPT_SUPERSCRIPT_SCALE = 0.65;
7488
7498
  const resolveRunProperties = (params, inlineRpr, resolvedPpr, isListNumber = false, numberingDefinedInline = false) => {
7489
7499
  const paragraphStyleId = resolvedPpr?.styleId;
7490
7500
  const paragraphStyleProps = resolveStyleChain(params, paragraphStyleId, translator$1O);
@@ -7832,6 +7842,21 @@ function encodeMarksFromRPr(runProperties, docx) {
7832
7842
  }
7833
7843
  break;
7834
7844
  }
7845
+ case "vertAlign": {
7846
+ if (value) {
7847
+ textStyleAttrs.vertAlign = value;
7848
+ }
7849
+ break;
7850
+ }
7851
+ case "position": {
7852
+ if (value != null && Number.isFinite(value)) {
7853
+ const points2 = halfPointToPoints(value);
7854
+ if (Number.isFinite(points2)) {
7855
+ textStyleAttrs.position = `${points2}pt`;
7856
+ }
7857
+ }
7858
+ break;
7859
+ }
7835
7860
  }
7836
7861
  });
7837
7862
  if (Object.keys(textStyleAttrs).length) {
@@ -7946,6 +7971,8 @@ function encodeCSSFromRPr(runProperties, docx) {
7946
7971
  let hasTextDecorationNone = false;
7947
7972
  let highlightColor = null;
7948
7973
  let hasHighlightTag = false;
7974
+ let verticalAlignValue;
7975
+ let fontSizeOverride;
7949
7976
  Object.keys(runProperties).forEach((key) => {
7950
7977
  const value = runProperties[key];
7951
7978
  switch (key) {
@@ -8076,6 +8103,35 @@ function encodeCSSFromRPr(runProperties, docx) {
8076
8103
  }
8077
8104
  break;
8078
8105
  }
8106
+ case "vertAlign": {
8107
+ if (runProperties.position != null && Number.isFinite(runProperties.position)) {
8108
+ break;
8109
+ }
8110
+ if (value === "superscript" || value === "subscript") {
8111
+ verticalAlignValue = value === "superscript" ? "super" : "sub";
8112
+ if (runProperties.fontSize != null && Number.isFinite(runProperties.fontSize)) {
8113
+ const scaledPoints = halfPointToPoints(runProperties.fontSize * SUBSCRIPT_SUPERSCRIPT_SCALE);
8114
+ if (Number.isFinite(scaledPoints)) {
8115
+ fontSizeOverride = `${scaledPoints}pt`;
8116
+ }
8117
+ } else {
8118
+ fontSizeOverride = `${SUBSCRIPT_SUPERSCRIPT_SCALE * 100}%`;
8119
+ }
8120
+ } else if (value === "baseline") {
8121
+ verticalAlignValue = "baseline";
8122
+ }
8123
+ break;
8124
+ }
8125
+ case "position": {
8126
+ if (value != null && Number.isFinite(value)) {
8127
+ const points = halfPointToPoints(value);
8128
+ if (Number.isFinite(points)) {
8129
+ verticalAlignValue = `${points}pt`;
8130
+ fontSizeOverride = void 0;
8131
+ }
8132
+ }
8133
+ break;
8134
+ }
8079
8135
  }
8080
8136
  });
8081
8137
  if (!hasTextDecorationNone && textDecorationLines.size) {
@@ -8090,6 +8146,12 @@ function encodeCSSFromRPr(runProperties, docx) {
8090
8146
  css["color"] = "inherit";
8091
8147
  }
8092
8148
  }
8149
+ if (fontSizeOverride) {
8150
+ css["font-size"] = fontSizeOverride;
8151
+ }
8152
+ if (verticalAlignValue) {
8153
+ css["vertical-align"] = verticalAlignValue;
8154
+ }
8093
8155
  return css;
8094
8156
  }
8095
8157
  function decodeRPrFromMarks(marks) {
@@ -8166,6 +8228,20 @@ function decodeRPrFromMarks(marks) {
8166
8228
  runProperties.fontFamily = result;
8167
8229
  }
8168
8230
  break;
8231
+ case "vertAlign":
8232
+ if (value != null) {
8233
+ runProperties.vertAlign = value;
8234
+ }
8235
+ break;
8236
+ case "position": {
8237
+ if (value != null) {
8238
+ const numeric = parseFloat(value);
8239
+ if (!isNaN(numeric)) {
8240
+ runProperties.position = numeric * 2;
8241
+ }
8242
+ }
8243
+ break;
8244
+ }
8169
8245
  }
8170
8246
  });
8171
8247
  break;
@@ -9053,6 +9129,17 @@ const attrConfig$f = Object.freeze({
9053
9129
  const validXmlAttributes$b = [attrConfig$h, attrConfig$g, attrConfig$f];
9054
9130
  const XML_NODE_NAME$k = "w:r";
9055
9131
  const SD_KEY_NAME = "run";
9132
+ const createRunNodeWithContent = (content, encodedAttrs, runLevelMarks, runProperties) => {
9133
+ const node = {
9134
+ type: SD_KEY_NAME,
9135
+ content,
9136
+ attrs: { ...encodedAttrs, runProperties }
9137
+ };
9138
+ if (runLevelMarks.length) {
9139
+ node.marks = runLevelMarks.map((mark) => cloneMark$1(mark));
9140
+ }
9141
+ return node;
9142
+ };
9056
9143
  const encode$x = (params, encodedAttrs = {}) => {
9057
9144
  const { nodes = [], nodeListHandler } = params || {};
9058
9145
  const runNode = nodes[0];
@@ -9097,15 +9184,30 @@ const encode$x = (params, encodedAttrs = {}) => {
9097
9184
  return { ...child, marks: childMarks };
9098
9185
  });
9099
9186
  const filtered = contentWithRunMarks.filter(Boolean);
9100
- const runNodeResult = {
9101
- type: SD_KEY_NAME,
9102
- content: filtered,
9103
- attrs: { ...encodedAttrs, runProperties }
9187
+ const containsBreakNodes = filtered.some((child) => child?.type === "lineBreak");
9188
+ if (!containsBreakNodes) {
9189
+ const defaultNode = createRunNodeWithContent(filtered, encodedAttrs, runLevelMarks, runProperties);
9190
+ return defaultNode;
9191
+ }
9192
+ const splitRuns = [];
9193
+ let currentChunk = [];
9194
+ const finalizeTextChunk = () => {
9195
+ if (!currentChunk.length) return;
9196
+ const chunkNode = createRunNodeWithContent(currentChunk, encodedAttrs, runLevelMarks, runProperties);
9197
+ if (chunkNode) splitRuns.push(chunkNode);
9198
+ currentChunk = [];
9104
9199
  };
9105
- if (runLevelMarks.length) {
9106
- runNodeResult.marks = runLevelMarks;
9107
- }
9108
- return runNodeResult;
9200
+ filtered.forEach((child) => {
9201
+ if (child?.type === "lineBreak") {
9202
+ finalizeTextChunk();
9203
+ const breakNode = createRunNodeWithContent([child], encodedAttrs, runLevelMarks, runProperties);
9204
+ if (breakNode) splitRuns.push(breakNode);
9205
+ } else {
9206
+ currentChunk.push(child);
9207
+ }
9208
+ });
9209
+ finalizeTextChunk();
9210
+ return splitRuns;
9109
9211
  };
9110
9212
  const decode$z = (params, decodedAttrs = {}) => {
9111
9213
  const { node } = params || {};
@@ -30737,7 +30839,7 @@ class SuperConverter {
30737
30839
  static getStoredSuperdocVersion(docx) {
30738
30840
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
30739
30841
  }
30740
- static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.2.1") {
30842
+ static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.3.0-next.1") {
30741
30843
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
30742
30844
  }
30743
30845
  /**
@@ -7484,8 +7484,18 @@ function getUnderlineCssString({ type = "single", color = null, thickness = null
7484
7484
  if (color) add("text-decoration-color", color);
7485
7485
  return parts.join("; ");
7486
7486
  }
7487
- const INLINE_OVERRIDE_PROPERTIES = ["fontSize", "bold", "italic", "strike", "underline", "letterSpacing"];
7487
+ const INLINE_OVERRIDE_PROPERTIES = [
7488
+ "fontSize",
7489
+ "bold",
7490
+ "italic",
7491
+ "strike",
7492
+ "underline",
7493
+ "letterSpacing",
7494
+ "vertAlign",
7495
+ "position"
7496
+ ];
7488
7497
  const DEFAULT_FONT_SIZE_HALF_POINTS = 20;
7498
+ const SUBSCRIPT_SUPERSCRIPT_SCALE = 0.65;
7489
7499
  const resolveRunProperties = (params, inlineRpr, resolvedPpr, isListNumber = false, numberingDefinedInline = false) => {
7490
7500
  const paragraphStyleId = resolvedPpr?.styleId;
7491
7501
  const paragraphStyleProps = resolveStyleChain(params, paragraphStyleId, translator$1O);
@@ -7833,6 +7843,21 @@ function encodeMarksFromRPr(runProperties, docx) {
7833
7843
  }
7834
7844
  break;
7835
7845
  }
7846
+ case "vertAlign": {
7847
+ if (value) {
7848
+ textStyleAttrs.vertAlign = value;
7849
+ }
7850
+ break;
7851
+ }
7852
+ case "position": {
7853
+ if (value != null && Number.isFinite(value)) {
7854
+ const points2 = helpers.halfPointToPoints(value);
7855
+ if (Number.isFinite(points2)) {
7856
+ textStyleAttrs.position = `${points2}pt`;
7857
+ }
7858
+ }
7859
+ break;
7860
+ }
7836
7861
  }
7837
7862
  });
7838
7863
  if (Object.keys(textStyleAttrs).length) {
@@ -7947,6 +7972,8 @@ function encodeCSSFromRPr(runProperties, docx) {
7947
7972
  let hasTextDecorationNone = false;
7948
7973
  let highlightColor = null;
7949
7974
  let hasHighlightTag = false;
7975
+ let verticalAlignValue;
7976
+ let fontSizeOverride;
7950
7977
  Object.keys(runProperties).forEach((key) => {
7951
7978
  const value = runProperties[key];
7952
7979
  switch (key) {
@@ -8077,6 +8104,35 @@ function encodeCSSFromRPr(runProperties, docx) {
8077
8104
  }
8078
8105
  break;
8079
8106
  }
8107
+ case "vertAlign": {
8108
+ if (runProperties.position != null && Number.isFinite(runProperties.position)) {
8109
+ break;
8110
+ }
8111
+ if (value === "superscript" || value === "subscript") {
8112
+ verticalAlignValue = value === "superscript" ? "super" : "sub";
8113
+ if (runProperties.fontSize != null && Number.isFinite(runProperties.fontSize)) {
8114
+ const scaledPoints = helpers.halfPointToPoints(runProperties.fontSize * SUBSCRIPT_SUPERSCRIPT_SCALE);
8115
+ if (Number.isFinite(scaledPoints)) {
8116
+ fontSizeOverride = `${scaledPoints}pt`;
8117
+ }
8118
+ } else {
8119
+ fontSizeOverride = `${SUBSCRIPT_SUPERSCRIPT_SCALE * 100}%`;
8120
+ }
8121
+ } else if (value === "baseline") {
8122
+ verticalAlignValue = "baseline";
8123
+ }
8124
+ break;
8125
+ }
8126
+ case "position": {
8127
+ if (value != null && Number.isFinite(value)) {
8128
+ const points = helpers.halfPointToPoints(value);
8129
+ if (Number.isFinite(points)) {
8130
+ verticalAlignValue = `${points}pt`;
8131
+ fontSizeOverride = void 0;
8132
+ }
8133
+ }
8134
+ break;
8135
+ }
8080
8136
  }
8081
8137
  });
8082
8138
  if (!hasTextDecorationNone && textDecorationLines.size) {
@@ -8091,6 +8147,12 @@ function encodeCSSFromRPr(runProperties, docx) {
8091
8147
  css["color"] = "inherit";
8092
8148
  }
8093
8149
  }
8150
+ if (fontSizeOverride) {
8151
+ css["font-size"] = fontSizeOverride;
8152
+ }
8153
+ if (verticalAlignValue) {
8154
+ css["vertical-align"] = verticalAlignValue;
8155
+ }
8094
8156
  return css;
8095
8157
  }
8096
8158
  function decodeRPrFromMarks(marks) {
@@ -8167,6 +8229,20 @@ function decodeRPrFromMarks(marks) {
8167
8229
  runProperties.fontFamily = result;
8168
8230
  }
8169
8231
  break;
8232
+ case "vertAlign":
8233
+ if (value != null) {
8234
+ runProperties.vertAlign = value;
8235
+ }
8236
+ break;
8237
+ case "position": {
8238
+ if (value != null) {
8239
+ const numeric = parseFloat(value);
8240
+ if (!isNaN(numeric)) {
8241
+ runProperties.position = numeric * 2;
8242
+ }
8243
+ }
8244
+ break;
8245
+ }
8170
8246
  }
8171
8247
  });
8172
8248
  break;
@@ -9054,6 +9130,17 @@ const attrConfig$f = Object.freeze({
9054
9130
  const validXmlAttributes$b = [attrConfig$h, attrConfig$g, attrConfig$f];
9055
9131
  const XML_NODE_NAME$k = "w:r";
9056
9132
  const SD_KEY_NAME = "run";
9133
+ const createRunNodeWithContent = (content, encodedAttrs, runLevelMarks, runProperties) => {
9134
+ const node = {
9135
+ type: SD_KEY_NAME,
9136
+ content,
9137
+ attrs: { ...encodedAttrs, runProperties }
9138
+ };
9139
+ if (runLevelMarks.length) {
9140
+ node.marks = runLevelMarks.map((mark) => cloneMark$1(mark));
9141
+ }
9142
+ return node;
9143
+ };
9057
9144
  const encode$x = (params, encodedAttrs = {}) => {
9058
9145
  const { nodes = [], nodeListHandler } = params || {};
9059
9146
  const runNode = nodes[0];
@@ -9098,15 +9185,30 @@ const encode$x = (params, encodedAttrs = {}) => {
9098
9185
  return { ...child, marks: childMarks };
9099
9186
  });
9100
9187
  const filtered = contentWithRunMarks.filter(Boolean);
9101
- const runNodeResult = {
9102
- type: SD_KEY_NAME,
9103
- content: filtered,
9104
- attrs: { ...encodedAttrs, runProperties }
9188
+ const containsBreakNodes = filtered.some((child) => child?.type === "lineBreak");
9189
+ if (!containsBreakNodes) {
9190
+ const defaultNode = createRunNodeWithContent(filtered, encodedAttrs, runLevelMarks, runProperties);
9191
+ return defaultNode;
9192
+ }
9193
+ const splitRuns = [];
9194
+ let currentChunk = [];
9195
+ const finalizeTextChunk = () => {
9196
+ if (!currentChunk.length) return;
9197
+ const chunkNode = createRunNodeWithContent(currentChunk, encodedAttrs, runLevelMarks, runProperties);
9198
+ if (chunkNode) splitRuns.push(chunkNode);
9199
+ currentChunk = [];
9105
9200
  };
9106
- if (runLevelMarks.length) {
9107
- runNodeResult.marks = runLevelMarks;
9108
- }
9109
- return runNodeResult;
9201
+ filtered.forEach((child) => {
9202
+ if (child?.type === "lineBreak") {
9203
+ finalizeTextChunk();
9204
+ const breakNode = createRunNodeWithContent([child], encodedAttrs, runLevelMarks, runProperties);
9205
+ if (breakNode) splitRuns.push(breakNode);
9206
+ } else {
9207
+ currentChunk.push(child);
9208
+ }
9209
+ });
9210
+ finalizeTextChunk();
9211
+ return splitRuns;
9110
9212
  };
9111
9213
  const decode$z = (params, decodedAttrs = {}) => {
9112
9214
  const { node } = params || {};
@@ -30738,7 +30840,7 @@ class SuperConverter {
30738
30840
  static getStoredSuperdocVersion(docx) {
30739
30841
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
30740
30842
  }
30741
- static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.2.1") {
30843
+ static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.3.0-next.1") {
30742
30844
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
30743
30845
  }
30744
30846
  /**
@@ -331,14 +331,14 @@ export {
331
331
  inchesToPixels as e,
332
332
  libExports as f,
333
333
  getContentTypesFromXml as g,
334
- getDocxHighlightKeywordFromHex as h,
334
+ halfPointToPoints as h,
335
335
  inchesToTwips as i,
336
- isValidHexColor as j,
337
- getHexColorFromDocxSystem as k,
336
+ getDocxHighlightKeywordFromHex as j,
337
+ isValidHexColor as k,
338
338
  linesToTwips as l,
339
- twipsToPt as m,
339
+ getHexColorFromDocxSystem as m,
340
340
  normalizeHexColor as n,
341
- halfPointToPoints as o,
341
+ twipsToPt as o,
342
342
  ptToTwips as p,
343
343
  eighthPointsToPixels as q,
344
344
  pixelsToEightPoints as r,