superdoc 1.15.0 → 1.15.1-next.2

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.
@@ -33843,7 +33843,7 @@ var SuperConverter = class SuperConverter {
33843
33843
  static getStoredSuperdocVersion(docx) {
33844
33844
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
33845
33845
  }
33846
- static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.15.0") {
33846
+ static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.15.1-next.2") {
33847
33847
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
33848
33848
  }
33849
33849
  static generateWordTimestamp() {
@@ -33829,7 +33829,7 @@ var SuperConverter = class SuperConverter {
33829
33829
  static getStoredSuperdocVersion(docx) {
33830
33830
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
33831
33831
  }
33832
- static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.15.0") {
33832
+ static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.15.1-next.2") {
33833
33833
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
33834
33834
  }
33835
33835
  static generateWordTimestamp() {
@@ -1,5 +1,5 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-Dp2H1eGw.cjs");
2
- const require_SuperConverter = require("./SuperConverter-BsXuivNG.cjs");
2
+ const require_SuperConverter = require("./SuperConverter-Byxnduvh.cjs");
3
3
  const require_jszip = require("./jszip-DCT9QYaK.cjs");
4
4
  const require_uuid = require("./uuid-CHj_rjgt.cjs");
5
5
  const require_constants = require("./constants-CpniKo9Z.cjs");
@@ -243,7 +243,7 @@ var DEFAULT_ENDPOINT = "https://ingest.superdoc.dev/v1/collect";
243
243
  const COMMUNITY_LICENSE_KEY = "community-and-eval-agplv3";
244
244
  function getSuperdocVersion() {
245
245
  try {
246
- return "1.15.0";
246
+ return "1.15.1-next.2";
247
247
  } catch {
248
248
  return "unknown";
249
249
  }
@@ -5083,7 +5083,7 @@ const LOWEST_INT32 = 1 << 31;
5083
5083
  const HIGHEST_INT32 = BITS31;
5084
5084
  const HIGHEST_UINT32 = BITS32;
5085
5085
  /* c8 ignore next */
5086
- const isInteger = Number.isInteger || ((num) => typeof num === "number" && isFinite(num) && floor(num) === num);
5086
+ const isInteger$1 = Number.isInteger || ((num) => typeof num === "number" && isFinite(num) && floor(num) === num);
5087
5087
  const isNaN$1 = Number.isNaN;
5088
5088
  const parseInt$1 = Number.parseInt;
5089
5089
  const create$2 = () => /* @__PURE__ */ new Set();
@@ -5252,7 +5252,7 @@ const writeAny = (encoder, data) => {
5252
5252
  writeVarString(encoder, data);
5253
5253
  break;
5254
5254
  case "number":
5255
- if (isInteger(data) && abs(data) <= 2147483647) {
5255
+ if (isInteger$1(data) && abs(data) <= 2147483647) {
5256
5256
  write$1(encoder, 125);
5257
5257
  writeVarInt(encoder, data);
5258
5258
  } else if (isFloat32(data)) {
@@ -17576,7 +17576,7 @@ var require_lodash = /* @__PURE__ */ require_rolldown_runtime.__commonJSMin(((ex
17576
17576
  var tag = baseGetTag$1(value);
17577
17577
  return tag == funcTag$2 || tag == genTag$1 || tag == asyncTag$1 || tag == proxyTag$1;
17578
17578
  }
17579
- function isInteger$1(value) {
17579
+ function isInteger$2(value) {
17580
17580
  return typeof value == "number" && value == toInteger(value);
17581
17581
  }
17582
17582
  function isLength$1(value) {
@@ -17622,7 +17622,7 @@ var require_lodash = /* @__PURE__ */ require_rolldown_runtime.__commonJSMin(((ex
17622
17622
  }
17623
17623
  var isRegExp$1 = nodeIsRegExp ? baseUnary$1(nodeIsRegExp) : baseIsRegExp;
17624
17624
  function isSafeInteger(value) {
17625
- return isInteger$1(value) && value >= -MAX_SAFE_INTEGER$3 && value <= MAX_SAFE_INTEGER$3;
17625
+ return isInteger$2(value) && value >= -MAX_SAFE_INTEGER$3 && value <= MAX_SAFE_INTEGER$3;
17626
17626
  }
17627
17627
  var isSet = nodeIsSet ? baseUnary$1(nodeIsSet) : baseIsSet;
17628
17628
  function isString(value) {
@@ -18548,7 +18548,7 @@ var require_lodash = /* @__PURE__ */ require_rolldown_runtime.__commonJSMin(((ex
18548
18548
  lodash.isError = isError;
18549
18549
  lodash.isFinite = isFinite$1;
18550
18550
  lodash.isFunction = isFunction$1;
18551
- lodash.isInteger = isInteger$1;
18551
+ lodash.isInteger = isInteger$2;
18552
18552
  lodash.isLength = isLength$1;
18553
18553
  lodash.isMap = isMap;
18554
18554
  lodash.isMatch = isMatch$1;
@@ -20693,7 +20693,7 @@ const canUseDOM = () => {
20693
20693
  return false;
20694
20694
  }
20695
20695
  };
20696
- var summaryVersion = "1.15.0";
20696
+ var summaryVersion = "1.15.1-next.2";
20697
20697
  var nodeKeys = [
20698
20698
  "group",
20699
20699
  "content",
@@ -21192,7 +21192,7 @@ const OPERATION_DEFINITIONS = {
21192
21192
  supportsDryRun: true,
21193
21193
  supportsTrackedMode: true,
21194
21194
  possibleFailureCodes: ["INVALID_TARGET", "NO_OP"],
21195
- throws: T_NOT_FOUND_TRACKED
21195
+ throws: [...T_NOT_FOUND_TRACKED, "INVALID_TARGET"]
21196
21196
  }),
21197
21197
  referenceDocPath: "insert.mdx",
21198
21198
  referenceGroup: "core"
@@ -22102,6 +22102,29 @@ var capabilitiesOutputSchema = objectSchema({
22102
22102
  operations: operationCapabilitiesSchema
22103
22103
  }, ["global", "operations"]);
22104
22104
  var strictEmptyObjectSchema = objectSchema({});
22105
+ var insertInputSchema = {
22106
+ ...objectSchema({
22107
+ target: textAddressSchema,
22108
+ text: { type: "string" },
22109
+ blockId: {
22110
+ type: "string",
22111
+ description: "Block ID for block-relative targeting."
22112
+ },
22113
+ offset: {
22114
+ type: "integer",
22115
+ minimum: 0,
22116
+ description: "Character offset within the block identified by blockId."
22117
+ }
22118
+ }, ["text"]),
22119
+ allOf: [
22120
+ { not: { required: ["target", "blockId"] } },
22121
+ { not: { required: ["target", "offset"] } },
22122
+ {
22123
+ if: { required: ["offset"] },
22124
+ then: { required: ["blockId"] }
22125
+ }
22126
+ ]
22127
+ };
22105
22128
  var operationSchemas = {
22106
22129
  find: {
22107
22130
  input: findInputSchema,
@@ -22127,10 +22150,7 @@ var operationSchemas = {
22127
22150
  output: documentInfoSchema
22128
22151
  },
22129
22152
  insert: {
22130
- input: objectSchema({
22131
- target: textAddressSchema,
22132
- text: { type: "string" }
22133
- }, ["text"]),
22153
+ input: insertInputSchema,
22134
22154
  output: textMutationResultSchemaFor("insert"),
22135
22155
  success: textMutationSuccessSchema,
22136
22156
  failure: textMutationFailureSchemaFor("insert")
@@ -22546,14 +22566,83 @@ function executeDelete(adapter, input, options) {
22546
22566
  text: ""
22547
22567
  }, options);
22548
22568
  }
22569
+ var DocumentApiValidationError = class DocumentApiValidationError extends Error {
22570
+ constructor(code$1, message, details) {
22571
+ super(message);
22572
+ this.name = "DocumentApiValidationError";
22573
+ this.code = code$1;
22574
+ this.details = details;
22575
+ Object.setPrototypeOf(this, DocumentApiValidationError.prototype);
22576
+ }
22577
+ };
22578
+ var INSERT_INPUT_ALLOWED_KEYS = new Set([
22579
+ "text",
22580
+ "target",
22581
+ "blockId",
22582
+ "offset"
22583
+ ]);
22584
+ function isRecord(value) {
22585
+ return typeof value === "object" && value != null && !Array.isArray(value);
22586
+ }
22587
+ function isInteger(value) {
22588
+ return typeof value === "number" && Number.isInteger(value);
22589
+ }
22590
+ function isTextAddress(value) {
22591
+ if (!isRecord(value)) return false;
22592
+ if (value.kind !== "text") return false;
22593
+ if (typeof value.blockId !== "string") return false;
22594
+ const range = value.range;
22595
+ if (!isRecord(range)) return false;
22596
+ if (!isInteger(range.start) || !isInteger(range.end)) return false;
22597
+ return range.start <= range.end;
22598
+ }
22599
+ function validateInsertInput(input) {
22600
+ if (!isRecord(input)) throw new DocumentApiValidationError("INVALID_TARGET", "Insert input must be a non-null object.");
22601
+ const inputObj = input;
22602
+ if ("pos" in inputObj) throw new DocumentApiValidationError("INVALID_TARGET", "pos locator is not yet supported.", { field: "pos" });
22603
+ for (const key$1 of Object.keys(inputObj)) if (!INSERT_INPUT_ALLOWED_KEYS.has(key$1)) throw new DocumentApiValidationError("INVALID_TARGET", `Unknown field "${key$1}" on insert input. Allowed fields: ${[...INSERT_INPUT_ALLOWED_KEYS].join(", ")}.`, { field: key$1 });
22604
+ const { target, text, blockId, offset: offset$1 } = inputObj;
22605
+ const hasTarget = target !== void 0;
22606
+ const hasBlockId = blockId !== void 0;
22607
+ const hasOffset = offset$1 !== void 0;
22608
+ if (hasTarget && !isTextAddress(target)) throw new DocumentApiValidationError("INVALID_TARGET", "target must be a text address object.", {
22609
+ field: "target",
22610
+ value: target
22611
+ });
22612
+ if (typeof text !== "string") throw new DocumentApiValidationError("INVALID_TARGET", `text must be a string, got ${typeof text}.`, {
22613
+ field: "text",
22614
+ value: text
22615
+ });
22616
+ if (hasBlockId && typeof blockId !== "string") throw new DocumentApiValidationError("INVALID_TARGET", `blockId must be a string, got ${typeof blockId}.`, {
22617
+ field: "blockId",
22618
+ value: blockId
22619
+ });
22620
+ if (hasTarget && hasBlockId) throw new DocumentApiValidationError("INVALID_TARGET", "Cannot combine target with blockId. Use exactly one locator mode.", { fields: ["target", "blockId"] });
22621
+ if (hasTarget && hasOffset) throw new DocumentApiValidationError("INVALID_TARGET", "Cannot combine target with offset. Use exactly one locator mode.", { fields: ["target", "offset"] });
22622
+ if (hasOffset && !hasBlockId) throw new DocumentApiValidationError("INVALID_TARGET", "offset requires blockId.", { fields: ["offset", "blockId"] });
22623
+ if (hasOffset) {
22624
+ if (typeof offset$1 !== "number" || !Number.isInteger(offset$1) || offset$1 < 0) throw new DocumentApiValidationError("INVALID_TARGET", `offset must be a non-negative integer, got ${JSON.stringify(offset$1)}.`, {
22625
+ field: "offset",
22626
+ value: offset$1
22627
+ });
22628
+ }
22629
+ }
22549
22630
  function executeInsert(adapter, input, options) {
22550
- return executeWrite(adapter, input.target ? {
22631
+ validateInsertInput(input);
22632
+ const { target, blockId, offset: offset$1, text } = input;
22633
+ if (blockId !== void 0) return executeWrite(adapter, {
22551
22634
  kind: "insert",
22552
- target: input.target,
22553
- text: input.text
22635
+ blockId,
22636
+ offset: offset$1,
22637
+ text
22638
+ }, options);
22639
+ return executeWrite(adapter, target ? {
22640
+ kind: "insert",
22641
+ target,
22642
+ text
22554
22643
  } : {
22555
22644
  kind: "insert",
22556
- text: input.text
22645
+ text
22557
22646
  }, options);
22558
22647
  }
22559
22648
  function executeListsList(adapter, query) {
@@ -25874,6 +25963,28 @@ function validateWriteRequest(request, resolvedTarget) {
25874
25963
  };
25875
25964
  return null;
25876
25965
  }
25966
+ function normalizeInsertLocator(request) {
25967
+ if (request.kind !== "insert") return request;
25968
+ const hasBlockId = request.blockId !== void 0;
25969
+ const hasOffset = request.offset !== void 0;
25970
+ if (hasOffset && request.target) throw new DocumentApiAdapterError("INVALID_TARGET", "Cannot combine target with offset on insert request.", { fields: ["target", "offset"] });
25971
+ if (hasOffset && !hasBlockId) throw new DocumentApiAdapterError("INVALID_TARGET", "offset requires blockId on insert request.", { fields: ["offset", "blockId"] });
25972
+ if (!hasBlockId) return request;
25973
+ if (request.target) throw new DocumentApiAdapterError("INVALID_TARGET", "Cannot combine target with blockId on insert request.", { fields: ["target", "blockId"] });
25974
+ const effectiveOffset = request.offset ?? 0;
25975
+ return {
25976
+ kind: "insert",
25977
+ target: {
25978
+ kind: "text",
25979
+ blockId: request.blockId,
25980
+ range: {
25981
+ start: effectiveOffset,
25982
+ end: effectiveOffset
25983
+ }
25984
+ },
25985
+ text: request.text
25986
+ };
25987
+ }
25877
25988
  function resolveWriteTarget(editor, request) {
25878
25989
  const requestedTarget = request.target;
25879
25990
  if (request.kind === "insert" && !request.target) {
@@ -25961,9 +26072,10 @@ function toFailureReceipt(failure, resolvedTarget) {
25961
26072
  };
25962
26073
  }
25963
26074
  function writeAdapter(editor, request, options) {
25964
- const resolvedTarget = resolveWriteTarget(editor, request);
25965
- if (!resolvedTarget) throw new DocumentApiAdapterError("TARGET_NOT_FOUND", "Mutation target could not be resolved.", { target: request.target });
25966
- const validationFailure = validateWriteRequest(request, resolvedTarget);
26075
+ const normalizedRequest = normalizeInsertLocator(request);
26076
+ const resolvedTarget = resolveWriteTarget(editor, normalizedRequest);
26077
+ if (!resolvedTarget) throw new DocumentApiAdapterError("TARGET_NOT_FOUND", "Mutation target could not be resolved.", { target: normalizedRequest.target });
26078
+ const validationFailure = validateWriteRequest(normalizedRequest, resolvedTarget);
25967
26079
  if (validationFailure) return toFailureReceipt(validationFailure, resolvedTarget);
25968
26080
  const mode = options?.changeMode ?? "direct";
25969
26081
  if (options?.dryRun) {
@@ -25973,8 +26085,8 @@ function writeAdapter(editor, request, options) {
25973
26085
  resolution: resolvedTarget.resolution
25974
26086
  };
25975
26087
  }
25976
- if (mode === "tracked") return applyTrackedWrite(editor, request, resolvedTarget);
25977
- return applyDirectWrite(editor, request, resolvedTarget);
26088
+ if (mode === "tracked") return applyTrackedWrite(editor, normalizedRequest, resolvedTarget);
26089
+ return applyDirectWrite(editor, normalizedRequest, resolvedTarget);
25978
26090
  }
25979
26091
  function getDocumentApiAdapters(editor) {
25980
26092
  return {
@@ -27388,7 +27500,7 @@ var Editor = class Editor extends EventEmitter$1 {
27388
27500
  return migrations.length > 0;
27389
27501
  }
27390
27502
  processCollaborationMigrations() {
27391
- console.debug("[checkVersionMigrations] Current editor version", "1.15.0");
27503
+ console.debug("[checkVersionMigrations] Current editor version", "1.15.1-next.2");
27392
27504
  if (!this.options.ydoc) return;
27393
27505
  let docVersion = this.options.ydoc.getMap("meta").get("version");
27394
27506
  if (!docVersion) docVersion = "initial";
@@ -89745,8 +89857,18 @@ function getItems(context, customItems = [], includeDefaultItems = true) {
89745
89857
  action: async (editor$1) => {
89746
89858
  const { view } = editor$1 ?? {};
89747
89859
  if (!view) return;
89748
- view.dom.focus();
89860
+ const savedFrom = view.state.selection.from;
89861
+ const savedTo = view.state.selection.to;
89862
+ view.focus();
89749
89863
  const { html, text } = await readClipboardRaw();
89864
+ if (view.state?.doc?.content) {
89865
+ const { tr, doc: doc$2 } = view.state;
89866
+ const maxPos = doc$2.content.size;
89867
+ const safeFrom = Math.min(savedFrom, maxPos);
89868
+ const safeTo = Math.min(savedTo, maxPos);
89869
+ const SelectionType = view.state.selection.constructor;
89870
+ if (typeof SelectionType.create === "function") view.dispatch(tr.setSelection(SelectionType.create(doc$2, safeFrom, safeTo)));
89871
+ }
89750
89872
  if (!(html ? require_SuperConverter.handleClipboardPaste({
89751
89873
  editor: editor$1,
89752
89874
  view
@@ -1,5 +1,5 @@
1
1
  import { a as __toCommonJS, n as __esmMin, r as __export, t as __commonJSMin } from "./rolldown-runtime-B2q5OVn9.es.js";
2
- import { $ as TextSelection$1, A as findMark, At as Mark$1, B as defaultBlockAt$1, C as docxNumberingHelpers, Ct as TrackDeleteMarkName, D as posToDOMRect, Dt as DOMParser$1, E as isInTable, Et as carbonCopy, F as isMarkActive, Ft as getExtensionConfigField, G as createDocument, H as getNodeType, I as getMarkRange, J as NodeSelection, K as AllSelection, L as isTextSelection, M as isActive, Mt as Slice, N as isNodeActive, Nt as minMax, O as findChildren$1, Ot as DOMSerializer, P as getSchemaTypeNameByName, Pt as callOrGet, Q as SelectionRange, R as findParentNode, S as getResolvedParagraphProperties, St as getUnderlineCssString, T as CommandService, Tt as TrackInsertMarkName, U as cleanSchemaItem, V as getMarkType, W as getSchemaTypeByName, X as PluginKey, Y as Plugin, Z as Selection, _ as ListHelpers, _t as encodeMarksFromRPr, a as _getReferencedTableStyles, at as Transform, b as isList, bt as resolveRunProperties, c as processContent, ct as dropPoint, d as createCellBorders, dt as replaceStep$1, et as AddMarkStep, f as InputRule, ft as generateDocxRandomId, g as unflattenListsInHtml, gt as encodeCSSFromRPr, h as inputRulesPlugin, ht as encodeCSSFromPPr, it as ReplaceStep, j as getMarksFromSelection, jt as Schema$1, k as getActiveFormatting, kt as Fragment$1, l as createDocFromMarkdown, lt as joinPoint, m as htmlHandler, mt as decodeRPrFromMarks, n as kebabCase$1, nt as RemoveMarkStep, o as helpers_exports, ot as canJoin, p as handleClipboardPaste, pt as generateRandomSigned32BitIntStrId, q as EditorState, r as insertNewRelationship, rt as ReplaceAroundStep$1, s as updateDOMAttributes, st as canSplit, t as SuperConverter, tt as Mapping, u as createDocFromHTML, ut as liftTarget, v as changeListLevel, vt as resolveDocxFontFamily, w as generateOrderedListIndex, wt as TrackFormatMarkName, x as calculateResolvedParagraphProperties, xt as resolveTableCellProperties, y as updateNumberingProperties, yt as resolveParagraphProperties, z as findParentNodeClosestToPos } from "./SuperConverter-Cv8wefny.es.js";
2
+ import { $ as TextSelection$1, A as findMark, At as Mark$1, B as defaultBlockAt$1, C as docxNumberingHelpers, Ct as TrackDeleteMarkName, D as posToDOMRect, Dt as DOMParser$1, E as isInTable, Et as carbonCopy, F as isMarkActive, Ft as getExtensionConfigField, G as createDocument, H as getNodeType, I as getMarkRange, J as NodeSelection, K as AllSelection, L as isTextSelection, M as isActive, Mt as Slice, N as isNodeActive, Nt as minMax, O as findChildren$1, Ot as DOMSerializer, P as getSchemaTypeNameByName, Pt as callOrGet, Q as SelectionRange, R as findParentNode, S as getResolvedParagraphProperties, St as getUnderlineCssString, T as CommandService, Tt as TrackInsertMarkName, U as cleanSchemaItem, V as getMarkType, W as getSchemaTypeByName, X as PluginKey, Y as Plugin, Z as Selection, _ as ListHelpers, _t as encodeMarksFromRPr, a as _getReferencedTableStyles, at as Transform, b as isList, bt as resolveRunProperties, c as processContent, ct as dropPoint, d as createCellBorders, dt as replaceStep$1, et as AddMarkStep, f as InputRule, ft as generateDocxRandomId, g as unflattenListsInHtml, gt as encodeCSSFromRPr, h as inputRulesPlugin, ht as encodeCSSFromPPr, it as ReplaceStep, j as getMarksFromSelection, jt as Schema$1, k as getActiveFormatting, kt as Fragment$1, l as createDocFromMarkdown, lt as joinPoint, m as htmlHandler, mt as decodeRPrFromMarks, n as kebabCase$1, nt as RemoveMarkStep, o as helpers_exports, ot as canJoin, p as handleClipboardPaste, pt as generateRandomSigned32BitIntStrId, q as EditorState, r as insertNewRelationship, rt as ReplaceAroundStep$1, s as updateDOMAttributes, st as canSplit, t as SuperConverter, tt as Mapping, u as createDocFromHTML, ut as liftTarget, v as changeListLevel, vt as resolveDocxFontFamily, w as generateOrderedListIndex, wt as TrackFormatMarkName, x as calculateResolvedParagraphProperties, xt as resolveTableCellProperties, y as updateNumberingProperties, yt as resolveParagraphProperties, z as findParentNodeClosestToPos } from "./SuperConverter-mYJUjRBF.es.js";
3
3
  import { a as init_dist$2, i as global, n as init_dist, o as Buffer$3, r as process$1, s as init_dist$1 } from "./jszip-ChlR43oI.es.js";
4
4
  import { t as v4_default } from "./uuid-2IzDu5nl.es.js";
5
5
  import { A as resolveOpcTargetPath, E as pixelsToTwips, F as twipsToLines, I as twipsToPixels, P as twipsToInches, _ as halfPointToPoints, c as convertSizeToCSS, k as ptToTwips, p as getArrayBufferFromUrl, t as COMMENT_FILE_BASENAMES, v as inchesToPixels, x as linesToTwips, y as inchesToTwips } from "./constants-DBKi0Amm.es.js";
@@ -242,7 +242,7 @@ var v_click_outside_default = {
242
242
  var DEFAULT_ENDPOINT = "https://ingest.superdoc.dev/v1/collect";
243
243
  function getSuperdocVersion() {
244
244
  try {
245
- return "1.15.0";
245
+ return "1.15.1-next.2";
246
246
  } catch {
247
247
  return "unknown";
248
248
  }
@@ -5072,7 +5072,7 @@ BIT31 - 1;
5072
5072
  const MAX_SAFE_INTEGER$2 = Number.MAX_SAFE_INTEGER;
5073
5073
  const MIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER;
5074
5074
  /* c8 ignore next */
5075
- const isInteger = Number.isInteger || ((num) => typeof num === "number" && isFinite(num) && floor(num) === num);
5075
+ const isInteger$1 = Number.isInteger || ((num) => typeof num === "number" && isFinite(num) && floor(num) === num);
5076
5076
  Number.isNaN;
5077
5077
  Number.parseInt;
5078
5078
  const create$2 = () => /* @__PURE__ */ new Set();
@@ -5241,7 +5241,7 @@ const writeAny = (encoder, data) => {
5241
5241
  writeVarString(encoder, data);
5242
5242
  break;
5243
5243
  case "number":
5244
- if (isInteger(data) && abs(data) <= 2147483647) {
5244
+ if (isInteger$1(data) && abs(data) <= 2147483647) {
5245
5245
  write$1(encoder, 125);
5246
5246
  writeVarInt(encoder, data);
5247
5247
  } else if (isFloat32(data)) {
@@ -17557,7 +17557,7 @@ var require_lodash = /* @__PURE__ */ __commonJSMin(((exports, module) => {
17557
17557
  var tag = baseGetTag$1(value);
17558
17558
  return tag == funcTag$2 || tag == genTag$1 || tag == asyncTag$1 || tag == proxyTag$1;
17559
17559
  }
17560
- function isInteger$1(value) {
17560
+ function isInteger$2(value) {
17561
17561
  return typeof value == "number" && value == toInteger(value);
17562
17562
  }
17563
17563
  function isLength$1(value) {
@@ -17603,7 +17603,7 @@ var require_lodash = /* @__PURE__ */ __commonJSMin(((exports, module) => {
17603
17603
  }
17604
17604
  var isRegExp$1 = nodeIsRegExp ? baseUnary$1(nodeIsRegExp) : baseIsRegExp;
17605
17605
  function isSafeInteger(value) {
17606
- return isInteger$1(value) && value >= -MAX_SAFE_INTEGER$3 && value <= MAX_SAFE_INTEGER$3;
17606
+ return isInteger$2(value) && value >= -MAX_SAFE_INTEGER$3 && value <= MAX_SAFE_INTEGER$3;
17607
17607
  }
17608
17608
  var isSet = nodeIsSet ? baseUnary$1(nodeIsSet) : baseIsSet;
17609
17609
  function isString(value) {
@@ -18529,7 +18529,7 @@ var require_lodash = /* @__PURE__ */ __commonJSMin(((exports, module) => {
18529
18529
  lodash.isError = isError;
18530
18530
  lodash.isFinite = isFinite$1;
18531
18531
  lodash.isFunction = isFunction$1;
18532
- lodash.isInteger = isInteger$1;
18532
+ lodash.isInteger = isInteger$2;
18533
18533
  lodash.isLength = isLength$1;
18534
18534
  lodash.isMap = isMap;
18535
18535
  lodash.isMatch = isMatch$1;
@@ -20674,7 +20674,7 @@ const canUseDOM = () => {
20674
20674
  return false;
20675
20675
  }
20676
20676
  };
20677
- var summaryVersion = "1.15.0";
20677
+ var summaryVersion = "1.15.1-next.2";
20678
20678
  var nodeKeys = [
20679
20679
  "group",
20680
20680
  "content",
@@ -21172,7 +21172,7 @@ const OPERATION_DEFINITIONS = {
21172
21172
  supportsDryRun: true,
21173
21173
  supportsTrackedMode: true,
21174
21174
  possibleFailureCodes: ["INVALID_TARGET", "NO_OP"],
21175
- throws: T_NOT_FOUND_TRACKED
21175
+ throws: [...T_NOT_FOUND_TRACKED, "INVALID_TARGET"]
21176
21176
  }),
21177
21177
  referenceDocPath: "insert.mdx",
21178
21178
  referenceGroup: "core"
@@ -22081,13 +22081,23 @@ objectSchema({
22081
22081
  operations: operationCapabilitiesSchema
22082
22082
  }, ["global", "operations"]);
22083
22083
  objectSchema({});
22084
+ ({ ...objectSchema({
22085
+ target: textAddressSchema,
22086
+ text: { type: "string" },
22087
+ blockId: {
22088
+ type: "string",
22089
+ description: "Block ID for block-relative targeting."
22090
+ },
22091
+ offset: {
22092
+ type: "integer",
22093
+ minimum: 0,
22094
+ description: "Character offset within the block identified by blockId."
22095
+ }
22096
+ }, ["text"]) });
22084
22097
  objectSchema({
22085
22098
  nodeId: { type: "string" },
22086
22099
  nodeType: { enum: [...blockNodeTypeValues] }
22087
- }, ["nodeId"]), objectSchema({
22088
- target: textAddressSchema,
22089
- text: { type: "string" }
22090
- }, ["text"]), textMutationResultSchemaFor("insert"), textMutationFailureSchemaFor("insert"), objectSchema({
22100
+ }, ["nodeId"]), textMutationResultSchemaFor("insert"), textMutationFailureSchemaFor("insert"), objectSchema({
22091
22101
  target: textAddressSchema,
22092
22102
  text: { type: "string" }
22093
22103
  }, ["target", "text"]), textMutationResultSchemaFor("replace"), textMutationFailureSchemaFor("replace"), objectSchema({ target: textAddressSchema }, ["target"]), textMutationResultSchemaFor("delete"), textMutationFailureSchemaFor("delete"), objectSchema({ target: textAddressSchema }, ["target"]), textMutationResultSchemaFor("format.bold"), textMutationFailureSchemaFor("format.bold"), objectSchema({ target: textAddressSchema }, ["target"]), textMutationResultSchemaFor("format.italic"), textMutationFailureSchemaFor("format.italic"), objectSchema({ target: textAddressSchema }, ["target"]), textMutationResultSchemaFor("format.underline"), textMutationFailureSchemaFor("format.underline"), objectSchema({ target: textAddressSchema }, ["target"]), textMutationResultSchemaFor("format.strikethrough"), textMutationFailureSchemaFor("format.strikethrough"), objectSchema({
@@ -22310,14 +22320,83 @@ function executeDelete(adapter, input, options) {
22310
22320
  text: ""
22311
22321
  }, options);
22312
22322
  }
22323
+ var DocumentApiValidationError = class DocumentApiValidationError extends Error {
22324
+ constructor(code$1, message, details) {
22325
+ super(message);
22326
+ this.name = "DocumentApiValidationError";
22327
+ this.code = code$1;
22328
+ this.details = details;
22329
+ Object.setPrototypeOf(this, DocumentApiValidationError.prototype);
22330
+ }
22331
+ };
22332
+ var INSERT_INPUT_ALLOWED_KEYS = new Set([
22333
+ "text",
22334
+ "target",
22335
+ "blockId",
22336
+ "offset"
22337
+ ]);
22338
+ function isRecord(value) {
22339
+ return typeof value === "object" && value != null && !Array.isArray(value);
22340
+ }
22341
+ function isInteger(value) {
22342
+ return typeof value === "number" && Number.isInteger(value);
22343
+ }
22344
+ function isTextAddress(value) {
22345
+ if (!isRecord(value)) return false;
22346
+ if (value.kind !== "text") return false;
22347
+ if (typeof value.blockId !== "string") return false;
22348
+ const range = value.range;
22349
+ if (!isRecord(range)) return false;
22350
+ if (!isInteger(range.start) || !isInteger(range.end)) return false;
22351
+ return range.start <= range.end;
22352
+ }
22353
+ function validateInsertInput(input) {
22354
+ if (!isRecord(input)) throw new DocumentApiValidationError("INVALID_TARGET", "Insert input must be a non-null object.");
22355
+ const inputObj = input;
22356
+ if ("pos" in inputObj) throw new DocumentApiValidationError("INVALID_TARGET", "pos locator is not yet supported.", { field: "pos" });
22357
+ for (const key$1 of Object.keys(inputObj)) if (!INSERT_INPUT_ALLOWED_KEYS.has(key$1)) throw new DocumentApiValidationError("INVALID_TARGET", `Unknown field "${key$1}" on insert input. Allowed fields: ${[...INSERT_INPUT_ALLOWED_KEYS].join(", ")}.`, { field: key$1 });
22358
+ const { target, text, blockId, offset: offset$1 } = inputObj;
22359
+ const hasTarget = target !== void 0;
22360
+ const hasBlockId = blockId !== void 0;
22361
+ const hasOffset = offset$1 !== void 0;
22362
+ if (hasTarget && !isTextAddress(target)) throw new DocumentApiValidationError("INVALID_TARGET", "target must be a text address object.", {
22363
+ field: "target",
22364
+ value: target
22365
+ });
22366
+ if (typeof text !== "string") throw new DocumentApiValidationError("INVALID_TARGET", `text must be a string, got ${typeof text}.`, {
22367
+ field: "text",
22368
+ value: text
22369
+ });
22370
+ if (hasBlockId && typeof blockId !== "string") throw new DocumentApiValidationError("INVALID_TARGET", `blockId must be a string, got ${typeof blockId}.`, {
22371
+ field: "blockId",
22372
+ value: blockId
22373
+ });
22374
+ if (hasTarget && hasBlockId) throw new DocumentApiValidationError("INVALID_TARGET", "Cannot combine target with blockId. Use exactly one locator mode.", { fields: ["target", "blockId"] });
22375
+ if (hasTarget && hasOffset) throw new DocumentApiValidationError("INVALID_TARGET", "Cannot combine target with offset. Use exactly one locator mode.", { fields: ["target", "offset"] });
22376
+ if (hasOffset && !hasBlockId) throw new DocumentApiValidationError("INVALID_TARGET", "offset requires blockId.", { fields: ["offset", "blockId"] });
22377
+ if (hasOffset) {
22378
+ if (typeof offset$1 !== "number" || !Number.isInteger(offset$1) || offset$1 < 0) throw new DocumentApiValidationError("INVALID_TARGET", `offset must be a non-negative integer, got ${JSON.stringify(offset$1)}.`, {
22379
+ field: "offset",
22380
+ value: offset$1
22381
+ });
22382
+ }
22383
+ }
22313
22384
  function executeInsert(adapter, input, options) {
22314
- return executeWrite(adapter, input.target ? {
22385
+ validateInsertInput(input);
22386
+ const { target, blockId, offset: offset$1, text } = input;
22387
+ if (blockId !== void 0) return executeWrite(adapter, {
22315
22388
  kind: "insert",
22316
- target: input.target,
22317
- text: input.text
22389
+ blockId,
22390
+ offset: offset$1,
22391
+ text
22392
+ }, options);
22393
+ return executeWrite(adapter, target ? {
22394
+ kind: "insert",
22395
+ target,
22396
+ text
22318
22397
  } : {
22319
22398
  kind: "insert",
22320
- text: input.text
22399
+ text
22321
22400
  }, options);
22322
22401
  }
22323
22402
  function executeListsList(adapter, query) {
@@ -25638,6 +25717,28 @@ function validateWriteRequest(request, resolvedTarget) {
25638
25717
  };
25639
25718
  return null;
25640
25719
  }
25720
+ function normalizeInsertLocator(request) {
25721
+ if (request.kind !== "insert") return request;
25722
+ const hasBlockId = request.blockId !== void 0;
25723
+ const hasOffset = request.offset !== void 0;
25724
+ if (hasOffset && request.target) throw new DocumentApiAdapterError("INVALID_TARGET", "Cannot combine target with offset on insert request.", { fields: ["target", "offset"] });
25725
+ if (hasOffset && !hasBlockId) throw new DocumentApiAdapterError("INVALID_TARGET", "offset requires blockId on insert request.", { fields: ["offset", "blockId"] });
25726
+ if (!hasBlockId) return request;
25727
+ if (request.target) throw new DocumentApiAdapterError("INVALID_TARGET", "Cannot combine target with blockId on insert request.", { fields: ["target", "blockId"] });
25728
+ const effectiveOffset = request.offset ?? 0;
25729
+ return {
25730
+ kind: "insert",
25731
+ target: {
25732
+ kind: "text",
25733
+ blockId: request.blockId,
25734
+ range: {
25735
+ start: effectiveOffset,
25736
+ end: effectiveOffset
25737
+ }
25738
+ },
25739
+ text: request.text
25740
+ };
25741
+ }
25641
25742
  function resolveWriteTarget(editor, request) {
25642
25743
  const requestedTarget = request.target;
25643
25744
  if (request.kind === "insert" && !request.target) {
@@ -25725,9 +25826,10 @@ function toFailureReceipt(failure, resolvedTarget) {
25725
25826
  };
25726
25827
  }
25727
25828
  function writeAdapter(editor, request, options) {
25728
- const resolvedTarget = resolveWriteTarget(editor, request);
25729
- if (!resolvedTarget) throw new DocumentApiAdapterError("TARGET_NOT_FOUND", "Mutation target could not be resolved.", { target: request.target });
25730
- const validationFailure = validateWriteRequest(request, resolvedTarget);
25829
+ const normalizedRequest = normalizeInsertLocator(request);
25830
+ const resolvedTarget = resolveWriteTarget(editor, normalizedRequest);
25831
+ if (!resolvedTarget) throw new DocumentApiAdapterError("TARGET_NOT_FOUND", "Mutation target could not be resolved.", { target: normalizedRequest.target });
25832
+ const validationFailure = validateWriteRequest(normalizedRequest, resolvedTarget);
25731
25833
  if (validationFailure) return toFailureReceipt(validationFailure, resolvedTarget);
25732
25834
  const mode = options?.changeMode ?? "direct";
25733
25835
  if (options?.dryRun) {
@@ -25737,8 +25839,8 @@ function writeAdapter(editor, request, options) {
25737
25839
  resolution: resolvedTarget.resolution
25738
25840
  };
25739
25841
  }
25740
- if (mode === "tracked") return applyTrackedWrite(editor, request, resolvedTarget);
25741
- return applyDirectWrite(editor, request, resolvedTarget);
25842
+ if (mode === "tracked") return applyTrackedWrite(editor, normalizedRequest, resolvedTarget);
25843
+ return applyDirectWrite(editor, normalizedRequest, resolvedTarget);
25742
25844
  }
25743
25845
  function getDocumentApiAdapters(editor) {
25744
25846
  return {
@@ -27151,7 +27253,7 @@ var Editor = class Editor extends EventEmitter$1 {
27151
27253
  return migrations.length > 0;
27152
27254
  }
27153
27255
  processCollaborationMigrations() {
27154
- console.debug("[checkVersionMigrations] Current editor version", "1.15.0");
27256
+ console.debug("[checkVersionMigrations] Current editor version", "1.15.1-next.2");
27155
27257
  if (!this.options.ydoc) return;
27156
27258
  let docVersion = this.options.ydoc.getMap("meta").get("version");
27157
27259
  if (!docVersion) docVersion = "initial";
@@ -89398,8 +89500,18 @@ function getItems(context, customItems = [], includeDefaultItems = true) {
89398
89500
  action: async (editor$1) => {
89399
89501
  const { view } = editor$1 ?? {};
89400
89502
  if (!view) return;
89401
- view.dom.focus();
89503
+ const savedFrom = view.state.selection.from;
89504
+ const savedTo = view.state.selection.to;
89505
+ view.focus();
89402
89506
  const { html, text } = await readClipboardRaw();
89507
+ if (view.state?.doc?.content) {
89508
+ const { tr, doc: doc$2 } = view.state;
89509
+ const maxPos = doc$2.content.size;
89510
+ const safeFrom = Math.min(savedFrom, maxPos);
89511
+ const safeTo = Math.min(savedTo, maxPos);
89512
+ const SelectionType = view.state.selection.constructor;
89513
+ if (typeof SelectionType.create === "function") view.dispatch(tr.setSelection(SelectionType.create(doc$2, safeFrom, safeTo)));
89514
+ }
89403
89515
  if (!(html ? handleClipboardPaste({
89404
89516
  editor: editor$1,
89405
89517
  view
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_rolldown_runtime = require("../chunks/rolldown-runtime-Dp2H1eGw.cjs");
3
- const require_SuperConverter = require("../chunks/SuperConverter-BsXuivNG.cjs");
3
+ const require_SuperConverter = require("../chunks/SuperConverter-Byxnduvh.cjs");
4
4
  require("../chunks/jszip-DCT9QYaK.cjs");
5
5
  require("../chunks/xml-js--DznO7Gk.cjs");
6
6
  require("../chunks/constants-CpniKo9Z.cjs");
@@ -1,4 +1,4 @@
1
- import { t as SuperConverter } from "../chunks/SuperConverter-Cv8wefny.es.js";
1
+ import { t as SuperConverter } from "../chunks/SuperConverter-mYJUjRBF.es.js";
2
2
  import "../chunks/jszip-ChlR43oI.es.js";
3
3
  import "../chunks/xml-js-DLE8mr0n.es.js";
4
4
  import "../chunks/constants-DBKi0Amm.es.js";
@@ -1 +1 @@
1
- {"version":3,"file":"menuItems.d.ts","sourceRoot":"","sources":["../../../../../../super-editor/src/components/context-menu/menuItems.js"],"names":[],"mappings":"AAoFA;;;;;;GAMG;AACH,kCALW,MAAM,6CAEN,OAAO,yBAyRjB"}
1
+ {"version":3,"file":"menuItems.d.ts","sourceRoot":"","sources":["../../../../../../super-editor/src/components/context-menu/menuItems.js"],"names":[],"mappings":"AAoFA;;;;;;GAMG;AACH,kCALW,MAAM,6CAEN,OAAO,yBAgTjB"}
@@ -1 +1 @@
1
- {"version":3,"file":"write-adapter.d.ts","sourceRoot":"","sources":["../../../../../super-editor/src/document-api-adapters/write-adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EACV,eAAe,EAGf,mBAAmB,EACnB,YAAY,EACb,MAAM,wBAAwB,CAAC;AAiLhC,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,mBAAmB,CAwBlH"}
1
+ {"version":3,"file":"write-adapter.d.ts","sourceRoot":"","sources":["../../../../../super-editor/src/document-api-adapters/write-adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EACV,eAAe,EAGf,mBAAmB,EACnB,YAAY,EACb,MAAM,wBAAwB,CAAC;AA8NhC,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,mBAAmB,CA4BlH"}
@@ -354,7 +354,7 @@ export type TableProperties = {
354
354
  /**
355
355
  * - Specifies whether the current table should allow other floating tables to overlap its extents when the tables are displayed in a document
356
356
  */
357
- overlap?: "never" | "overlap" | undefined;
357
+ overlap?: "overlap" | "never" | undefined;
358
358
  /**
359
359
  * - Reference to table style ID
360
360
  */
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_rolldown_runtime = require("./chunks/rolldown-runtime-Dp2H1eGw.cjs");
3
- const require_src = require("./chunks/src-PPicsAhf.cjs");
4
- const require_SuperConverter = require("./chunks/SuperConverter-BsXuivNG.cjs");
3
+ const require_src = require("./chunks/src-BLs36rcx.cjs");
4
+ const require_SuperConverter = require("./chunks/SuperConverter-Byxnduvh.cjs");
5
5
  require("./chunks/jszip-DCT9QYaK.cjs");
6
6
  require("./chunks/xml-js--DznO7Gk.cjs");
7
7
  require("./chunks/constants-CpniKo9Z.cjs");
@@ -1,5 +1,5 @@
1
- import { $ as getAllowedImageDimensions, Bt as isMarkType, Ht as isNodeType, Q as trackChangesHelpers_exports, Rt as defineMark, Vt as assertNodeType, X as getRichTextExtensions, Y as AIWriter_default, Z as getStarterExtensions, a as BasicUpload_default, at as CommentsPluginKey, c as Toolbar_default, et as SectionHelpers, i as SuperEditor_default, it as AnnotatorHelpers, n as SlashMenu, nt as Editor, o as ContextMenu_default, ot as TrackChangesBasePluginKey, r as SuperInput_default, rt as fieldAnnotationHelpers_exports, s as SuperToolbar, t as Extensions, tt as PresentationEditor, zt as defineNode } from "./chunks/src-9JS9WrsR.es.js";
2
- import { i as registeredHandlers, j as getMarksFromSelection, k as getActiveFormatting, o as helpers_exports, t as SuperConverter } from "./chunks/SuperConverter-Cv8wefny.es.js";
1
+ import { $ as getAllowedImageDimensions, Bt as isMarkType, Ht as isNodeType, Q as trackChangesHelpers_exports, Rt as defineMark, Vt as assertNodeType, X as getRichTextExtensions, Y as AIWriter_default, Z as getStarterExtensions, a as BasicUpload_default, at as CommentsPluginKey, c as Toolbar_default, et as SectionHelpers, i as SuperEditor_default, it as AnnotatorHelpers, n as SlashMenu, nt as Editor, o as ContextMenu_default, ot as TrackChangesBasePluginKey, r as SuperInput_default, rt as fieldAnnotationHelpers_exports, s as SuperToolbar, t as Extensions, tt as PresentationEditor, zt as defineNode } from "./chunks/src-CSEqymEk.es.js";
2
+ import { i as registeredHandlers, j as getMarksFromSelection, k as getActiveFormatting, o as helpers_exports, t as SuperConverter } from "./chunks/SuperConverter-mYJUjRBF.es.js";
3
3
  import "./chunks/jszip-ChlR43oI.es.js";
4
4
  import "./chunks/xml-js-DLE8mr0n.es.js";
5
5
  import "./chunks/constants-DBKi0Amm.es.js";