@superdoc-dev/cli 0.2.0-next.85 → 0.2.0-next.86
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.
- package/dist/index.js +1876 -43
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -3548,6 +3548,93 @@ var init_operation_definitions = __esm(() => {
|
|
|
3548
3548
|
}),
|
|
3549
3549
|
referenceDocPath: "images/set-z-order.mdx",
|
|
3550
3550
|
referenceGroup: "images"
|
|
3551
|
+
},
|
|
3552
|
+
"hyperlinks.list": {
|
|
3553
|
+
memberPath: "hyperlinks.list",
|
|
3554
|
+
description: "List all hyperlinks in the document, with optional filtering by href, anchor, or display text.",
|
|
3555
|
+
expectedResult: "Returns a HyperlinksListResult with an array of hyperlink discovery items and pagination metadata.",
|
|
3556
|
+
requiresDocumentContext: true,
|
|
3557
|
+
metadata: readOperation({
|
|
3558
|
+
idempotency: "idempotent"
|
|
3559
|
+
}),
|
|
3560
|
+
referenceDocPath: "hyperlinks/list.mdx",
|
|
3561
|
+
referenceGroup: "hyperlinks"
|
|
3562
|
+
},
|
|
3563
|
+
"hyperlinks.get": {
|
|
3564
|
+
memberPath: "hyperlinks.get",
|
|
3565
|
+
description: "Retrieve details of a specific hyperlink by its inline address.",
|
|
3566
|
+
expectedResult: "Returns a HyperlinkInfo object with the address, destination properties, and display text.",
|
|
3567
|
+
requiresDocumentContext: true,
|
|
3568
|
+
metadata: readOperation({
|
|
3569
|
+
idempotency: "idempotent",
|
|
3570
|
+
throws: ["TARGET_NOT_FOUND", "INVALID_TARGET"]
|
|
3571
|
+
}),
|
|
3572
|
+
referenceDocPath: "hyperlinks/get.mdx",
|
|
3573
|
+
referenceGroup: "hyperlinks"
|
|
3574
|
+
},
|
|
3575
|
+
"hyperlinks.wrap": {
|
|
3576
|
+
memberPath: "hyperlinks.wrap",
|
|
3577
|
+
description: "Wrap an existing text range with a hyperlink.",
|
|
3578
|
+
expectedResult: "Returns a HyperlinkMutationResult with the created hyperlink address on success, or a failure code on no-op.",
|
|
3579
|
+
requiresDocumentContext: true,
|
|
3580
|
+
metadata: mutationOperation({
|
|
3581
|
+
idempotency: "conditional",
|
|
3582
|
+
supportsDryRun: true,
|
|
3583
|
+
supportsTrackedMode: false,
|
|
3584
|
+
deterministicTargetResolution: true,
|
|
3585
|
+
possibleFailureCodes: ["NO_OP"],
|
|
3586
|
+
throws: [...T_NOT_FOUND_CAPABLE, "INVALID_TARGET", "INVALID_INPUT"]
|
|
3587
|
+
}),
|
|
3588
|
+
referenceDocPath: "hyperlinks/wrap.mdx",
|
|
3589
|
+
referenceGroup: "hyperlinks"
|
|
3590
|
+
},
|
|
3591
|
+
"hyperlinks.insert": {
|
|
3592
|
+
memberPath: "hyperlinks.insert",
|
|
3593
|
+
description: "Insert new linked text at a target position.",
|
|
3594
|
+
expectedResult: "Returns a HyperlinkMutationResult with the created hyperlink address on success, or a failure code.",
|
|
3595
|
+
requiresDocumentContext: true,
|
|
3596
|
+
metadata: mutationOperation({
|
|
3597
|
+
idempotency: "non-idempotent",
|
|
3598
|
+
supportsDryRun: true,
|
|
3599
|
+
supportsTrackedMode: false,
|
|
3600
|
+
deterministicTargetResolution: true,
|
|
3601
|
+
possibleFailureCodes: ["NO_OP", "INVALID_TARGET"],
|
|
3602
|
+
throws: [...T_NOT_FOUND_CAPABLE, "INVALID_TARGET", "INVALID_INPUT"]
|
|
3603
|
+
}),
|
|
3604
|
+
referenceDocPath: "hyperlinks/insert.mdx",
|
|
3605
|
+
referenceGroup: "hyperlinks"
|
|
3606
|
+
},
|
|
3607
|
+
"hyperlinks.patch": {
|
|
3608
|
+
memberPath: "hyperlinks.patch",
|
|
3609
|
+
description: "Update hyperlink metadata (destination, tooltip, target, rel) without changing display text.",
|
|
3610
|
+
expectedResult: "Returns a HyperlinkMutationResult with the updated hyperlink address on success, or NO_OP if unchanged.",
|
|
3611
|
+
requiresDocumentContext: true,
|
|
3612
|
+
metadata: mutationOperation({
|
|
3613
|
+
idempotency: "conditional",
|
|
3614
|
+
supportsDryRun: true,
|
|
3615
|
+
supportsTrackedMode: false,
|
|
3616
|
+
deterministicTargetResolution: true,
|
|
3617
|
+
possibleFailureCodes: ["NO_OP"],
|
|
3618
|
+
throws: [...T_NOT_FOUND_CAPABLE, "INVALID_TARGET", "INVALID_INPUT"]
|
|
3619
|
+
}),
|
|
3620
|
+
referenceDocPath: "hyperlinks/patch.mdx",
|
|
3621
|
+
referenceGroup: "hyperlinks"
|
|
3622
|
+
},
|
|
3623
|
+
"hyperlinks.remove": {
|
|
3624
|
+
memberPath: "hyperlinks.remove",
|
|
3625
|
+
description: "Remove a hyperlink. Mode 'unwrap' preserves display text; 'deleteText' removes the linked content entirely.",
|
|
3626
|
+
expectedResult: "Returns a HyperlinkMutationResult with the removed hyperlink address on success, or a failure code on no-op.",
|
|
3627
|
+
requiresDocumentContext: true,
|
|
3628
|
+
metadata: mutationOperation({
|
|
3629
|
+
idempotency: "conditional",
|
|
3630
|
+
supportsDryRun: true,
|
|
3631
|
+
supportsTrackedMode: false,
|
|
3632
|
+
deterministicTargetResolution: true,
|
|
3633
|
+
possibleFailureCodes: ["NO_OP"],
|
|
3634
|
+
throws: [...T_NOT_FOUND_CAPABLE, "INVALID_TARGET", "INVALID_INPUT"]
|
|
3635
|
+
}),
|
|
3636
|
+
referenceDocPath: "hyperlinks/remove.mdx",
|
|
3637
|
+
referenceGroup: "hyperlinks"
|
|
3551
3638
|
}
|
|
3552
3639
|
};
|
|
3553
3640
|
OPERATION_IDS = Object.freeze(Object.keys(OPERATION_DEFINITIONS));
|
|
@@ -4833,6 +4920,9 @@ function tocEntryMutationResultSchema() {
|
|
|
4833
4920
|
oneOf: [tocEntryMutationSuccessSchema, tocEntryMutationFailureSchema]
|
|
4834
4921
|
};
|
|
4835
4922
|
}
|
|
4923
|
+
function hyperlinkMutationResultSchema() {
|
|
4924
|
+
return { oneOf: [hyperlinkMutationSuccessSchema, hyperlinkMutationFailureSchema] };
|
|
4925
|
+
}
|
|
4836
4926
|
function buildInternalContractSchemas() {
|
|
4837
4927
|
const operations = { ...operationSchemas };
|
|
4838
4928
|
for (const operationId of OPERATION_IDS) {
|
|
@@ -4852,7 +4942,7 @@ function buildInternalContractSchemas() {
|
|
|
4852
4942
|
operations
|
|
4853
4943
|
};
|
|
4854
4944
|
}
|
|
4855
|
-
var nodeTypeValues, blockNodeTypeValues, deletableBlockNodeTypeValues, inlineNodeTypeValues, knownTargetKindValues, SHARED_DEFS, rangeSchema, positionSchema, inlineAnchorSchema, targetKindSchema, textAddressSchema, textTargetSchema, blockNodeAddressSchema, deletableBlockNodeAddressSchema, paragraphAddressSchema, headingAddressSchema, listItemAddressSchema, paragraphTargetSchema, sectionAddressSchema, inlineNodeAddressSchema, nodeAddressSchema, commentAddressSchema, trackedChangeAddressSchema, entityAddressSchema, resolvedHandleSchema, pageInfoSchema, receiptSuccessSchema, textMutationRangeSchema, textMutationResolutionSchema, textMutationSuccessSchema, matchRunSchema, matchBlockSchema, trackChangeRefSchema, createParagraphSuccessSchema, createHeadingSuccessSchema, headingLevelSchema, listsInsertSuccessSchema, listsMutateItemSuccessSchema, listsExitSuccessSchema, nodeSummarySchema, nodeInfoSchema, matchContextSchema, unknownNodeDiagnosticSchema, textSelectorSchema, nodeSelectorSchema, selectorShorthandSchema, selectSchema, findInputSchema, findItemDomainSchema, findOutputSchema, documentInfoCountsSchema, documentInfoOutlineItemSchema, documentInfoCapabilitiesSchema, documentInfoSchema, listKindSchema, listInsertPositionSchema, listItemInfoSchema, listItemDomainItemSchema, listsListResultSchema, sectionBreakTypeSchema, sectionOrientationSchema, sectionVerticalAlignSchema, sectionDirectionSchema, sectionHeaderFooterKindSchema, sectionHeaderFooterVariantSchema, sectionLineNumberRestartSchema, sectionPageNumberFormatSchema, sectionRangeDomainSchema, sectionPageMarginsSchema, sectionHeaderFooterMarginsSchema, sectionPageSetupSchema, sectionColumnsSchema, sectionLineNumberingSchema, sectionPageNumberingSchema, sectionHeaderFooterRefsSchema, sectionBorderSpecSchema, sectionPageBordersSchema, sectionInfoSchema, sectionResolvedHandleSchema, sectionDomainItemSchema, sectionsListResultSchema, sectionMutationSuccessSchema, documentMutationSuccessSchema, paragraphMutationTargetSchema, paragraphMutationSuccessSchema, createSectionBreakSuccessSchema, commentInfoSchema, commentDomainItemSchema, commentsListResultSchema, trackChangeInfoSchema, trackChangeDomainItemSchema, trackChangesListResultSchema, capabilityReasonCodeSchema, capabilityReasonsSchema, capabilityFlagSchema, operationRuntimeCapabilitySchema, operationCapabilitiesSchema, inlinePropertyCapabilitySchema, inlinePropertyCapabilitiesByKeySchema, formatCapabilitiesSchema, planEngineCapabilitiesSchema, capabilitiesOutputSchema, strictEmptyObjectSchema, insertInputSchema, tableLocatorSchema, _tableScopedRowLocatorSchema, _tableScopedColumnLocatorSchema, mergeRangeLocatorSchema, mixedRowLocatorOneOf, tableCreateLocationSchema, tableMutationSuccessSchema, createTableSuccessSchema, tableMutationFailureCodes, tableMutationFailureSchema, tableMutationResultSchema, createTableResultSchema, historyActionSuccessSchema, historyActionFailureSchema, formatInlineAliasOperationSchemas, tocMutationFailureCodes, tocMutationFailureSchema, tocMutationSuccessSchema, tocEntryMutationFailureCodes, tocEntryMutationFailureSchema, tocEntryMutationSuccessSchema, operationSchemas;
|
|
4945
|
+
var nodeTypeValues, blockNodeTypeValues, deletableBlockNodeTypeValues, inlineNodeTypeValues, knownTargetKindValues, SHARED_DEFS, rangeSchema, positionSchema, inlineAnchorSchema, targetKindSchema, textAddressSchema, textTargetSchema, blockNodeAddressSchema, deletableBlockNodeAddressSchema, paragraphAddressSchema, headingAddressSchema, listItemAddressSchema, paragraphTargetSchema, sectionAddressSchema, inlineNodeAddressSchema, nodeAddressSchema, commentAddressSchema, trackedChangeAddressSchema, entityAddressSchema, resolvedHandleSchema, pageInfoSchema, receiptSuccessSchema, textMutationRangeSchema, textMutationResolutionSchema, textMutationSuccessSchema, matchRunSchema, matchBlockSchema, trackChangeRefSchema, createParagraphSuccessSchema, createHeadingSuccessSchema, headingLevelSchema, listsInsertSuccessSchema, listsMutateItemSuccessSchema, listsExitSuccessSchema, nodeSummarySchema, nodeInfoSchema, matchContextSchema, unknownNodeDiagnosticSchema, textSelectorSchema, nodeSelectorSchema, selectorShorthandSchema, selectSchema, findInputSchema, findItemDomainSchema, findOutputSchema, documentInfoCountsSchema, documentInfoOutlineItemSchema, documentInfoCapabilitiesSchema, documentInfoSchema, listKindSchema, listInsertPositionSchema, listItemInfoSchema, listItemDomainItemSchema, listsListResultSchema, sectionBreakTypeSchema, sectionOrientationSchema, sectionVerticalAlignSchema, sectionDirectionSchema, sectionHeaderFooterKindSchema, sectionHeaderFooterVariantSchema, sectionLineNumberRestartSchema, sectionPageNumberFormatSchema, sectionRangeDomainSchema, sectionPageMarginsSchema, sectionHeaderFooterMarginsSchema, sectionPageSetupSchema, sectionColumnsSchema, sectionLineNumberingSchema, sectionPageNumberingSchema, sectionHeaderFooterRefsSchema, sectionBorderSpecSchema, sectionPageBordersSchema, sectionInfoSchema, sectionResolvedHandleSchema, sectionDomainItemSchema, sectionsListResultSchema, sectionMutationSuccessSchema, documentMutationSuccessSchema, paragraphMutationTargetSchema, paragraphMutationSuccessSchema, createSectionBreakSuccessSchema, commentInfoSchema, commentDomainItemSchema, commentsListResultSchema, trackChangeInfoSchema, trackChangeDomainItemSchema, trackChangesListResultSchema, capabilityReasonCodeSchema, capabilityReasonsSchema, capabilityFlagSchema, operationRuntimeCapabilitySchema, operationCapabilitiesSchema, inlinePropertyCapabilitySchema, inlinePropertyCapabilitiesByKeySchema, formatCapabilitiesSchema, planEngineCapabilitiesSchema, capabilitiesOutputSchema, strictEmptyObjectSchema, insertInputSchema, tableLocatorSchema, _tableScopedRowLocatorSchema, _tableScopedColumnLocatorSchema, mergeRangeLocatorSchema, mixedRowLocatorOneOf, tableCreateLocationSchema, tableMutationSuccessSchema, createTableSuccessSchema, tableMutationFailureCodes, tableMutationFailureSchema, tableMutationResultSchema, createTableResultSchema, historyActionSuccessSchema, historyActionFailureSchema, formatInlineAliasOperationSchemas, tocMutationFailureCodes, tocMutationFailureSchema, tocMutationSuccessSchema, tocEntryMutationFailureCodes, tocEntryMutationFailureSchema, tocEntryMutationSuccessSchema, hyperlinkTargetSchema, hyperlinkReadPropertiesSchema, hyperlinkDestinationSchema, hyperlinkSpecSchema, hyperlinkPatchSchema, hyperlinkDomainSchema, hyperlinkMutationSuccessSchema, hyperlinkMutationFailureCodes, hyperlinkMutationFailureSchema, hyperlinkInfoSchema, operationSchemas;
|
|
4856
4946
|
var init_schemas = __esm(() => {
|
|
4857
4947
|
init_command_catalog();
|
|
4858
4948
|
init_types2();
|
|
@@ -5615,6 +5705,63 @@ var init_schemas = __esm(() => {
|
|
|
5615
5705
|
}, ["code", "message"])
|
|
5616
5706
|
}, ["success", "failure"]);
|
|
5617
5707
|
tocEntryMutationSuccessSchema = objectSchema({ success: { const: true }, entry: tocEntryAddressSchema() }, ["success", "entry"]);
|
|
5708
|
+
hyperlinkTargetSchema = objectSchema({
|
|
5709
|
+
kind: { const: "inline" },
|
|
5710
|
+
nodeType: { const: "hyperlink" },
|
|
5711
|
+
anchor: ref("InlineAnchor")
|
|
5712
|
+
}, ["kind", "nodeType", "anchor"]);
|
|
5713
|
+
hyperlinkReadPropertiesSchema = objectSchema({
|
|
5714
|
+
href: { type: "string" },
|
|
5715
|
+
anchor: { type: "string" },
|
|
5716
|
+
docLocation: { type: "string" },
|
|
5717
|
+
tooltip: { type: "string" },
|
|
5718
|
+
target: { type: "string" },
|
|
5719
|
+
rel: { type: "string" }
|
|
5720
|
+
});
|
|
5721
|
+
hyperlinkDestinationSchema = objectSchema({
|
|
5722
|
+
href: { type: "string" },
|
|
5723
|
+
anchor: { type: "string" },
|
|
5724
|
+
docLocation: { type: "string" }
|
|
5725
|
+
});
|
|
5726
|
+
hyperlinkSpecSchema = objectSchema({
|
|
5727
|
+
destination: hyperlinkDestinationSchema,
|
|
5728
|
+
tooltip: { type: "string" },
|
|
5729
|
+
target: { type: "string" },
|
|
5730
|
+
rel: { type: "string" }
|
|
5731
|
+
}, ["destination"]);
|
|
5732
|
+
hyperlinkPatchSchema = objectSchema({
|
|
5733
|
+
href: { oneOf: [{ type: "string" }, { type: "null" }] },
|
|
5734
|
+
anchor: { oneOf: [{ type: "string" }, { type: "null" }] },
|
|
5735
|
+
docLocation: { oneOf: [{ type: "string" }, { type: "null" }] },
|
|
5736
|
+
tooltip: { oneOf: [{ type: "string" }, { type: "null" }] },
|
|
5737
|
+
target: { oneOf: [{ type: "string" }, { type: "null" }] },
|
|
5738
|
+
rel: { oneOf: [{ type: "string" }, { type: "null" }] }
|
|
5739
|
+
});
|
|
5740
|
+
hyperlinkDomainSchema = objectSchema({
|
|
5741
|
+
address: hyperlinkTargetSchema,
|
|
5742
|
+
properties: hyperlinkReadPropertiesSchema,
|
|
5743
|
+
text: { type: "string" }
|
|
5744
|
+
}, ["address", "properties"]);
|
|
5745
|
+
hyperlinkMutationSuccessSchema = objectSchema({ success: { const: true }, hyperlink: hyperlinkTargetSchema }, ["success", "hyperlink"]);
|
|
5746
|
+
hyperlinkMutationFailureCodes = [
|
|
5747
|
+
"NO_OP",
|
|
5748
|
+
"INVALID_TARGET",
|
|
5749
|
+
"TARGET_NOT_FOUND",
|
|
5750
|
+
"CAPABILITY_UNAVAILABLE"
|
|
5751
|
+
];
|
|
5752
|
+
hyperlinkMutationFailureSchema = objectSchema({
|
|
5753
|
+
success: { const: false },
|
|
5754
|
+
failure: objectSchema({
|
|
5755
|
+
code: { enum: [...hyperlinkMutationFailureCodes] },
|
|
5756
|
+
message: { type: "string" },
|
|
5757
|
+
details: { type: "object" }
|
|
5758
|
+
}, ["code", "message"])
|
|
5759
|
+
}, ["success", "failure"]);
|
|
5760
|
+
hyperlinkInfoSchema = objectSchema({
|
|
5761
|
+
address: hyperlinkTargetSchema,
|
|
5762
|
+
properties: hyperlinkReadPropertiesSchema,
|
|
5763
|
+
text: { type: "string" }
|
|
5764
|
+
}, ["address", "properties"]);
|
|
5618
5765
|
operationSchemas = {
|
|
5619
5766
|
find: {
|
|
5620
5767
|
input: findInputSchema,
|
|
@@ -7765,6 +7912,48 @@ var init_schemas = __esm(() => {
|
|
|
7765
7912
|
success: { const: false },
|
|
7766
7913
|
failure: objectSchema({ code: { type: "string" }, message: { type: "string" } }, ["code", "message"])
|
|
7767
7914
|
}, ["success", "failure"])
|
|
7915
|
+
},
|
|
7916
|
+
"hyperlinks.list": {
|
|
7917
|
+
input: objectSchema({
|
|
7918
|
+
within: nodeAddressSchema,
|
|
7919
|
+
hrefPattern: { type: "string" },
|
|
7920
|
+
anchor: { type: "string" },
|
|
7921
|
+
textPattern: { type: "string" },
|
|
7922
|
+
limit: { type: "integer" },
|
|
7923
|
+
offset: { type: "integer" }
|
|
7924
|
+
}),
|
|
7925
|
+
output: discoveryResultSchema(hyperlinkDomainSchema)
|
|
7926
|
+
},
|
|
7927
|
+
"hyperlinks.get": {
|
|
7928
|
+
input: objectSchema({ target: hyperlinkTargetSchema }, ["target"]),
|
|
7929
|
+
output: hyperlinkInfoSchema
|
|
7930
|
+
},
|
|
7931
|
+
"hyperlinks.wrap": {
|
|
7932
|
+
input: objectSchema({ target: textAddressSchema, link: hyperlinkSpecSchema }, ["target", "link"]),
|
|
7933
|
+
output: hyperlinkMutationResultSchema(),
|
|
7934
|
+
success: hyperlinkMutationSuccessSchema,
|
|
7935
|
+
failure: hyperlinkMutationFailureSchema
|
|
7936
|
+
},
|
|
7937
|
+
"hyperlinks.insert": {
|
|
7938
|
+
input: objectSchema({ target: textAddressSchema, text: { type: "string" }, link: hyperlinkSpecSchema }, [
|
|
7939
|
+
"text",
|
|
7940
|
+
"link"
|
|
7941
|
+
]),
|
|
7942
|
+
output: hyperlinkMutationResultSchema(),
|
|
7943
|
+
success: hyperlinkMutationSuccessSchema,
|
|
7944
|
+
failure: hyperlinkMutationFailureSchema
|
|
7945
|
+
},
|
|
7946
|
+
"hyperlinks.patch": {
|
|
7947
|
+
input: objectSchema({ target: hyperlinkTargetSchema, patch: hyperlinkPatchSchema }, ["target", "patch"]),
|
|
7948
|
+
output: hyperlinkMutationResultSchema(),
|
|
7949
|
+
success: hyperlinkMutationSuccessSchema,
|
|
7950
|
+
failure: hyperlinkMutationFailureSchema
|
|
7951
|
+
},
|
|
7952
|
+
"hyperlinks.remove": {
|
|
7953
|
+
input: objectSchema({ target: hyperlinkTargetSchema, mode: { enum: ["unwrap", "deleteText"] } }, ["target"]),
|
|
7954
|
+
output: hyperlinkMutationResultSchema(),
|
|
7955
|
+
success: hyperlinkMutationSuccessSchema,
|
|
7956
|
+
failure: hyperlinkMutationFailureSchema
|
|
7768
7957
|
}
|
|
7769
7958
|
};
|
|
7770
7959
|
});
|
|
@@ -7874,6 +8063,11 @@ var init_reference_doc_map = __esm(() => {
|
|
|
7874
8063
|
title: "Images",
|
|
7875
8064
|
description: "Image lifecycle, placement, and wrap configuration.",
|
|
7876
8065
|
pagePath: "images/index.mdx"
|
|
8066
|
+
},
|
|
8067
|
+
hyperlinks: {
|
|
8068
|
+
title: "Hyperlinks",
|
|
8069
|
+
description: "Hyperlink discovery, creation, and metadata management.",
|
|
8070
|
+
pagePath: "hyperlinks/index.mdx"
|
|
7877
8071
|
}
|
|
7878
8072
|
};
|
|
7879
8073
|
REFERENCE_OPERATION_GROUPS = Object.keys(GROUP_METADATA).map((key) => ({
|
|
@@ -8988,7 +9182,13 @@ function buildDispatchTable(api) {
|
|
|
8988
9182
|
"images.setWrapDistances": (input, options) => api.images.setWrapDistances(input, options),
|
|
8989
9183
|
"images.setPosition": (input, options) => api.images.setPosition(input, options),
|
|
8990
9184
|
"images.setAnchorOptions": (input, options) => api.images.setAnchorOptions(input, options),
|
|
8991
|
-
"images.setZOrder": (input, options) => api.images.setZOrder(input, options)
|
|
9185
|
+
"images.setZOrder": (input, options) => api.images.setZOrder(input, options),
|
|
9186
|
+
"hyperlinks.list": (input) => api.hyperlinks.list(input),
|
|
9187
|
+
"hyperlinks.get": (input) => api.hyperlinks.get(input),
|
|
9188
|
+
"hyperlinks.wrap": (input, options) => api.hyperlinks.wrap(input, options),
|
|
9189
|
+
"hyperlinks.insert": (input, options) => api.hyperlinks.insert(input, options),
|
|
9190
|
+
"hyperlinks.patch": (input, options) => api.hyperlinks.patch(input, options),
|
|
9191
|
+
"hyperlinks.remove": (input, options) => api.hyperlinks.remove(input, options)
|
|
8992
9192
|
};
|
|
8993
9193
|
}
|
|
8994
9194
|
var init_invoke = __esm(() => {
|
|
@@ -9629,6 +9829,116 @@ var init_toc = __esm(() => {
|
|
|
9629
9829
|
init_errors2();
|
|
9630
9830
|
});
|
|
9631
9831
|
|
|
9832
|
+
// ../../packages/document-api/src/hyperlinks/hyperlinks.ts
|
|
9833
|
+
function isHyperlinkTarget(value) {
|
|
9834
|
+
if (!isRecord(value))
|
|
9835
|
+
return false;
|
|
9836
|
+
if (value.kind !== "inline" || value.nodeType !== "hyperlink")
|
|
9837
|
+
return false;
|
|
9838
|
+
const anchor = value.anchor;
|
|
9839
|
+
if (!isRecord(anchor))
|
|
9840
|
+
return false;
|
|
9841
|
+
const start = anchor.start;
|
|
9842
|
+
const end = anchor.end;
|
|
9843
|
+
if (!isRecord(start) || !isRecord(end))
|
|
9844
|
+
return false;
|
|
9845
|
+
return typeof start.blockId === "string" && typeof start.offset === "number" && typeof end.blockId === "string" && typeof end.offset === "number";
|
|
9846
|
+
}
|
|
9847
|
+
function validateHyperlinkTarget(target, operationName) {
|
|
9848
|
+
if (target === undefined || target === null) {
|
|
9849
|
+
throw new DocumentApiValidationError("INVALID_TARGET", `${operationName} requires a target.`);
|
|
9850
|
+
}
|
|
9851
|
+
if (!isHyperlinkTarget(target)) {
|
|
9852
|
+
throw new DocumentApiValidationError("INVALID_TARGET", `${operationName} target must be a HyperlinkTarget with kind 'inline', nodeType 'hyperlink', and a valid anchor.`, { target });
|
|
9853
|
+
}
|
|
9854
|
+
}
|
|
9855
|
+
function validateDestination(destination, operationName) {
|
|
9856
|
+
if (!isRecord(destination)) {
|
|
9857
|
+
throw new DocumentApiValidationError("INVALID_INPUT", `${operationName} requires a destination object.`);
|
|
9858
|
+
}
|
|
9859
|
+
const hasHref = typeof destination.href === "string" && destination.href.length > 0;
|
|
9860
|
+
const hasAnchor = typeof destination.anchor === "string" && destination.anchor.length > 0;
|
|
9861
|
+
if (!hasHref && !hasAnchor) {
|
|
9862
|
+
throw new DocumentApiValidationError("INVALID_INPUT", `${operationName} destination must have at least one of 'href' or 'anchor'.`);
|
|
9863
|
+
}
|
|
9864
|
+
}
|
|
9865
|
+
function validateHyperlinkSpec(link, operationName) {
|
|
9866
|
+
if (!isRecord(link)) {
|
|
9867
|
+
throw new DocumentApiValidationError("INVALID_INPUT", `${operationName} requires a link specification object.`);
|
|
9868
|
+
}
|
|
9869
|
+
validateDestination(link.destination, operationName);
|
|
9870
|
+
}
|
|
9871
|
+
function validatePatch(patch, operationName) {
|
|
9872
|
+
if (!isRecord(patch)) {
|
|
9873
|
+
throw new DocumentApiValidationError("INVALID_INPUT", `${operationName} requires a patch object.`);
|
|
9874
|
+
}
|
|
9875
|
+
for (const key of Object.keys(patch)) {
|
|
9876
|
+
if (!PATCH_FIELDS.has(key)) {
|
|
9877
|
+
throw new DocumentApiValidationError("INVALID_INPUT", `Unknown field "${key}" on ${operationName} patch. Allowed: ${[...PATCH_FIELDS].join(", ")}.`, { field: key });
|
|
9878
|
+
}
|
|
9879
|
+
}
|
|
9880
|
+
const hasField = Object.keys(patch).some((k) => patch[k] !== undefined);
|
|
9881
|
+
if (!hasField) {
|
|
9882
|
+
throw new DocumentApiValidationError("INVALID_INPUT", `${operationName} patch must set at least one field.`);
|
|
9883
|
+
}
|
|
9884
|
+
for (const key of PATCH_FIELDS) {
|
|
9885
|
+
const val = patch[key];
|
|
9886
|
+
if (val !== undefined && val !== null && typeof val !== "string") {
|
|
9887
|
+
throw new DocumentApiValidationError("INVALID_INPUT", `${operationName} patch.${key} must be a string, null, or omitted.`);
|
|
9888
|
+
}
|
|
9889
|
+
}
|
|
9890
|
+
}
|
|
9891
|
+
function executeHyperlinksList(adapter, query2) {
|
|
9892
|
+
return adapter.list(query2);
|
|
9893
|
+
}
|
|
9894
|
+
function executeHyperlinksGet(adapter, input) {
|
|
9895
|
+
validateHyperlinkTarget(input.target, "hyperlinks.get");
|
|
9896
|
+
return adapter.get(input);
|
|
9897
|
+
}
|
|
9898
|
+
function executeHyperlinksWrap(adapter, input, options) {
|
|
9899
|
+
if (!isTextAddress(input.target)) {
|
|
9900
|
+
throw new DocumentApiValidationError("INVALID_TARGET", "hyperlinks.wrap requires a valid TextAddress target with kind 'text', blockId, and range.");
|
|
9901
|
+
}
|
|
9902
|
+
if (input.target.range.start === input.target.range.end) {
|
|
9903
|
+
throw new DocumentApiValidationError("INVALID_TARGET", "hyperlinks.wrap requires a non-collapsed range (start !== end).");
|
|
9904
|
+
}
|
|
9905
|
+
validateHyperlinkSpec(input.link, "hyperlinks.wrap");
|
|
9906
|
+
return adapter.wrap(input, normalizeMutationOptions(options));
|
|
9907
|
+
}
|
|
9908
|
+
function executeHyperlinksInsert(adapter, input, options) {
|
|
9909
|
+
if (typeof input.text !== "string" || input.text.length === 0) {
|
|
9910
|
+
throw new DocumentApiValidationError("INVALID_INPUT", "hyperlinks.insert requires a non-empty text string.");
|
|
9911
|
+
}
|
|
9912
|
+
if (input.target !== undefined) {
|
|
9913
|
+
if (!isTextAddress(input.target)) {
|
|
9914
|
+
throw new DocumentApiValidationError("INVALID_TARGET", "hyperlinks.insert target (if provided) must be a valid TextAddress with kind 'text', blockId, and range.");
|
|
9915
|
+
}
|
|
9916
|
+
if (input.target.range.start !== input.target.range.end) {
|
|
9917
|
+
throw new DocumentApiValidationError("INVALID_TARGET", "hyperlinks.insert target must be a collapsed range (start === end) indicating the insertion point.");
|
|
9918
|
+
}
|
|
9919
|
+
}
|
|
9920
|
+
validateHyperlinkSpec(input.link, "hyperlinks.insert");
|
|
9921
|
+
return adapter.insert(input, normalizeMutationOptions(options));
|
|
9922
|
+
}
|
|
9923
|
+
function executeHyperlinksPatch(adapter, input, options) {
|
|
9924
|
+
validateHyperlinkTarget(input.target, "hyperlinks.patch");
|
|
9925
|
+
validatePatch(input.patch, "hyperlinks.patch");
|
|
9926
|
+
return adapter.patch(input, normalizeMutationOptions(options));
|
|
9927
|
+
}
|
|
9928
|
+
function executeHyperlinksRemove(adapter, input, options) {
|
|
9929
|
+
validateHyperlinkTarget(input.target, "hyperlinks.remove");
|
|
9930
|
+
if (input.mode !== undefined && input.mode !== "unwrap" && input.mode !== "deleteText") {
|
|
9931
|
+
throw new DocumentApiValidationError("INVALID_INPUT", `hyperlinks.remove mode must be 'unwrap' or 'deleteText', got '${String(input.mode)}'.`);
|
|
9932
|
+
}
|
|
9933
|
+
return adapter.remove(input, normalizeMutationOptions(options));
|
|
9934
|
+
}
|
|
9935
|
+
var PATCH_FIELDS;
|
|
9936
|
+
var init_hyperlinks = __esm(() => {
|
|
9937
|
+
init_errors2();
|
|
9938
|
+
init_validation_primitives();
|
|
9939
|
+
PATCH_FIELDS = new Set(["href", "anchor", "docLocation", "tooltip", "target", "rel"]);
|
|
9940
|
+
});
|
|
9941
|
+
|
|
9632
9942
|
// ../../packages/document-api/src/lists/lists.types.ts
|
|
9633
9943
|
var LIST_KINDS, LIST_INSERT_POSITIONS;
|
|
9634
9944
|
var init_lists_types = __esm(() => {
|
|
@@ -10158,6 +10468,26 @@ function createDocumentApi(adapters) {
|
|
|
10158
10468
|
return executeTocEditEntry(adapters.toc, input, options);
|
|
10159
10469
|
}
|
|
10160
10470
|
},
|
|
10471
|
+
hyperlinks: {
|
|
10472
|
+
list(query2) {
|
|
10473
|
+
return executeHyperlinksList(adapters.hyperlinks, query2);
|
|
10474
|
+
},
|
|
10475
|
+
get(input) {
|
|
10476
|
+
return executeHyperlinksGet(adapters.hyperlinks, input);
|
|
10477
|
+
},
|
|
10478
|
+
wrap(input, options) {
|
|
10479
|
+
return executeHyperlinksWrap(adapters.hyperlinks, input, options);
|
|
10480
|
+
},
|
|
10481
|
+
insert(input, options) {
|
|
10482
|
+
return executeHyperlinksInsert(adapters.hyperlinks, input, options);
|
|
10483
|
+
},
|
|
10484
|
+
patch(input, options) {
|
|
10485
|
+
return executeHyperlinksPatch(adapters.hyperlinks, input, options);
|
|
10486
|
+
},
|
|
10487
|
+
remove(input, options) {
|
|
10488
|
+
return executeHyperlinksRemove(adapters.hyperlinks, input, options);
|
|
10489
|
+
}
|
|
10490
|
+
},
|
|
10161
10491
|
query: {
|
|
10162
10492
|
match(input) {
|
|
10163
10493
|
return adapters.query.match(input);
|
|
@@ -10212,6 +10542,7 @@ var init_src = __esm(() => {
|
|
|
10212
10542
|
init_sections();
|
|
10213
10543
|
init_images();
|
|
10214
10544
|
init_toc();
|
|
10545
|
+
init_hyperlinks();
|
|
10215
10546
|
init_inline_run_patch();
|
|
10216
10547
|
init_styles();
|
|
10217
10548
|
init_paragraphs();
|
|
@@ -32447,7 +32778,7 @@ var init_remark_gfm_z_sDF4ss_es = __esm(() => {
|
|
|
32447
32778
|
emptyOptions2 = {};
|
|
32448
32779
|
});
|
|
32449
32780
|
|
|
32450
|
-
// ../../packages/superdoc/dist/chunks/SuperConverter-
|
|
32781
|
+
// ../../packages/superdoc/dist/chunks/SuperConverter-C3jSWLmj.es.js
|
|
32451
32782
|
function getExtensionConfigField(extension$1, field, context = { name: "" }) {
|
|
32452
32783
|
const fieldValue = extension$1.config[field];
|
|
32453
32784
|
if (typeof fieldValue === "function")
|
|
@@ -34396,6 +34727,9 @@ function tocEntryInsertionTargetSchema2() {
|
|
|
34396
34727
|
function tocEntryMutationResultSchema2() {
|
|
34397
34728
|
return { oneOf: [tocEntryMutationSuccessSchema2, tocEntryMutationFailureSchema2] };
|
|
34398
34729
|
}
|
|
34730
|
+
function hyperlinkMutationResultSchema2() {
|
|
34731
|
+
return { oneOf: [hyperlinkMutationSuccessSchema2, hyperlinkMutationFailureSchema2] };
|
|
34732
|
+
}
|
|
34399
34733
|
function step2(opId, domain2, description, options = {}) {
|
|
34400
34734
|
return {
|
|
34401
34735
|
opId,
|
|
@@ -35219,7 +35553,13 @@ function buildDispatchTable2(api) {
|
|
|
35219
35553
|
"images.setWrapDistances": (input, options) => api.images.setWrapDistances(input, options),
|
|
35220
35554
|
"images.setPosition": (input, options) => api.images.setPosition(input, options),
|
|
35221
35555
|
"images.setAnchorOptions": (input, options) => api.images.setAnchorOptions(input, options),
|
|
35222
|
-
"images.setZOrder": (input, options) => api.images.setZOrder(input, options)
|
|
35556
|
+
"images.setZOrder": (input, options) => api.images.setZOrder(input, options),
|
|
35557
|
+
"hyperlinks.list": (input) => api.hyperlinks.list(input),
|
|
35558
|
+
"hyperlinks.get": (input) => api.hyperlinks.get(input),
|
|
35559
|
+
"hyperlinks.wrap": (input, options) => api.hyperlinks.wrap(input, options),
|
|
35560
|
+
"hyperlinks.insert": (input, options) => api.hyperlinks.insert(input, options),
|
|
35561
|
+
"hyperlinks.patch": (input, options) => api.hyperlinks.patch(input, options),
|
|
35562
|
+
"hyperlinks.remove": (input, options) => api.hyperlinks.remove(input, options)
|
|
35223
35563
|
};
|
|
35224
35564
|
}
|
|
35225
35565
|
function executeHistoryGet2(adapter) {
|
|
@@ -35744,6 +36084,91 @@ function executeTocEditEntry2(adapter, input, options) {
|
|
|
35744
36084
|
validateTocEntryTarget2(input.target, "toc.editEntry");
|
|
35745
36085
|
return adapter.editEntry(input, normalizeMutationOptions2(options));
|
|
35746
36086
|
}
|
|
36087
|
+
function isHyperlinkTarget2(value) {
|
|
36088
|
+
if (!isRecord3(value))
|
|
36089
|
+
return false;
|
|
36090
|
+
if (value.kind !== "inline" || value.nodeType !== "hyperlink")
|
|
36091
|
+
return false;
|
|
36092
|
+
const anchor = value.anchor;
|
|
36093
|
+
if (!isRecord3(anchor))
|
|
36094
|
+
return false;
|
|
36095
|
+
const start = anchor.start;
|
|
36096
|
+
const end = anchor.end;
|
|
36097
|
+
if (!isRecord3(start) || !isRecord3(end))
|
|
36098
|
+
return false;
|
|
36099
|
+
return typeof start.blockId === "string" && typeof start.offset === "number" && typeof end.blockId === "string" && typeof end.offset === "number";
|
|
36100
|
+
}
|
|
36101
|
+
function validateHyperlinkTarget2(target, operationName) {
|
|
36102
|
+
if (target === undefined || target === null)
|
|
36103
|
+
throw new DocumentApiValidationError2("INVALID_TARGET", `${operationName} requires a target.`);
|
|
36104
|
+
if (!isHyperlinkTarget2(target))
|
|
36105
|
+
throw new DocumentApiValidationError2("INVALID_TARGET", `${operationName} target must be a HyperlinkTarget with kind 'inline', nodeType 'hyperlink', and a valid anchor.`, { target });
|
|
36106
|
+
}
|
|
36107
|
+
function validateDestination2(destination, operationName) {
|
|
36108
|
+
if (!isRecord3(destination))
|
|
36109
|
+
throw new DocumentApiValidationError2("INVALID_INPUT", `${operationName} requires a destination object.`);
|
|
36110
|
+
const hasHref = typeof destination.href === "string" && destination.href.length > 0;
|
|
36111
|
+
const hasAnchor = typeof destination.anchor === "string" && destination.anchor.length > 0;
|
|
36112
|
+
if (!hasHref && !hasAnchor)
|
|
36113
|
+
throw new DocumentApiValidationError2("INVALID_INPUT", `${operationName} destination must have at least one of 'href' or 'anchor'.`);
|
|
36114
|
+
}
|
|
36115
|
+
function validateHyperlinkSpec2(link2, operationName) {
|
|
36116
|
+
if (!isRecord3(link2))
|
|
36117
|
+
throw new DocumentApiValidationError2("INVALID_INPUT", `${operationName} requires a link specification object.`);
|
|
36118
|
+
validateDestination2(link2.destination, operationName);
|
|
36119
|
+
}
|
|
36120
|
+
function validatePatch2(patch, operationName) {
|
|
36121
|
+
if (!isRecord3(patch))
|
|
36122
|
+
throw new DocumentApiValidationError2("INVALID_INPUT", `${operationName} requires a patch object.`);
|
|
36123
|
+
for (const key of Object.keys(patch))
|
|
36124
|
+
if (!PATCH_FIELDS2.has(key))
|
|
36125
|
+
throw new DocumentApiValidationError2("INVALID_INPUT", `Unknown field "${key}" on ${operationName} patch. Allowed: ${[...PATCH_FIELDS2].join(", ")}.`, { field: key });
|
|
36126
|
+
if (!Object.keys(patch).some((k) => patch[k] !== undefined))
|
|
36127
|
+
throw new DocumentApiValidationError2("INVALID_INPUT", `${operationName} patch must set at least one field.`);
|
|
36128
|
+
for (const key of PATCH_FIELDS2) {
|
|
36129
|
+
const val = patch[key];
|
|
36130
|
+
if (val !== undefined && val !== null && typeof val !== "string")
|
|
36131
|
+
throw new DocumentApiValidationError2("INVALID_INPUT", `${operationName} patch.${key} must be a string, null, or omitted.`);
|
|
36132
|
+
}
|
|
36133
|
+
}
|
|
36134
|
+
function executeHyperlinksList2(adapter, query2) {
|
|
36135
|
+
return adapter.list(query2);
|
|
36136
|
+
}
|
|
36137
|
+
function executeHyperlinksGet2(adapter, input) {
|
|
36138
|
+
validateHyperlinkTarget2(input.target, "hyperlinks.get");
|
|
36139
|
+
return adapter.get(input);
|
|
36140
|
+
}
|
|
36141
|
+
function executeHyperlinksWrap2(adapter, input, options) {
|
|
36142
|
+
if (!isTextAddress2(input.target))
|
|
36143
|
+
throw new DocumentApiValidationError2("INVALID_TARGET", "hyperlinks.wrap requires a valid TextAddress target with kind 'text', blockId, and range.");
|
|
36144
|
+
if (input.target.range.start === input.target.range.end)
|
|
36145
|
+
throw new DocumentApiValidationError2("INVALID_TARGET", "hyperlinks.wrap requires a non-collapsed range (start !== end).");
|
|
36146
|
+
validateHyperlinkSpec2(input.link, "hyperlinks.wrap");
|
|
36147
|
+
return adapter.wrap(input, normalizeMutationOptions2(options));
|
|
36148
|
+
}
|
|
36149
|
+
function executeHyperlinksInsert2(adapter, input, options) {
|
|
36150
|
+
if (typeof input.text !== "string" || input.text.length === 0)
|
|
36151
|
+
throw new DocumentApiValidationError2("INVALID_INPUT", "hyperlinks.insert requires a non-empty text string.");
|
|
36152
|
+
if (input.target !== undefined) {
|
|
36153
|
+
if (!isTextAddress2(input.target))
|
|
36154
|
+
throw new DocumentApiValidationError2("INVALID_TARGET", "hyperlinks.insert target (if provided) must be a valid TextAddress with kind 'text', blockId, and range.");
|
|
36155
|
+
if (input.target.range.start !== input.target.range.end)
|
|
36156
|
+
throw new DocumentApiValidationError2("INVALID_TARGET", "hyperlinks.insert target must be a collapsed range (start === end) indicating the insertion point.");
|
|
36157
|
+
}
|
|
36158
|
+
validateHyperlinkSpec2(input.link, "hyperlinks.insert");
|
|
36159
|
+
return adapter.insert(input, normalizeMutationOptions2(options));
|
|
36160
|
+
}
|
|
36161
|
+
function executeHyperlinksPatch2(adapter, input, options) {
|
|
36162
|
+
validateHyperlinkTarget2(input.target, "hyperlinks.patch");
|
|
36163
|
+
validatePatch2(input.patch, "hyperlinks.patch");
|
|
36164
|
+
return adapter.patch(input, normalizeMutationOptions2(options));
|
|
36165
|
+
}
|
|
36166
|
+
function executeHyperlinksRemove2(adapter, input, options) {
|
|
36167
|
+
validateHyperlinkTarget2(input.target, "hyperlinks.remove");
|
|
36168
|
+
if (input.mode !== undefined && input.mode !== "unwrap" && input.mode !== "deleteText")
|
|
36169
|
+
throw new DocumentApiValidationError2("INVALID_INPUT", `hyperlinks.remove mode must be 'unwrap' or 'deleteText', got '${String(input.mode)}'.`);
|
|
36170
|
+
return adapter.remove(input, normalizeMutationOptions2(options));
|
|
36171
|
+
}
|
|
35747
36172
|
function buildFormatInlineAliasApi2(adapter) {
|
|
35748
36173
|
return Object.fromEntries(INLINE_PROPERTY_REGISTRY2.map((entry) => {
|
|
35749
36174
|
const key = entry.key;
|
|
@@ -36267,6 +36692,26 @@ function createDocumentApi2(adapters) {
|
|
|
36267
36692
|
return executeTocEditEntry2(adapters.toc, input, options);
|
|
36268
36693
|
}
|
|
36269
36694
|
},
|
|
36695
|
+
hyperlinks: {
|
|
36696
|
+
list(query2) {
|
|
36697
|
+
return executeHyperlinksList2(adapters.hyperlinks, query2);
|
|
36698
|
+
},
|
|
36699
|
+
get(input) {
|
|
36700
|
+
return executeHyperlinksGet2(adapters.hyperlinks, input);
|
|
36701
|
+
},
|
|
36702
|
+
wrap(input, options) {
|
|
36703
|
+
return executeHyperlinksWrap2(adapters.hyperlinks, input, options);
|
|
36704
|
+
},
|
|
36705
|
+
insert(input, options) {
|
|
36706
|
+
return executeHyperlinksInsert2(adapters.hyperlinks, input, options);
|
|
36707
|
+
},
|
|
36708
|
+
patch(input, options) {
|
|
36709
|
+
return executeHyperlinksPatch2(adapters.hyperlinks, input, options);
|
|
36710
|
+
},
|
|
36711
|
+
remove(input, options) {
|
|
36712
|
+
return executeHyperlinksRemove2(adapters.hyperlinks, input, options);
|
|
36713
|
+
}
|
|
36714
|
+
},
|
|
36270
36715
|
query: { match(input) {
|
|
36271
36716
|
return adapters.query.match(input);
|
|
36272
36717
|
} },
|
|
@@ -52455,7 +52900,7 @@ var isRegExp = (value) => {
|
|
|
52455
52900
|
tracked: false,
|
|
52456
52901
|
carrier: runAttributeCarrier2(runPropertyKey ?? key),
|
|
52457
52902
|
schema
|
|
52458
|
-
}), INLINE_PROPERTY_REGISTRY2, INLINE_PROPERTY_KEY_SET2, INLINE_PROPERTY_BY_KEY2, UNDERLINE_OBJECT_ALLOWED_KEYS2, SHADING_ALLOWED_KEYS2, BORDER_ALLOWED_KEYS2, FIT_TEXT_ALLOWED_KEYS2, LANG_ALLOWED_KEYS2, RFONTS_ALLOWED_KEYS2, EAST_ASIAN_LAYOUT_ALLOWED_KEYS2, STYLISTIC_SET_ALLOWED_KEYS2, VERT_ALIGN_VALUES2, NONE_FAILURES2, NONE_THROWS2, T_NOT_FOUND2, T_NOT_FOUND_CAPABLE2, T_PLAN_ENGINE2, T_NOT_FOUND_COMMAND2, T_NOT_FOUND_COMMAND_TRACKED2, T_IMAGE_COMMAND2, T_QUERY_MATCH2, T_SECTION_CREATE2, T_SECTION_READ2, T_PARAGRAPH_MUTATION2, T_SECTION_MUTATION2, T_SECTION_SETTINGS_MUTATION2, FORMAT_INLINE_ALIAS_OPERATION_DEFINITIONS2, OPERATION_DEFINITIONS2, OPERATION_IDS2, COMMAND_CATALOG3, PARAGRAPH_ALIGNMENTS2, TAB_STOP_ALIGNMENTS2, TAB_STOP_LEADERS2, BORDER_SIDES2, CLEAR_BORDER_SIDES2, LINE_RULES2, PARAGRAPH_BLOCK_TYPES2, SET_STYLE_KEYS2, CLEAR_STYLE_KEYS2, RESET_DIRECT_FORMATTING_KEYS2, SET_ALIGNMENT_KEYS2, CLEAR_ALIGNMENT_KEYS2, SET_INDENTATION_KEYS2, CLEAR_INDENTATION_KEYS2, SET_SPACING_KEYS2, CLEAR_SPACING_KEYS2, SET_KEEP_OPTIONS_KEYS2, SET_OUTLINE_LEVEL_KEYS2, SET_FLOW_OPTIONS_KEYS2, SET_TAB_STOP_KEYS2, CLEAR_TAB_STOP_KEYS2, CLEAR_ALL_TAB_STOPS_KEYS2, SET_BORDER_KEYS2, CLEAR_BORDER_KEYS2, SET_SHADING_KEYS2, CLEAR_SHADING_KEYS2, ST_ON_OFF_ON_VALUES2, ST_ON_OFF_OFF_VALUES2, ST_UNDERLINE_VALUES2, ST_UNDERLINE_VALUE_SET2, ST_VERTICAL_ALIGN_RUN2, ST_EM2, ST_TEXT_ALIGNMENT2, ST_TEXT_DIRECTION2, ST_TEXTBOX_TIGHT_WRAP2, ST_TEXT_TRANSFORM2, ST_JUSTIFICATION2, FONT_FAMILY_SCHEMA2, COLOR_SCHEMA2, SPACING_SCHEMA2, INDENT_SCHEMA2, UNDERLINE_SCHEMA2, BORDER_PROPERTIES_SCHEMA2, SHADING_SCHEMA2, LANG_SCHEMA2, EAST_ASIAN_LAYOUT_SCHEMA2, FIT_TEXT_SCHEMA2, NUMBERING_PROPERTIES_SCHEMA2, FRAME_PR_SCHEMA2, PARAGRAPH_BORDERS_SCHEMA2, TAB_STOP_SCHEMA2, PROPERTY_REGISTRY3, ALLOWED_KEYS_BY_CHANNEL2, PROPERTY_INDEX2, EXCLUDED_KEYS2, INPUT_ALLOWED_KEYS2, TARGET_ALLOWED_KEYS2, OPTIONS_ALLOWED_KEYS2, VALID_CHANNELS2, Z_ORDER_RELATIVE_HEIGHT_MAX2 = 4294967295, nodeTypeValues2, blockNodeTypeValues2, deletableBlockNodeTypeValues2, inlineNodeTypeValues2, rangeSchema2, textAddressSchema2, textTargetSchema2, blockNodeAddressSchema2, deletableBlockNodeAddressSchema2, paragraphAddressSchema2, headingAddressSchema2, listItemAddressSchema2, paragraphTargetSchema2, sectionAddressSchema2, nodeAddressSchema2, commentAddressSchema2, trackedChangeAddressSchema2, entityAddressSchema2, resolvedHandleSchema2, pageInfoSchema2, receiptSuccessSchema2, textMutationResolutionSchema2, textMutationSuccessSchema2, matchBlockSchema2, trackChangeRefSchema2, createParagraphSuccessSchema2, createHeadingSuccessSchema2, headingLevelSchema2, listsInsertSuccessSchema2, listsMutateItemSuccessSchema2, nodeSummarySchema2, nodeInfoSchema2, matchContextSchema2, unknownNodeDiagnosticSchema2, textSelectorSchema2, nodeSelectorSchema2, findItemDomainSchema2, documentInfoCountsSchema2, documentInfoOutlineItemSchema2, documentInfoCapabilitiesSchema2, listKindSchema2, listInsertPositionSchema2, sectionBreakTypeSchema2, sectionOrientationSchema2, sectionVerticalAlignSchema2, sectionDirectionSchema2, sectionHeaderFooterKindSchema2, sectionHeaderFooterVariantSchema2, sectionLineNumberRestartSchema2, sectionPageNumberFormatSchema2, sectionRangeDomainSchema2, sectionPageMarginsSchema2, sectionHeaderFooterMarginsSchema2, sectionPageSetupSchema2, sectionColumnsSchema2, sectionLineNumberingSchema2, sectionPageNumberingSchema2, sectionHeaderFooterRefsSchema2, sectionBorderSpecSchema2, sectionPageBordersSchema2, sectionMutationSuccessSchema2, documentMutationSuccessSchema2, paragraphMutationTargetSchema2, paragraphMutationSuccessSchema2, createSectionBreakSuccessSchema2, capabilityReasonsSchema2, capabilityFlagSchema2, operationRuntimeCapabilitySchema2, operationCapabilitiesSchema2, inlinePropertyCapabilitySchema2, formatCapabilitiesSchema2, planEngineCapabilitiesSchema2, tableCreateLocationSchema2, formatInlineAliasOperationSchemas2, tocMutationFailureSchema2, tocMutationSuccessSchema2, tocEntryMutationFailureSchema2, tocEntryMutationSuccessSchema2, GROUP_METADATA2, STEP_OP_CATALOG_UNFROZEN2, PUBLIC_STEP_OP_CATALOG_UNFROZEN2, PUBLIC_MUTATION_STEP_OP_IDS2, PUBLIC_MUTATION_STEP_OP_SET2, CAPABILITY_REASON_CODES2, CREATE_COMMENT_ALLOWED_KEYS2, PATCH_COMMENT_ALLOWED_KEYS2, STYLE_APPLY_INPUT_ALLOWED_KEYS2, INLINE_ALIAS_INPUT_ALLOWED_KEYS2, DELETE_INPUT_ALLOWED_KEYS2, INSERT_INPUT_ALLOWED_KEYS2, VALID_INSERT_TYPES2, REPLACE_INPUT_ALLOWED_KEYS2, SECTION_BREAK_TYPES$1, SUPPORTED_DELETE_NODE_TYPES2, REJECTED_DELETE_NODE_TYPES2, TABLE_LOCATOR_OPS2, ROW_LOCATOR_OPS2, COLUMN_LOCATOR_OPS2, MERGE_RANGE_LOCATOR_OPS2, DEFAULT_SECTIONS_LIST_LIMIT2 = 250, SECTION_BREAK_TYPES3, SECTION_ORIENTATIONS2, SECTION_VERTICAL_ALIGNS2, SECTION_DIRECTIONS2, HEADER_FOOTER_KINDS2, HEADER_FOOTER_VARIANTS2, LINE_NUMBER_RESTARTS2, PAGE_NUMBER_FORMATS2, PAGE_BORDER_DISPLAYS2, PAGE_BORDER_OFFSET_FROM_VALUES2, PAGE_BORDER_Z_ORDER_VALUES2, VALID_WRAP_TYPES2, VALID_WRAP_SIDES2, VALID_IMAGE_SIZE_UNITS2, _buffers, _defaultCollectionId = null, _nextCollectionId = 1, generateV2HandlerEntity = (handlerName, translator$208) => ({
|
|
52903
|
+
}), INLINE_PROPERTY_REGISTRY2, INLINE_PROPERTY_KEY_SET2, INLINE_PROPERTY_BY_KEY2, UNDERLINE_OBJECT_ALLOWED_KEYS2, SHADING_ALLOWED_KEYS2, BORDER_ALLOWED_KEYS2, FIT_TEXT_ALLOWED_KEYS2, LANG_ALLOWED_KEYS2, RFONTS_ALLOWED_KEYS2, EAST_ASIAN_LAYOUT_ALLOWED_KEYS2, STYLISTIC_SET_ALLOWED_KEYS2, VERT_ALIGN_VALUES2, NONE_FAILURES2, NONE_THROWS2, T_NOT_FOUND2, T_NOT_FOUND_CAPABLE2, T_PLAN_ENGINE2, T_NOT_FOUND_COMMAND2, T_NOT_FOUND_COMMAND_TRACKED2, T_IMAGE_COMMAND2, T_QUERY_MATCH2, T_SECTION_CREATE2, T_SECTION_READ2, T_PARAGRAPH_MUTATION2, T_SECTION_MUTATION2, T_SECTION_SETTINGS_MUTATION2, FORMAT_INLINE_ALIAS_OPERATION_DEFINITIONS2, OPERATION_DEFINITIONS2, OPERATION_IDS2, COMMAND_CATALOG3, PARAGRAPH_ALIGNMENTS2, TAB_STOP_ALIGNMENTS2, TAB_STOP_LEADERS2, BORDER_SIDES2, CLEAR_BORDER_SIDES2, LINE_RULES2, PARAGRAPH_BLOCK_TYPES2, SET_STYLE_KEYS2, CLEAR_STYLE_KEYS2, RESET_DIRECT_FORMATTING_KEYS2, SET_ALIGNMENT_KEYS2, CLEAR_ALIGNMENT_KEYS2, SET_INDENTATION_KEYS2, CLEAR_INDENTATION_KEYS2, SET_SPACING_KEYS2, CLEAR_SPACING_KEYS2, SET_KEEP_OPTIONS_KEYS2, SET_OUTLINE_LEVEL_KEYS2, SET_FLOW_OPTIONS_KEYS2, SET_TAB_STOP_KEYS2, CLEAR_TAB_STOP_KEYS2, CLEAR_ALL_TAB_STOPS_KEYS2, SET_BORDER_KEYS2, CLEAR_BORDER_KEYS2, SET_SHADING_KEYS2, CLEAR_SHADING_KEYS2, ST_ON_OFF_ON_VALUES2, ST_ON_OFF_OFF_VALUES2, ST_UNDERLINE_VALUES2, ST_UNDERLINE_VALUE_SET2, ST_VERTICAL_ALIGN_RUN2, ST_EM2, ST_TEXT_ALIGNMENT2, ST_TEXT_DIRECTION2, ST_TEXTBOX_TIGHT_WRAP2, ST_TEXT_TRANSFORM2, ST_JUSTIFICATION2, FONT_FAMILY_SCHEMA2, COLOR_SCHEMA2, SPACING_SCHEMA2, INDENT_SCHEMA2, UNDERLINE_SCHEMA2, BORDER_PROPERTIES_SCHEMA2, SHADING_SCHEMA2, LANG_SCHEMA2, EAST_ASIAN_LAYOUT_SCHEMA2, FIT_TEXT_SCHEMA2, NUMBERING_PROPERTIES_SCHEMA2, FRAME_PR_SCHEMA2, PARAGRAPH_BORDERS_SCHEMA2, TAB_STOP_SCHEMA2, PROPERTY_REGISTRY3, ALLOWED_KEYS_BY_CHANNEL2, PROPERTY_INDEX2, EXCLUDED_KEYS2, INPUT_ALLOWED_KEYS2, TARGET_ALLOWED_KEYS2, OPTIONS_ALLOWED_KEYS2, VALID_CHANNELS2, Z_ORDER_RELATIVE_HEIGHT_MAX2 = 4294967295, nodeTypeValues2, blockNodeTypeValues2, deletableBlockNodeTypeValues2, inlineNodeTypeValues2, rangeSchema2, textAddressSchema2, textTargetSchema2, blockNodeAddressSchema2, deletableBlockNodeAddressSchema2, paragraphAddressSchema2, headingAddressSchema2, listItemAddressSchema2, paragraphTargetSchema2, sectionAddressSchema2, nodeAddressSchema2, commentAddressSchema2, trackedChangeAddressSchema2, entityAddressSchema2, resolvedHandleSchema2, pageInfoSchema2, receiptSuccessSchema2, textMutationResolutionSchema2, textMutationSuccessSchema2, matchBlockSchema2, trackChangeRefSchema2, createParagraphSuccessSchema2, createHeadingSuccessSchema2, headingLevelSchema2, listsInsertSuccessSchema2, listsMutateItemSuccessSchema2, nodeSummarySchema2, nodeInfoSchema2, matchContextSchema2, unknownNodeDiagnosticSchema2, textSelectorSchema2, nodeSelectorSchema2, findItemDomainSchema2, documentInfoCountsSchema2, documentInfoOutlineItemSchema2, documentInfoCapabilitiesSchema2, listKindSchema2, listInsertPositionSchema2, sectionBreakTypeSchema2, sectionOrientationSchema2, sectionVerticalAlignSchema2, sectionDirectionSchema2, sectionHeaderFooterKindSchema2, sectionHeaderFooterVariantSchema2, sectionLineNumberRestartSchema2, sectionPageNumberFormatSchema2, sectionRangeDomainSchema2, sectionPageMarginsSchema2, sectionHeaderFooterMarginsSchema2, sectionPageSetupSchema2, sectionColumnsSchema2, sectionLineNumberingSchema2, sectionPageNumberingSchema2, sectionHeaderFooterRefsSchema2, sectionBorderSpecSchema2, sectionPageBordersSchema2, sectionMutationSuccessSchema2, documentMutationSuccessSchema2, paragraphMutationTargetSchema2, paragraphMutationSuccessSchema2, createSectionBreakSuccessSchema2, capabilityReasonsSchema2, capabilityFlagSchema2, operationRuntimeCapabilitySchema2, operationCapabilitiesSchema2, inlinePropertyCapabilitySchema2, formatCapabilitiesSchema2, planEngineCapabilitiesSchema2, tableCreateLocationSchema2, formatInlineAliasOperationSchemas2, tocMutationFailureSchema2, tocMutationSuccessSchema2, tocEntryMutationFailureSchema2, tocEntryMutationSuccessSchema2, hyperlinkTargetSchema2, hyperlinkReadPropertiesSchema2, hyperlinkSpecSchema2, hyperlinkPatchSchema2, hyperlinkDomainSchema2, hyperlinkMutationSuccessSchema2, hyperlinkMutationFailureSchema2, GROUP_METADATA2, STEP_OP_CATALOG_UNFROZEN2, PUBLIC_STEP_OP_CATALOG_UNFROZEN2, PUBLIC_MUTATION_STEP_OP_IDS2, PUBLIC_MUTATION_STEP_OP_SET2, CAPABILITY_REASON_CODES2, CREATE_COMMENT_ALLOWED_KEYS2, PATCH_COMMENT_ALLOWED_KEYS2, STYLE_APPLY_INPUT_ALLOWED_KEYS2, INLINE_ALIAS_INPUT_ALLOWED_KEYS2, DELETE_INPUT_ALLOWED_KEYS2, INSERT_INPUT_ALLOWED_KEYS2, VALID_INSERT_TYPES2, REPLACE_INPUT_ALLOWED_KEYS2, SECTION_BREAK_TYPES$1, SUPPORTED_DELETE_NODE_TYPES2, REJECTED_DELETE_NODE_TYPES2, TABLE_LOCATOR_OPS2, ROW_LOCATOR_OPS2, COLUMN_LOCATOR_OPS2, MERGE_RANGE_LOCATOR_OPS2, DEFAULT_SECTIONS_LIST_LIMIT2 = 250, SECTION_BREAK_TYPES3, SECTION_ORIENTATIONS2, SECTION_VERTICAL_ALIGNS2, SECTION_DIRECTIONS2, HEADER_FOOTER_KINDS2, HEADER_FOOTER_VARIANTS2, LINE_NUMBER_RESTARTS2, PAGE_NUMBER_FORMATS2, PAGE_BORDER_DISPLAYS2, PAGE_BORDER_OFFSET_FROM_VALUES2, PAGE_BORDER_Z_ORDER_VALUES2, VALID_WRAP_TYPES2, VALID_WRAP_SIDES2, VALID_IMAGE_SIZE_UNITS2, PATCH_FIELDS2, _buffers, _defaultCollectionId = null, _nextCollectionId = 1, generateV2HandlerEntity = (handlerName, translator$208) => ({
|
|
52459
52904
|
handlerName,
|
|
52460
52905
|
handler: (params) => {
|
|
52461
52906
|
const { nodes } = params;
|
|
@@ -63844,7 +64289,7 @@ var isRegExp = (value) => {
|
|
|
63844
64289
|
state.kern = kernNode.attributes["w:val"];
|
|
63845
64290
|
}
|
|
63846
64291
|
}, SuperConverter;
|
|
63847
|
-
var
|
|
64292
|
+
var init_SuperConverter_C3jSWLmj_es = __esm(() => {
|
|
63848
64293
|
init_rolldown_runtime_B2q5OVn9_es();
|
|
63849
64294
|
init_jszip_ChlR43oI_es();
|
|
63850
64295
|
init_xml_js_DLE8mr0n_es();
|
|
@@ -69267,6 +69712,107 @@ var init_SuperConverter_JDAVdLpj_es = __esm(() => {
|
|
|
69267
69712
|
}),
|
|
69268
69713
|
referenceDocPath: "images/set-z-order.mdx",
|
|
69269
69714
|
referenceGroup: "images"
|
|
69715
|
+
},
|
|
69716
|
+
"hyperlinks.list": {
|
|
69717
|
+
memberPath: "hyperlinks.list",
|
|
69718
|
+
description: "List all hyperlinks in the document, with optional filtering by href, anchor, or display text.",
|
|
69719
|
+
expectedResult: "Returns a HyperlinksListResult with an array of hyperlink discovery items and pagination metadata.",
|
|
69720
|
+
requiresDocumentContext: true,
|
|
69721
|
+
metadata: readOperation2({ idempotency: "idempotent" }),
|
|
69722
|
+
referenceDocPath: "hyperlinks/list.mdx",
|
|
69723
|
+
referenceGroup: "hyperlinks"
|
|
69724
|
+
},
|
|
69725
|
+
"hyperlinks.get": {
|
|
69726
|
+
memberPath: "hyperlinks.get",
|
|
69727
|
+
description: "Retrieve details of a specific hyperlink by its inline address.",
|
|
69728
|
+
expectedResult: "Returns a HyperlinkInfo object with the address, destination properties, and display text.",
|
|
69729
|
+
requiresDocumentContext: true,
|
|
69730
|
+
metadata: readOperation2({
|
|
69731
|
+
idempotency: "idempotent",
|
|
69732
|
+
throws: ["TARGET_NOT_FOUND", "INVALID_TARGET"]
|
|
69733
|
+
}),
|
|
69734
|
+
referenceDocPath: "hyperlinks/get.mdx",
|
|
69735
|
+
referenceGroup: "hyperlinks"
|
|
69736
|
+
},
|
|
69737
|
+
"hyperlinks.wrap": {
|
|
69738
|
+
memberPath: "hyperlinks.wrap",
|
|
69739
|
+
description: "Wrap an existing text range with a hyperlink.",
|
|
69740
|
+
expectedResult: "Returns a HyperlinkMutationResult with the created hyperlink address on success, or a failure code on no-op.",
|
|
69741
|
+
requiresDocumentContext: true,
|
|
69742
|
+
metadata: mutationOperation2({
|
|
69743
|
+
idempotency: "conditional",
|
|
69744
|
+
supportsDryRun: true,
|
|
69745
|
+
supportsTrackedMode: false,
|
|
69746
|
+
deterministicTargetResolution: true,
|
|
69747
|
+
possibleFailureCodes: ["NO_OP"],
|
|
69748
|
+
throws: [
|
|
69749
|
+
...T_NOT_FOUND_CAPABLE2,
|
|
69750
|
+
"INVALID_TARGET",
|
|
69751
|
+
"INVALID_INPUT"
|
|
69752
|
+
]
|
|
69753
|
+
}),
|
|
69754
|
+
referenceDocPath: "hyperlinks/wrap.mdx",
|
|
69755
|
+
referenceGroup: "hyperlinks"
|
|
69756
|
+
},
|
|
69757
|
+
"hyperlinks.insert": {
|
|
69758
|
+
memberPath: "hyperlinks.insert",
|
|
69759
|
+
description: "Insert new linked text at a target position.",
|
|
69760
|
+
expectedResult: "Returns a HyperlinkMutationResult with the created hyperlink address on success, or a failure code.",
|
|
69761
|
+
requiresDocumentContext: true,
|
|
69762
|
+
metadata: mutationOperation2({
|
|
69763
|
+
idempotency: "non-idempotent",
|
|
69764
|
+
supportsDryRun: true,
|
|
69765
|
+
supportsTrackedMode: false,
|
|
69766
|
+
deterministicTargetResolution: true,
|
|
69767
|
+
possibleFailureCodes: ["NO_OP", "INVALID_TARGET"],
|
|
69768
|
+
throws: [
|
|
69769
|
+
...T_NOT_FOUND_CAPABLE2,
|
|
69770
|
+
"INVALID_TARGET",
|
|
69771
|
+
"INVALID_INPUT"
|
|
69772
|
+
]
|
|
69773
|
+
}),
|
|
69774
|
+
referenceDocPath: "hyperlinks/insert.mdx",
|
|
69775
|
+
referenceGroup: "hyperlinks"
|
|
69776
|
+
},
|
|
69777
|
+
"hyperlinks.patch": {
|
|
69778
|
+
memberPath: "hyperlinks.patch",
|
|
69779
|
+
description: "Update hyperlink metadata (destination, tooltip, target, rel) without changing display text.",
|
|
69780
|
+
expectedResult: "Returns a HyperlinkMutationResult with the updated hyperlink address on success, or NO_OP if unchanged.",
|
|
69781
|
+
requiresDocumentContext: true,
|
|
69782
|
+
metadata: mutationOperation2({
|
|
69783
|
+
idempotency: "conditional",
|
|
69784
|
+
supportsDryRun: true,
|
|
69785
|
+
supportsTrackedMode: false,
|
|
69786
|
+
deterministicTargetResolution: true,
|
|
69787
|
+
possibleFailureCodes: ["NO_OP"],
|
|
69788
|
+
throws: [
|
|
69789
|
+
...T_NOT_FOUND_CAPABLE2,
|
|
69790
|
+
"INVALID_TARGET",
|
|
69791
|
+
"INVALID_INPUT"
|
|
69792
|
+
]
|
|
69793
|
+
}),
|
|
69794
|
+
referenceDocPath: "hyperlinks/patch.mdx",
|
|
69795
|
+
referenceGroup: "hyperlinks"
|
|
69796
|
+
},
|
|
69797
|
+
"hyperlinks.remove": {
|
|
69798
|
+
memberPath: "hyperlinks.remove",
|
|
69799
|
+
description: "Remove a hyperlink. Mode 'unwrap' preserves display text; 'deleteText' removes the linked content entirely.",
|
|
69800
|
+
expectedResult: "Returns a HyperlinkMutationResult with the removed hyperlink address on success, or a failure code on no-op.",
|
|
69801
|
+
requiresDocumentContext: true,
|
|
69802
|
+
metadata: mutationOperation2({
|
|
69803
|
+
idempotency: "conditional",
|
|
69804
|
+
supportsDryRun: true,
|
|
69805
|
+
supportsTrackedMode: false,
|
|
69806
|
+
deterministicTargetResolution: true,
|
|
69807
|
+
possibleFailureCodes: ["NO_OP"],
|
|
69808
|
+
throws: [
|
|
69809
|
+
...T_NOT_FOUND_CAPABLE2,
|
|
69810
|
+
"INVALID_TARGET",
|
|
69811
|
+
"INVALID_INPUT"
|
|
69812
|
+
]
|
|
69813
|
+
}),
|
|
69814
|
+
referenceDocPath: "hyperlinks/remove.mdx",
|
|
69815
|
+
referenceGroup: "hyperlinks"
|
|
69270
69816
|
}
|
|
69271
69817
|
};
|
|
69272
69818
|
OPERATION_IDS2 = Object.freeze(Object.keys(OPERATION_DEFINITIONS2));
|
|
@@ -71065,6 +71611,68 @@ var init_SuperConverter_JDAVdLpj_es = __esm(() => {
|
|
|
71065
71611
|
success: { const: true },
|
|
71066
71612
|
entry: tocEntryAddressSchema2()
|
|
71067
71613
|
}, ["success", "entry"]);
|
|
71614
|
+
hyperlinkTargetSchema2 = objectSchema2({
|
|
71615
|
+
kind: { const: "inline" },
|
|
71616
|
+
nodeType: { const: "hyperlink" },
|
|
71617
|
+
anchor: ref2("InlineAnchor")
|
|
71618
|
+
}, [
|
|
71619
|
+
"kind",
|
|
71620
|
+
"nodeType",
|
|
71621
|
+
"anchor"
|
|
71622
|
+
]);
|
|
71623
|
+
hyperlinkReadPropertiesSchema2 = objectSchema2({
|
|
71624
|
+
href: { type: "string" },
|
|
71625
|
+
anchor: { type: "string" },
|
|
71626
|
+
docLocation: { type: "string" },
|
|
71627
|
+
tooltip: { type: "string" },
|
|
71628
|
+
target: { type: "string" },
|
|
71629
|
+
rel: { type: "string" }
|
|
71630
|
+
});
|
|
71631
|
+
hyperlinkSpecSchema2 = objectSchema2({
|
|
71632
|
+
destination: objectSchema2({
|
|
71633
|
+
href: { type: "string" },
|
|
71634
|
+
anchor: { type: "string" },
|
|
71635
|
+
docLocation: { type: "string" }
|
|
71636
|
+
}),
|
|
71637
|
+
tooltip: { type: "string" },
|
|
71638
|
+
target: { type: "string" },
|
|
71639
|
+
rel: { type: "string" }
|
|
71640
|
+
}, ["destination"]);
|
|
71641
|
+
hyperlinkPatchSchema2 = objectSchema2({
|
|
71642
|
+
href: { oneOf: [{ type: "string" }, { type: "null" }] },
|
|
71643
|
+
anchor: { oneOf: [{ type: "string" }, { type: "null" }] },
|
|
71644
|
+
docLocation: { oneOf: [{ type: "string" }, { type: "null" }] },
|
|
71645
|
+
tooltip: { oneOf: [{ type: "string" }, { type: "null" }] },
|
|
71646
|
+
target: { oneOf: [{ type: "string" }, { type: "null" }] },
|
|
71647
|
+
rel: { oneOf: [{ type: "string" }, { type: "null" }] }
|
|
71648
|
+
});
|
|
71649
|
+
hyperlinkDomainSchema2 = objectSchema2({
|
|
71650
|
+
address: hyperlinkTargetSchema2,
|
|
71651
|
+
properties: hyperlinkReadPropertiesSchema2,
|
|
71652
|
+
text: { type: "string" }
|
|
71653
|
+
}, ["address", "properties"]);
|
|
71654
|
+
hyperlinkMutationSuccessSchema2 = objectSchema2({
|
|
71655
|
+
success: { const: true },
|
|
71656
|
+
hyperlink: hyperlinkTargetSchema2
|
|
71657
|
+
}, ["success", "hyperlink"]);
|
|
71658
|
+
hyperlinkMutationFailureSchema2 = objectSchema2({
|
|
71659
|
+
success: { const: false },
|
|
71660
|
+
failure: objectSchema2({
|
|
71661
|
+
code: { enum: [...[
|
|
71662
|
+
"NO_OP",
|
|
71663
|
+
"INVALID_TARGET",
|
|
71664
|
+
"TARGET_NOT_FOUND",
|
|
71665
|
+
"CAPABILITY_UNAVAILABLE"
|
|
71666
|
+
]] },
|
|
71667
|
+
message: { type: "string" },
|
|
71668
|
+
details: { type: "object" }
|
|
71669
|
+
}, ["code", "message"])
|
|
71670
|
+
}, ["success", "failure"]);
|
|
71671
|
+
objectSchema2({
|
|
71672
|
+
address: hyperlinkTargetSchema2,
|
|
71673
|
+
properties: hyperlinkReadPropertiesSchema2,
|
|
71674
|
+
text: { type: "string" }
|
|
71675
|
+
}, ["address", "properties"]);
|
|
71068
71676
|
objectSchema2({
|
|
71069
71677
|
nodeId: { type: "string" },
|
|
71070
71678
|
nodeType: { enum: [...blockNodeTypeValues2] }
|
|
@@ -73008,7 +73616,27 @@ var init_SuperConverter_JDAVdLpj_es = __esm(() => {
|
|
|
73008
73616
|
code: { type: "string" },
|
|
73009
73617
|
message: { type: "string" }
|
|
73010
73618
|
}, ["code", "message"])
|
|
73011
|
-
}, ["success", "failure"])
|
|
73619
|
+
}, ["success", "failure"]), objectSchema2({
|
|
73620
|
+
within: nodeAddressSchema2,
|
|
73621
|
+
hrefPattern: { type: "string" },
|
|
73622
|
+
anchor: { type: "string" },
|
|
73623
|
+
textPattern: { type: "string" },
|
|
73624
|
+
limit: { type: "integer" },
|
|
73625
|
+
offset: { type: "integer" }
|
|
73626
|
+
}), discoveryResultSchema2(hyperlinkDomainSchema2), objectSchema2({ target: hyperlinkTargetSchema2 }, ["target"]), objectSchema2({
|
|
73627
|
+
target: textAddressSchema2,
|
|
73628
|
+
link: hyperlinkSpecSchema2
|
|
73629
|
+
}, ["target", "link"]), hyperlinkMutationResultSchema2(), objectSchema2({
|
|
73630
|
+
target: textAddressSchema2,
|
|
73631
|
+
text: { type: "string" },
|
|
73632
|
+
link: hyperlinkSpecSchema2
|
|
73633
|
+
}, ["text", "link"]), hyperlinkMutationResultSchema2(), objectSchema2({
|
|
73634
|
+
target: hyperlinkTargetSchema2,
|
|
73635
|
+
patch: hyperlinkPatchSchema2
|
|
73636
|
+
}, ["target", "patch"]), hyperlinkMutationResultSchema2(), objectSchema2({
|
|
73637
|
+
target: hyperlinkTargetSchema2,
|
|
73638
|
+
mode: { enum: ["unwrap", "deleteText"] }
|
|
73639
|
+
}, ["target"]), hyperlinkMutationResultSchema2();
|
|
73012
73640
|
projectFromDefinitions2((_id, entry) => entry.memberPath);
|
|
73013
73641
|
[...new Set(OPERATION_IDS2.map((id) => OPERATION_DEFINITIONS2[id].memberPath))];
|
|
73014
73642
|
projectFromDefinitions2((_id, entry) => entry.referenceDocPath);
|
|
@@ -73102,6 +73730,11 @@ var init_SuperConverter_JDAVdLpj_es = __esm(() => {
|
|
|
73102
73730
|
title: "Images",
|
|
73103
73731
|
description: "Image lifecycle, placement, and wrap configuration.",
|
|
73104
73732
|
pagePath: "images/index.mdx"
|
|
73733
|
+
},
|
|
73734
|
+
hyperlinks: {
|
|
73735
|
+
title: "Hyperlinks",
|
|
73736
|
+
description: "Hyperlink discovery, creation, and metadata management.",
|
|
73737
|
+
pagePath: "hyperlinks/index.mdx"
|
|
73105
73738
|
}
|
|
73106
73739
|
};
|
|
73107
73740
|
Object.keys(GROUP_METADATA2).map((key) => ({
|
|
@@ -73310,6 +73943,14 @@ var init_SuperConverter_JDAVdLpj_es = __esm(() => {
|
|
|
73310
73943
|
"pt",
|
|
73311
73944
|
"twip"
|
|
73312
73945
|
]);
|
|
73946
|
+
PATCH_FIELDS2 = new Set([
|
|
73947
|
+
"href",
|
|
73948
|
+
"anchor",
|
|
73949
|
+
"docLocation",
|
|
73950
|
+
"tooltip",
|
|
73951
|
+
"target",
|
|
73952
|
+
"rel"
|
|
73953
|
+
]);
|
|
73313
73954
|
_buffers = /* @__PURE__ */ new Map;
|
|
73314
73955
|
translator$35 = NodeTranslator.from(createStrictTogglePropertyHandler("w:b", "bold"));
|
|
73315
73956
|
translator$39 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:bCs", "boldCs"));
|
|
@@ -120117,9 +120758,9 @@ var init_remark_gfm_CjV8kaUy_es = __esm(() => {
|
|
|
120117
120758
|
init_remark_gfm_z_sDF4ss_es();
|
|
120118
120759
|
});
|
|
120119
120760
|
|
|
120120
|
-
// ../../packages/superdoc/dist/chunks/src-
|
|
120121
|
-
var
|
|
120122
|
-
__export(
|
|
120761
|
+
// ../../packages/superdoc/dist/chunks/src-nq0HTKfv.es.js
|
|
120762
|
+
var exports_src_nq0HTKfv_es = {};
|
|
120763
|
+
__export(exports_src_nq0HTKfv_es, {
|
|
120123
120764
|
zt: () => defineMark,
|
|
120124
120765
|
z: () => cM,
|
|
120125
120766
|
yt: () => removeAwarenessStates,
|
|
@@ -133996,7 +134637,7 @@ function listItemProjectionToInfo(projection, listId) {
|
|
|
133996
134637
|
text: projection.text
|
|
133997
134638
|
};
|
|
133998
134639
|
}
|
|
133999
|
-
function matchesListQuery(projection, query2) {
|
|
134640
|
+
function matchesListQuery$1(projection, query2) {
|
|
134000
134641
|
if (!query2)
|
|
134001
134642
|
return true;
|
|
134002
134643
|
if (query2.kind && projection.kind !== query2.kind)
|
|
@@ -134043,7 +134684,7 @@ function listListItems(editor, query2) {
|
|
|
134043
134684
|
let total = 0;
|
|
134044
134685
|
const items = [];
|
|
134045
134686
|
for (const projection of projections) {
|
|
134046
|
-
if (!matchesListQuery(projection, query2))
|
|
134687
|
+
if (!matchesListQuery$1(projection, query2))
|
|
134047
134688
|
continue;
|
|
134048
134689
|
const currentIndex = total;
|
|
134049
134690
|
total += 1;
|
|
@@ -141398,7 +142039,7 @@ function dispatchEditorTransaction(editor, tr) {
|
|
|
141398
142039
|
}
|
|
141399
142040
|
throw new Error("No transaction dispatcher available.");
|
|
141400
142041
|
}
|
|
141401
|
-
function receiptApplied$
|
|
142042
|
+
function receiptApplied$2(receipt2) {
|
|
141402
142043
|
return receipt2.steps[0]?.effect === "changed";
|
|
141403
142044
|
}
|
|
141404
142045
|
function isTocContentUnchanged(existingNode, newContent) {
|
|
@@ -141493,7 +142134,7 @@ function tocConfigureWrapper(editor, input2, options) {
|
|
|
141493
142134
|
const shouldRefreshContent = !isTocContentUnchanged(resolved.node, nextContent);
|
|
141494
142135
|
const command$1 = editor.commands?.setTableOfContentsInstructionById;
|
|
141495
142136
|
const commandNodeId = resolved.commandNodeId ?? resolved.nodeId;
|
|
141496
|
-
if (!receiptApplied$
|
|
142137
|
+
if (!receiptApplied$2(typeof command$1 === "function" ? runTocCommand(editor, command$1, {
|
|
141497
142138
|
sdBlockId: commandNodeId,
|
|
141498
142139
|
instruction,
|
|
141499
142140
|
...shouldRefreshContent ? { content: nextContent } : {},
|
|
@@ -141536,7 +142177,7 @@ function tocUpdateAll(editor, input2, options) {
|
|
|
141536
142177
|
if (options?.dryRun)
|
|
141537
142178
|
return tocSuccess(resolved.nodeId);
|
|
141538
142179
|
const command$1 = editor.commands?.replaceTableOfContentsContentById;
|
|
141539
|
-
return receiptApplied$
|
|
142180
|
+
return receiptApplied$2(typeof command$1 === "function" ? runTocCommand(editor, command$1, {
|
|
141540
142181
|
sdBlockId: resolved.commandNodeId ?? resolved.nodeId,
|
|
141541
142182
|
content: content3
|
|
141542
142183
|
}, options?.expectedRevision) : runTocAction(editor, () => {
|
|
@@ -141579,7 +142220,7 @@ function tocUpdatePageNumbers(editor, input2, options) {
|
|
|
141579
142220
|
if (options?.dryRun)
|
|
141580
142221
|
return tocSuccess(resolved.nodeId);
|
|
141581
142222
|
const command$1 = editor.commands?.replaceTableOfContentsContentById;
|
|
141582
|
-
return receiptApplied$
|
|
142223
|
+
return receiptApplied$2(typeof command$1 === "function" ? runTocCommand(editor, command$1, {
|
|
141583
142224
|
sdBlockId: resolved.commandNodeId ?? resolved.nodeId,
|
|
141584
142225
|
content: updatedContent
|
|
141585
142226
|
}, options?.expectedRevision) : runTocAction(editor, () => {
|
|
@@ -141646,7 +142287,7 @@ function tocRemoveWrapper(editor, input2, options) {
|
|
|
141646
142287
|
if (options?.dryRun)
|
|
141647
142288
|
return tocSuccess(resolved.nodeId);
|
|
141648
142289
|
const command$1 = editor.commands?.deleteTableOfContentsById;
|
|
141649
|
-
return receiptApplied$
|
|
142290
|
+
return receiptApplied$2(typeof command$1 === "function" ? runTocCommand(editor, command$1, { sdBlockId: resolved.commandNodeId ?? resolved.nodeId }, options?.expectedRevision) : runTocAction(editor, () => {
|
|
141650
142291
|
try {
|
|
141651
142292
|
const { tr } = editor.state;
|
|
141652
142293
|
tr.delete(resolved.pos, resolved.pos + resolved.node.nodeSize);
|
|
@@ -141677,7 +142318,7 @@ function createTableOfContentsWrapper(editor, input2, options) {
|
|
|
141677
142318
|
toc: buildTocAddress("(dry-run)")
|
|
141678
142319
|
};
|
|
141679
142320
|
const command$1 = editor.commands?.insertTableOfContentsAt;
|
|
141680
|
-
if (!receiptApplied$
|
|
142321
|
+
if (!receiptApplied$2(typeof command$1 === "function" ? runTocCommand(editor, command$1, {
|
|
141681
142322
|
pos,
|
|
141682
142323
|
instruction,
|
|
141683
142324
|
sdBlockId,
|
|
@@ -141872,7 +142513,7 @@ function runEntryCommand(editor, command$1, args$1, expectedRevision) {
|
|
|
141872
142513
|
const executeCommand = toEntryEditorCommand(command$1);
|
|
141873
142514
|
return runEntryAction(editor, () => executeCommand(args$1), expectedRevision);
|
|
141874
142515
|
}
|
|
141875
|
-
function receiptApplied(receipt2) {
|
|
142516
|
+
function receiptApplied$1(receipt2) {
|
|
141876
142517
|
return receipt2.steps[0]?.effect === "changed";
|
|
141877
142518
|
}
|
|
141878
142519
|
function tocListEntriesWrapper(editor, query2) {
|
|
@@ -141919,7 +142560,7 @@ function tocMarkEntryWrapper(editor, input2, options) {
|
|
|
141919
142560
|
const pos = (input2.target.position ?? "end") === "start" ? paragraph2.pos + 1 : paragraph2.pos + paragraph2.node.nodeSize - 1;
|
|
141920
142561
|
if (options?.dryRun)
|
|
141921
142562
|
return entrySuccess("(dry-run)");
|
|
141922
|
-
if (!receiptApplied(runEntryCommand(editor, command$1, {
|
|
142563
|
+
if (!receiptApplied$1(runEntryCommand(editor, command$1, {
|
|
141923
142564
|
pos,
|
|
141924
142565
|
instruction
|
|
141925
142566
|
}, options?.expectedRevision)))
|
|
@@ -141941,7 +142582,7 @@ function tocUnmarkEntryWrapper(editor, input2, options) {
|
|
|
141941
142582
|
const resolved = resolveTcEntryTarget(editor.state.doc, input2.target);
|
|
141942
142583
|
if (options?.dryRun)
|
|
141943
142584
|
return entrySuccess(resolved.nodeId);
|
|
141944
|
-
return receiptApplied(runEntryCommand(editor, command$1, { pos: resolved.pos }, options?.expectedRevision)) ? entrySuccess(resolved.nodeId) : entryFailure("NO_OP", "TC entry removal produced no change.");
|
|
142585
|
+
return receiptApplied$1(runEntryCommand(editor, command$1, { pos: resolved.pos }, options?.expectedRevision)) ? entrySuccess(resolved.nodeId) : entryFailure("NO_OP", "TC entry removal produced no change.");
|
|
141945
142586
|
}
|
|
141946
142587
|
function tocEditEntryWrapper(editor, input2, options) {
|
|
141947
142588
|
rejectTrackedMode("toc.editEntry", options);
|
|
@@ -141954,7 +142595,7 @@ function tocEditEntryWrapper(editor, input2, options) {
|
|
|
141954
142595
|
return entryFailure("NO_OP", "Edit patch produced no change.");
|
|
141955
142596
|
if (options?.dryRun)
|
|
141956
142597
|
return entrySuccess(resolved.nodeId);
|
|
141957
|
-
if (!receiptApplied(runEntryCommand(editor, command$1, {
|
|
142598
|
+
if (!receiptApplied$1(runEntryCommand(editor, command$1, {
|
|
141958
142599
|
pos: resolved.pos,
|
|
141959
142600
|
instruction: serializeTcInstruction(patched)
|
|
141960
142601
|
}, options?.expectedRevision)))
|
|
@@ -142624,6 +143265,497 @@ function imagesSetZOrderWrapper(editor, input2, options) {
|
|
|
142624
143265
|
return buildNoOpResult("Set z-order produced no change.");
|
|
142625
143266
|
return buildSuccessResult(findImageById(editor, input2.imageId));
|
|
142626
143267
|
}
|
|
143268
|
+
function getLinkMarkType(editor) {
|
|
143269
|
+
const markType = editor.schema.marks.link;
|
|
143270
|
+
if (!markType)
|
|
143271
|
+
throw new Error("Link mark type is not defined in the editor schema.");
|
|
143272
|
+
return markType;
|
|
143273
|
+
}
|
|
143274
|
+
function dispatchTransaction(editor, tr) {
|
|
143275
|
+
editor.dispatch(tr);
|
|
143276
|
+
}
|
|
143277
|
+
function dispatchIfChanged(editor, tr) {
|
|
143278
|
+
if (!tr.docChanged)
|
|
143279
|
+
return false;
|
|
143280
|
+
dispatchTransaction(editor, tr);
|
|
143281
|
+
return true;
|
|
143282
|
+
}
|
|
143283
|
+
function createRelationshipId(editor, href) {
|
|
143284
|
+
if (editor.options.mode !== "docx")
|
|
143285
|
+
return null;
|
|
143286
|
+
try {
|
|
143287
|
+
return insertNewRelationship(href, "hyperlink", editor);
|
|
143288
|
+
} catch {
|
|
143289
|
+
return null;
|
|
143290
|
+
}
|
|
143291
|
+
}
|
|
143292
|
+
function sanitizeHrefOrThrow(href) {
|
|
143293
|
+
const result = sanitizeHref(href);
|
|
143294
|
+
if (!result)
|
|
143295
|
+
throw Object.assign(/* @__PURE__ */ new Error(`Blocked or invalid href: "${href}"`), { code: "INVALID_INPUT" });
|
|
143296
|
+
return result.href;
|
|
143297
|
+
}
|
|
143298
|
+
function buildMarkAttrs(editor, spec) {
|
|
143299
|
+
const attrs = {};
|
|
143300
|
+
if (spec.href) {
|
|
143301
|
+
attrs.href = sanitizeHrefOrThrow(spec.href);
|
|
143302
|
+
attrs.rId = createRelationshipId(editor, attrs.href);
|
|
143303
|
+
}
|
|
143304
|
+
if (spec.anchor) {
|
|
143305
|
+
attrs.anchor = spec.anchor;
|
|
143306
|
+
if (!spec.href)
|
|
143307
|
+
attrs.href = `#${spec.anchor}`;
|
|
143308
|
+
}
|
|
143309
|
+
if (spec.docLocation)
|
|
143310
|
+
attrs.docLocation = spec.docLocation;
|
|
143311
|
+
if (spec.tooltip)
|
|
143312
|
+
attrs.tooltip = spec.tooltip;
|
|
143313
|
+
if (spec.target)
|
|
143314
|
+
attrs.target = spec.target;
|
|
143315
|
+
if (spec.rel)
|
|
143316
|
+
attrs.rel = spec.rel;
|
|
143317
|
+
return attrs;
|
|
143318
|
+
}
|
|
143319
|
+
function wrapWithLink(editor, from$12, to, spec) {
|
|
143320
|
+
const linkMarkType = getLinkMarkType(editor);
|
|
143321
|
+
const attrs = buildMarkAttrs(editor, spec);
|
|
143322
|
+
const tr = editor.state.tr;
|
|
143323
|
+
tr.addMark(from$12, to, linkMarkType.create(attrs));
|
|
143324
|
+
applyDirectMutationMeta(tr);
|
|
143325
|
+
dispatchTransaction(editor, tr);
|
|
143326
|
+
return true;
|
|
143327
|
+
}
|
|
143328
|
+
function insertLinkedText(editor, pos, text5, spec) {
|
|
143329
|
+
const linkMarkType = getLinkMarkType(editor);
|
|
143330
|
+
const attrs = buildMarkAttrs(editor, spec);
|
|
143331
|
+
const tr = editor.state.tr;
|
|
143332
|
+
const mark2 = linkMarkType.create(attrs);
|
|
143333
|
+
tr.insertText(text5, pos);
|
|
143334
|
+
tr.addMark(pos, pos + text5.length, mark2);
|
|
143335
|
+
applyDirectMutationMeta(tr);
|
|
143336
|
+
dispatchTransaction(editor, tr);
|
|
143337
|
+
return true;
|
|
143338
|
+
}
|
|
143339
|
+
function patchLinkMark(editor, from$12, to, existingMark, patch3) {
|
|
143340
|
+
const linkMarkType = getLinkMarkType(editor);
|
|
143341
|
+
const merged = { ...existingMark.attrs };
|
|
143342
|
+
for (const [key$1, value] of Object.entries(patch3)) {
|
|
143343
|
+
if (value === undefined)
|
|
143344
|
+
continue;
|
|
143345
|
+
if (value === null)
|
|
143346
|
+
merged[key$1] = null;
|
|
143347
|
+
else
|
|
143348
|
+
merged[key$1] = value;
|
|
143349
|
+
}
|
|
143350
|
+
if (typeof patch3.href === "string") {
|
|
143351
|
+
merged.href = sanitizeHrefOrThrow(patch3.href);
|
|
143352
|
+
merged.rId = createRelationshipId(editor, merged.href);
|
|
143353
|
+
}
|
|
143354
|
+
if (patch3.href === null && typeof merged.anchor === "string") {
|
|
143355
|
+
merged.href = `#${merged.anchor}`;
|
|
143356
|
+
merged.rId = null;
|
|
143357
|
+
}
|
|
143358
|
+
if (typeof patch3.anchor === "string" && patch3.href === undefined) {
|
|
143359
|
+
const currentHref = merged.href;
|
|
143360
|
+
if (typeof currentHref === "string" && currentHref.startsWith("#"))
|
|
143361
|
+
merged.href = `#${patch3.anchor}`;
|
|
143362
|
+
}
|
|
143363
|
+
if (patch3.anchor === null && typeof merged.href === "string" && !merged.href.startsWith("#"))
|
|
143364
|
+
merged.anchor = null;
|
|
143365
|
+
const tr = editor.state.tr;
|
|
143366
|
+
tr.removeMark(from$12, to, existingMark);
|
|
143367
|
+
tr.addMark(from$12, to, linkMarkType.create(merged));
|
|
143368
|
+
applyDirectMutationMeta(tr);
|
|
143369
|
+
return dispatchIfChanged(editor, tr);
|
|
143370
|
+
}
|
|
143371
|
+
function unwrapLink(editor, from$12, to) {
|
|
143372
|
+
const linkMarkType = getLinkMarkType(editor);
|
|
143373
|
+
const tr = editor.state.tr;
|
|
143374
|
+
tr.removeMark(from$12, to, linkMarkType);
|
|
143375
|
+
applyDirectMutationMeta(tr);
|
|
143376
|
+
return dispatchIfChanged(editor, tr);
|
|
143377
|
+
}
|
|
143378
|
+
function deleteLinkedText(editor, from$12, to) {
|
|
143379
|
+
const tr = editor.state.tr;
|
|
143380
|
+
tr.delete(from$12, to);
|
|
143381
|
+
applyDirectMutationMeta(tr);
|
|
143382
|
+
dispatchTransaction(editor, tr);
|
|
143383
|
+
return true;
|
|
143384
|
+
}
|
|
143385
|
+
function normalizeReadProperties(attrs) {
|
|
143386
|
+
const rawHref = typeof attrs.href === "string" ? attrs.href : undefined;
|
|
143387
|
+
const rawAnchor = typeof attrs.anchor === "string" ? attrs.anchor : undefined;
|
|
143388
|
+
const rawDocLocation = typeof attrs.docLocation === "string" ? attrs.docLocation : undefined;
|
|
143389
|
+
const rawTooltip = typeof attrs.tooltip === "string" ? attrs.tooltip : undefined;
|
|
143390
|
+
const rawTarget = typeof attrs.target === "string" ? attrs.target : undefined;
|
|
143391
|
+
const rawRel = typeof attrs.rel === "string" ? attrs.rel : undefined;
|
|
143392
|
+
const props = {};
|
|
143393
|
+
let effectiveAnchor = rawAnchor;
|
|
143394
|
+
let effectiveHref = rawHref;
|
|
143395
|
+
if (rawHref && rawHref.startsWith("#")) {
|
|
143396
|
+
const fragment = rawHref.slice(1);
|
|
143397
|
+
if (!rawAnchor) {
|
|
143398
|
+
effectiveAnchor = fragment;
|
|
143399
|
+
effectiveHref = undefined;
|
|
143400
|
+
} else if (rawAnchor === fragment)
|
|
143401
|
+
effectiveHref = undefined;
|
|
143402
|
+
}
|
|
143403
|
+
if (effectiveHref)
|
|
143404
|
+
props.href = effectiveHref;
|
|
143405
|
+
if (effectiveAnchor)
|
|
143406
|
+
props.anchor = effectiveAnchor;
|
|
143407
|
+
if (rawDocLocation)
|
|
143408
|
+
props.docLocation = rawDocLocation;
|
|
143409
|
+
if (rawTooltip)
|
|
143410
|
+
props.tooltip = rawTooltip;
|
|
143411
|
+
if (rawTarget)
|
|
143412
|
+
props.target = rawTarget;
|
|
143413
|
+
if (rawRel)
|
|
143414
|
+
props.rel = rawRel;
|
|
143415
|
+
return props;
|
|
143416
|
+
}
|
|
143417
|
+
function candidateToTarget(candidate) {
|
|
143418
|
+
return {
|
|
143419
|
+
kind: "inline",
|
|
143420
|
+
nodeType: "hyperlink",
|
|
143421
|
+
anchor: candidate.anchor
|
|
143422
|
+
};
|
|
143423
|
+
}
|
|
143424
|
+
function candidateToReadProperties(candidate) {
|
|
143425
|
+
return normalizeReadProperties(candidate.mark?.attrs ?? candidate.attrs ?? {});
|
|
143426
|
+
}
|
|
143427
|
+
function extractDisplayText(editor, candidate) {
|
|
143428
|
+
const doc$2 = editor.state.doc;
|
|
143429
|
+
try {
|
|
143430
|
+
return doc$2.textBetween(candidate.pos, candidate.end, "");
|
|
143431
|
+
} catch {
|
|
143432
|
+
return;
|
|
143433
|
+
}
|
|
143434
|
+
}
|
|
143435
|
+
function candidateToDomain(editor, candidate) {
|
|
143436
|
+
return {
|
|
143437
|
+
address: candidateToTarget(candidate),
|
|
143438
|
+
properties: candidateToReadProperties(candidate),
|
|
143439
|
+
text: extractDisplayText(editor, candidate)
|
|
143440
|
+
};
|
|
143441
|
+
}
|
|
143442
|
+
function encodeInlineRef(anchor) {
|
|
143443
|
+
return `${anchor.start.blockId}:${anchor.start.offset}:${anchor.end.offset}`;
|
|
143444
|
+
}
|
|
143445
|
+
function isInsideTocBlock(editor, pos) {
|
|
143446
|
+
const resolved = editor.state.doc.resolve(pos);
|
|
143447
|
+
for (let depth = resolved.depth;depth > 0; depth--)
|
|
143448
|
+
if (resolved.node(depth).type.name === "tableOfContents")
|
|
143449
|
+
return true;
|
|
143450
|
+
return false;
|
|
143451
|
+
}
|
|
143452
|
+
function rejectIfInsideToc(editor, pos, operationName) {
|
|
143453
|
+
if (isInsideTocBlock(editor, pos))
|
|
143454
|
+
throw new DocumentApiAdapterError("INVALID_TARGET", `${operationName}: target is inside a TOC block. TOC content is managed by toc.* operations.`);
|
|
143455
|
+
}
|
|
143456
|
+
function findHyperlinkCandidates(editor) {
|
|
143457
|
+
return findInlineByType(buildInlineIndex(editor, getBlockIndex(editor)), "hyperlink");
|
|
143458
|
+
}
|
|
143459
|
+
function resolveHyperlinkCandidate(editor, target) {
|
|
143460
|
+
const candidate = findInlineByAnchor(buildInlineIndex(editor, getBlockIndex(editor)), target);
|
|
143461
|
+
if (!candidate)
|
|
143462
|
+
throw new DocumentApiAdapterError("TARGET_NOT_FOUND", "Hyperlink target not found in document.", { target });
|
|
143463
|
+
return candidate;
|
|
143464
|
+
}
|
|
143465
|
+
function resolveCandidateTextRange(editor, candidate, operationName) {
|
|
143466
|
+
const start$1 = candidate.anchor.start;
|
|
143467
|
+
const end$1 = candidate.anchor.end;
|
|
143468
|
+
if (start$1.blockId !== end$1.blockId)
|
|
143469
|
+
throw new DocumentApiAdapterError("INVALID_TARGET", `${operationName}: hyperlink anchor spans multiple blocks.`, { anchor: candidate.anchor });
|
|
143470
|
+
const resolved = resolveTextTarget(editor, {
|
|
143471
|
+
kind: "text",
|
|
143472
|
+
blockId: start$1.blockId,
|
|
143473
|
+
range: {
|
|
143474
|
+
start: start$1.offset,
|
|
143475
|
+
end: end$1.offset
|
|
143476
|
+
}
|
|
143477
|
+
});
|
|
143478
|
+
if (!resolved)
|
|
143479
|
+
throw new DocumentApiAdapterError("TARGET_NOT_FOUND", `${operationName}: hyperlink text range could not be resolved.`, { anchor: candidate.anchor });
|
|
143480
|
+
return resolved;
|
|
143481
|
+
}
|
|
143482
|
+
function hyperlinkSuccess(target) {
|
|
143483
|
+
return {
|
|
143484
|
+
success: true,
|
|
143485
|
+
hyperlink: target
|
|
143486
|
+
};
|
|
143487
|
+
}
|
|
143488
|
+
function hyperlinkFailure(code$1, message) {
|
|
143489
|
+
return {
|
|
143490
|
+
success: false,
|
|
143491
|
+
failure: {
|
|
143492
|
+
code: code$1,
|
|
143493
|
+
message
|
|
143494
|
+
}
|
|
143495
|
+
};
|
|
143496
|
+
}
|
|
143497
|
+
function receiptApplied(receipt2) {
|
|
143498
|
+
return receipt2.steps[0]?.effect === "changed";
|
|
143499
|
+
}
|
|
143500
|
+
function matchesListQuery(candidate, query2, editor) {
|
|
143501
|
+
if (!query2)
|
|
143502
|
+
return true;
|
|
143503
|
+
const props = candidateToReadProperties(candidate);
|
|
143504
|
+
if (query2.hrefPattern && (!props.href || !props.href.includes(query2.hrefPattern)))
|
|
143505
|
+
return false;
|
|
143506
|
+
if (query2.anchor && props.anchor !== query2.anchor)
|
|
143507
|
+
return false;
|
|
143508
|
+
if (query2.textPattern) {
|
|
143509
|
+
const text5 = extractDisplayText(editor, candidate);
|
|
143510
|
+
if (!text5 || !text5.includes(query2.textPattern))
|
|
143511
|
+
return false;
|
|
143512
|
+
}
|
|
143513
|
+
return true;
|
|
143514
|
+
}
|
|
143515
|
+
function hyperlinksListWrapper(editor, query2) {
|
|
143516
|
+
const revision = getRevision(editor);
|
|
143517
|
+
let candidates = findHyperlinkCandidates(editor);
|
|
143518
|
+
if (query2?.within) {
|
|
143519
|
+
const withinResult = resolveWithinScope(getBlockIndex(editor), { within: query2.within }, []);
|
|
143520
|
+
if (!withinResult.ok)
|
|
143521
|
+
candidates = [];
|
|
143522
|
+
else
|
|
143523
|
+
candidates = scopeByRange(candidates, withinResult.range);
|
|
143524
|
+
}
|
|
143525
|
+
const { total, items: paged } = paginate(candidates.filter((c$3) => matchesListQuery(c$3, query2, editor)).map((candidate) => {
|
|
143526
|
+
const domain2 = candidateToDomain(editor, candidate);
|
|
143527
|
+
const ref$1 = encodeInlineRef(candidate.anchor);
|
|
143528
|
+
return buildDiscoveryItem2(ref$1, buildResolvedHandle2(ref$1, "ephemeral", "node"), domain2);
|
|
143529
|
+
}), query2?.offset, query2?.limit);
|
|
143530
|
+
return buildDiscoveryResult2({
|
|
143531
|
+
evaluatedRevision: revision,
|
|
143532
|
+
total,
|
|
143533
|
+
items: paged,
|
|
143534
|
+
page: {
|
|
143535
|
+
limit: query2?.limit ?? total,
|
|
143536
|
+
offset: query2?.offset ?? 0,
|
|
143537
|
+
returned: paged.length
|
|
143538
|
+
}
|
|
143539
|
+
});
|
|
143540
|
+
}
|
|
143541
|
+
function hyperlinksGetWrapper(editor, input2) {
|
|
143542
|
+
const candidate = resolveHyperlinkCandidate(editor, input2.target);
|
|
143543
|
+
return {
|
|
143544
|
+
address: candidateToTarget(candidate),
|
|
143545
|
+
properties: candidateToReadProperties(candidate),
|
|
143546
|
+
text: extractDisplayText(editor, candidate)
|
|
143547
|
+
};
|
|
143548
|
+
}
|
|
143549
|
+
function specFromInput(link2) {
|
|
143550
|
+
return {
|
|
143551
|
+
href: link2.destination.href,
|
|
143552
|
+
anchor: link2.destination.anchor,
|
|
143553
|
+
docLocation: link2.destination.docLocation,
|
|
143554
|
+
tooltip: link2.tooltip,
|
|
143555
|
+
target: link2.target,
|
|
143556
|
+
rel: link2.rel
|
|
143557
|
+
};
|
|
143558
|
+
}
|
|
143559
|
+
function hyperlinksWrapWrapper(editor, input2, options) {
|
|
143560
|
+
rejectTrackedMode("hyperlinks.wrap", options);
|
|
143561
|
+
const resolved = resolveTextTarget(editor, input2.target);
|
|
143562
|
+
if (!resolved)
|
|
143563
|
+
throw new DocumentApiAdapterError("TARGET_NOT_FOUND", "hyperlinks.wrap: text target block not found.", { target: input2.target });
|
|
143564
|
+
rejectIfInsideToc(editor, resolved.from, "hyperlinks.wrap");
|
|
143565
|
+
const overlapping = findInlineByType(buildInlineIndex(editor, getBlockIndex(editor)), "hyperlink").filter((c$3) => c$3.pos < resolved.to && c$3.end > resolved.from);
|
|
143566
|
+
if (overlapping.length > 1)
|
|
143567
|
+
throw new DocumentApiAdapterError("INVALID_TARGET", "hyperlinks.wrap: target range spans multiple existing links.");
|
|
143568
|
+
if (overlapping.length === 1) {
|
|
143569
|
+
const existing = overlapping[0];
|
|
143570
|
+
if (existing.pos === resolved.from && existing.end === resolved.to) {
|
|
143571
|
+
const existingProps = candidateToReadProperties(existing);
|
|
143572
|
+
const spec$1 = specFromInput(input2.link);
|
|
143573
|
+
if (existingProps.href === spec$1.href && existingProps.anchor === spec$1.anchor)
|
|
143574
|
+
return hyperlinkFailure("NO_OP", "Text range is already linked with the same destination.");
|
|
143575
|
+
} else
|
|
143576
|
+
throw new DocumentApiAdapterError("INVALID_TARGET", "hyperlinks.wrap: target range partially overlaps an existing link. Remove the existing link first.");
|
|
143577
|
+
}
|
|
143578
|
+
if (input2.link.destination.href)
|
|
143579
|
+
sanitizeHrefOrThrow(input2.link.destination.href);
|
|
143580
|
+
if (options?.dryRun)
|
|
143581
|
+
return hyperlinkSuccess({
|
|
143582
|
+
kind: "inline",
|
|
143583
|
+
nodeType: "hyperlink",
|
|
143584
|
+
anchor: {
|
|
143585
|
+
start: {
|
|
143586
|
+
blockId: input2.target.blockId,
|
|
143587
|
+
offset: input2.target.range.start
|
|
143588
|
+
},
|
|
143589
|
+
end: {
|
|
143590
|
+
blockId: input2.target.blockId,
|
|
143591
|
+
offset: input2.target.range.end
|
|
143592
|
+
}
|
|
143593
|
+
}
|
|
143594
|
+
});
|
|
143595
|
+
const spec = specFromInput(input2.link);
|
|
143596
|
+
if (!receiptApplied(executeDomainCommand(editor, () => {
|
|
143597
|
+
const result = wrapWithLink(editor, resolved.from, resolved.to, spec);
|
|
143598
|
+
if (result)
|
|
143599
|
+
clearIndexCache(editor);
|
|
143600
|
+
return result;
|
|
143601
|
+
}, { expectedRevision: options?.expectedRevision })))
|
|
143602
|
+
return hyperlinkFailure("NO_OP", "Wrap operation produced no change.");
|
|
143603
|
+
const postCandidate = findHyperlinkAtRange(editor, resolved.from, resolved.to);
|
|
143604
|
+
return hyperlinkSuccess(postCandidate ? candidateToTarget(postCandidate) : {
|
|
143605
|
+
kind: "inline",
|
|
143606
|
+
nodeType: "hyperlink",
|
|
143607
|
+
anchor: {
|
|
143608
|
+
start: {
|
|
143609
|
+
blockId: input2.target.blockId,
|
|
143610
|
+
offset: input2.target.range.start
|
|
143611
|
+
},
|
|
143612
|
+
end: {
|
|
143613
|
+
blockId: input2.target.blockId,
|
|
143614
|
+
offset: input2.target.range.end
|
|
143615
|
+
}
|
|
143616
|
+
}
|
|
143617
|
+
});
|
|
143618
|
+
}
|
|
143619
|
+
function hyperlinksInsertWrapper(editor, input2, options) {
|
|
143620
|
+
rejectTrackedMode("hyperlinks.insert", options);
|
|
143621
|
+
let insertPos;
|
|
143622
|
+
let blockId;
|
|
143623
|
+
let offset$1;
|
|
143624
|
+
let structuralEnd = false;
|
|
143625
|
+
if (input2.target) {
|
|
143626
|
+
const resolved = resolveTextTarget(editor, input2.target);
|
|
143627
|
+
if (!resolved)
|
|
143628
|
+
throw new DocumentApiAdapterError("TARGET_NOT_FOUND", "hyperlinks.insert: text target block not found.", { target: input2.target });
|
|
143629
|
+
rejectIfInsideToc(editor, resolved.from, "hyperlinks.insert");
|
|
143630
|
+
insertPos = resolved.from;
|
|
143631
|
+
blockId = input2.target.blockId;
|
|
143632
|
+
offset$1 = input2.target.range.start;
|
|
143633
|
+
} else {
|
|
143634
|
+
const fallback = resolveDefaultInsertTarget(editor);
|
|
143635
|
+
if (!fallback)
|
|
143636
|
+
throw new DocumentApiAdapterError("TARGET_NOT_FOUND", "hyperlinks.insert: document has no content to insert into.");
|
|
143637
|
+
if (fallback.kind === "text-block") {
|
|
143638
|
+
insertPos = fallback.range.from;
|
|
143639
|
+
blockId = fallback.target.blockId;
|
|
143640
|
+
offset$1 = fallback.target.range.start;
|
|
143641
|
+
} else {
|
|
143642
|
+
insertPos = fallback.insertPos;
|
|
143643
|
+
blockId = "";
|
|
143644
|
+
offset$1 = 0;
|
|
143645
|
+
structuralEnd = true;
|
|
143646
|
+
}
|
|
143647
|
+
}
|
|
143648
|
+
if (input2.link.destination.href)
|
|
143649
|
+
sanitizeHrefOrThrow(input2.link.destination.href);
|
|
143650
|
+
if (options?.dryRun)
|
|
143651
|
+
return hyperlinkSuccess({
|
|
143652
|
+
kind: "inline",
|
|
143653
|
+
nodeType: "hyperlink",
|
|
143654
|
+
anchor: {
|
|
143655
|
+
start: {
|
|
143656
|
+
blockId,
|
|
143657
|
+
offset: offset$1
|
|
143658
|
+
},
|
|
143659
|
+
end: {
|
|
143660
|
+
blockId,
|
|
143661
|
+
offset: offset$1 + input2.text.length
|
|
143662
|
+
}
|
|
143663
|
+
}
|
|
143664
|
+
});
|
|
143665
|
+
const spec = specFromInput(input2.link);
|
|
143666
|
+
if (!receiptApplied(executeDomainCommand(editor, () => {
|
|
143667
|
+
if (structuralEnd) {
|
|
143668
|
+
insertParagraphAtEnd(editor, insertPos, input2.text);
|
|
143669
|
+
clearIndexCache(editor);
|
|
143670
|
+
const textStart = insertPos + 1;
|
|
143671
|
+
const result$1 = wrapWithLink(editor, textStart, textStart + input2.text.length, spec);
|
|
143672
|
+
if (result$1)
|
|
143673
|
+
clearIndexCache(editor);
|
|
143674
|
+
return result$1;
|
|
143675
|
+
}
|
|
143676
|
+
const result = insertLinkedText(editor, insertPos, input2.text, spec);
|
|
143677
|
+
if (result)
|
|
143678
|
+
clearIndexCache(editor);
|
|
143679
|
+
return result;
|
|
143680
|
+
}, { expectedRevision: options?.expectedRevision })))
|
|
143681
|
+
return hyperlinkFailure("NO_OP", "Insert operation produced no change.");
|
|
143682
|
+
const searchFrom = structuralEnd ? insertPos + 1 : insertPos;
|
|
143683
|
+
const postCandidate = findHyperlinkAtRange(editor, searchFrom, searchFrom + input2.text.length);
|
|
143684
|
+
return hyperlinkSuccess(postCandidate ? candidateToTarget(postCandidate) : {
|
|
143685
|
+
kind: "inline",
|
|
143686
|
+
nodeType: "hyperlink",
|
|
143687
|
+
anchor: {
|
|
143688
|
+
start: {
|
|
143689
|
+
blockId,
|
|
143690
|
+
offset: offset$1
|
|
143691
|
+
},
|
|
143692
|
+
end: {
|
|
143693
|
+
blockId,
|
|
143694
|
+
offset: offset$1 + input2.text.length
|
|
143695
|
+
}
|
|
143696
|
+
}
|
|
143697
|
+
});
|
|
143698
|
+
}
|
|
143699
|
+
function hyperlinksPatchWrapper(editor, input2, options) {
|
|
143700
|
+
rejectTrackedMode("hyperlinks.patch", options);
|
|
143701
|
+
const candidate = resolveHyperlinkCandidate(editor, input2.target);
|
|
143702
|
+
const resolvedRange = resolveCandidateTextRange(editor, candidate, "hyperlinks.patch");
|
|
143703
|
+
rejectIfInsideToc(editor, resolvedRange.from, "hyperlinks.patch");
|
|
143704
|
+
const existingMark = candidate.mark;
|
|
143705
|
+
if (!existingMark)
|
|
143706
|
+
throw new DocumentApiAdapterError("TARGET_NOT_FOUND", "hyperlinks.patch: resolved candidate has no mark.");
|
|
143707
|
+
const oldAttrs = existingMark.attrs;
|
|
143708
|
+
const mergedHref = input2.patch.href === undefined ? oldAttrs.href : input2.patch.href;
|
|
143709
|
+
const mergedAnchor = input2.patch.anchor === undefined ? oldAttrs.anchor : input2.patch.anchor;
|
|
143710
|
+
const hasHref = typeof mergedHref === "string" && mergedHref.length > 0;
|
|
143711
|
+
const hasAnchor = typeof mergedAnchor === "string" && mergedAnchor.length > 0;
|
|
143712
|
+
if (!hasHref && !hasAnchor)
|
|
143713
|
+
throw new DocumentApiAdapterError("INVALID_INPUT", "hyperlinks.patch: resulting destination must have at least one of href or anchor.");
|
|
143714
|
+
if (typeof input2.patch.href === "string")
|
|
143715
|
+
sanitizeHrefOrThrow(input2.patch.href);
|
|
143716
|
+
const currentProps = candidateToReadProperties(candidate);
|
|
143717
|
+
if (Object.entries(input2.patch).every(([key$1, value]) => {
|
|
143718
|
+
if (value === undefined)
|
|
143719
|
+
return true;
|
|
143720
|
+
if (value === null)
|
|
143721
|
+
return currentProps[key$1] === undefined;
|
|
143722
|
+
return currentProps[key$1] === value;
|
|
143723
|
+
}))
|
|
143724
|
+
return hyperlinkFailure("NO_OP", "Patch produces no change — all values already match.");
|
|
143725
|
+
if (options?.dryRun)
|
|
143726
|
+
return hyperlinkSuccess(candidateToTarget(candidate));
|
|
143727
|
+
if (!receiptApplied(executeDomainCommand(editor, () => {
|
|
143728
|
+
const result = patchLinkMark(editor, resolvedRange.from, resolvedRange.to, existingMark, input2.patch);
|
|
143729
|
+
if (result)
|
|
143730
|
+
clearIndexCache(editor);
|
|
143731
|
+
return result;
|
|
143732
|
+
}, { expectedRevision: options?.expectedRevision })))
|
|
143733
|
+
return hyperlinkFailure("NO_OP", "Patch operation produced no change.");
|
|
143734
|
+
const postCandidate = findHyperlinkAtRange(editor, resolvedRange.from, resolvedRange.to);
|
|
143735
|
+
return hyperlinkSuccess(postCandidate ? candidateToTarget(postCandidate) : candidateToTarget(candidate));
|
|
143736
|
+
}
|
|
143737
|
+
function hyperlinksRemoveWrapper(editor, input2, options) {
|
|
143738
|
+
rejectTrackedMode("hyperlinks.remove", options);
|
|
143739
|
+
const candidate = resolveHyperlinkCandidate(editor, input2.target);
|
|
143740
|
+
const resolvedRange = resolveCandidateTextRange(editor, candidate, "hyperlinks.remove");
|
|
143741
|
+
rejectIfInsideToc(editor, resolvedRange.from, "hyperlinks.remove");
|
|
143742
|
+
const mode = input2.mode ?? "unwrap";
|
|
143743
|
+
const targetAddress = candidateToTarget(candidate);
|
|
143744
|
+
if (options?.dryRun)
|
|
143745
|
+
return hyperlinkSuccess(targetAddress);
|
|
143746
|
+
if (!receiptApplied(executeDomainCommand(editor, () => {
|
|
143747
|
+
const result = mode === "unwrap" ? unwrapLink(editor, resolvedRange.from, resolvedRange.to) : deleteLinkedText(editor, resolvedRange.from, resolvedRange.to);
|
|
143748
|
+
if (result)
|
|
143749
|
+
clearIndexCache(editor);
|
|
143750
|
+
return result;
|
|
143751
|
+
}, { expectedRevision: options?.expectedRevision })))
|
|
143752
|
+
return hyperlinkFailure("NO_OP", `Remove (${mode}) operation produced no change.`);
|
|
143753
|
+
return hyperlinkSuccess(targetAddress);
|
|
143754
|
+
}
|
|
143755
|
+
function findHyperlinkAtRange(editor, from$12, to) {
|
|
143756
|
+
const hyperlinks = findInlineByType(buildInlineIndex(editor, getBlockIndex(editor)), "hyperlink");
|
|
143757
|
+
return hyperlinks.find((c$3) => c$3.pos >= from$12 - 1 && c$3.pos <= from$12 + 1 && c$3.end >= to - 1 && c$3.end <= to + 1) ?? hyperlinks.find((c$3) => c$3.pos <= from$12 && c$3.end >= to);
|
|
143758
|
+
}
|
|
142627
143759
|
function assembleDocumentApiAdapters(editor) {
|
|
142628
143760
|
registerBuiltInExecutors();
|
|
142629
143761
|
initRevision(editor);
|
|
@@ -142806,6 +143938,14 @@ function assembleDocumentApiAdapters(editor) {
|
|
|
142806
143938
|
setAnchorOptions: (input2, options) => imagesSetAnchorOptionsWrapper(editor, input2, options),
|
|
142807
143939
|
setZOrder: (input2, options) => imagesSetZOrderWrapper(editor, input2, options)
|
|
142808
143940
|
},
|
|
143941
|
+
hyperlinks: {
|
|
143942
|
+
list: (query2) => hyperlinksListWrapper(editor, query2),
|
|
143943
|
+
get: (input2) => hyperlinksGetWrapper(editor, input2),
|
|
143944
|
+
wrap: (input2, options) => hyperlinksWrapWrapper(editor, input2, options),
|
|
143945
|
+
insert: (input2, options) => hyperlinksInsertWrapper(editor, input2, options),
|
|
143946
|
+
patch: (input2, options) => hyperlinksPatchWrapper(editor, input2, options),
|
|
143947
|
+
remove: (input2, options) => hyperlinksRemoveWrapper(editor, input2, options)
|
|
143948
|
+
},
|
|
142809
143949
|
query: { match: (input2) => queryMatchAdapter(editor, input2) },
|
|
142810
143950
|
mutations: {
|
|
142811
143951
|
preview: (input2) => previewPlan(editor, input2),
|
|
@@ -172580,15 +173720,15 @@ var Node$13 = class Node$14 {
|
|
|
172580
173720
|
return false;
|
|
172581
173721
|
if ($from.parent.type.name !== "run")
|
|
172582
173722
|
return false;
|
|
172583
|
-
let dispatchTransaction = null;
|
|
173723
|
+
let dispatchTransaction$1 = null;
|
|
172584
173724
|
if (view?.dispatch)
|
|
172585
|
-
dispatchTransaction = view.dispatch.bind(view);
|
|
173725
|
+
dispatchTransaction$1 = view.dispatch.bind(view);
|
|
172586
173726
|
else if (editor?.dispatch)
|
|
172587
|
-
dispatchTransaction = editor.dispatch.bind(editor);
|
|
172588
|
-
if (!dispatchTransaction)
|
|
173727
|
+
dispatchTransaction$1 = editor.dispatch.bind(editor);
|
|
173728
|
+
if (!dispatchTransaction$1)
|
|
172589
173729
|
return false;
|
|
172590
173730
|
const handled = splitBlockPatch(state, (transaction) => {
|
|
172591
|
-
dispatchTransaction(transaction);
|
|
173731
|
+
dispatchTransaction$1(transaction);
|
|
172592
173732
|
}, editor);
|
|
172593
173733
|
if (handled)
|
|
172594
173734
|
tr.setMeta("preventDispatch", true);
|
|
@@ -177240,11 +178380,11 @@ var Node$13 = class Node$14 {
|
|
|
177240
178380
|
this.eventListenerCleanups = [];
|
|
177241
178381
|
this.resizeTimeoutId = null;
|
|
177242
178382
|
}
|
|
177243
|
-
attach({ element: element3, state, editorProps = {}, dispatchTransaction, handleClick: handleClick$1 }) {
|
|
178383
|
+
attach({ element: element3, state, editorProps = {}, dispatchTransaction: dispatchTransaction$1, handleClick: handleClick$1 }) {
|
|
177244
178384
|
this.view?.destroy();
|
|
177245
178385
|
this.view = new EditorView(element3, {
|
|
177246
178386
|
...editorProps && typeof editorProps === "object" ? editorProps : {},
|
|
177247
|
-
dispatchTransaction,
|
|
178387
|
+
dispatchTransaction: dispatchTransaction$1,
|
|
177248
178388
|
state,
|
|
177249
178389
|
handleClick: handleClick$1
|
|
177250
178390
|
});
|
|
@@ -196108,9 +197248,9 @@ var Node$13 = class Node$14 {
|
|
|
196108
197248
|
trackedChanges: context.trackedChanges ?? []
|
|
196109
197249
|
});
|
|
196110
197250
|
}, _hoisted_1$6, _hoisted_2$2, _hoisted_3, _hoisted_4, ContextMenu_default, _hoisted_1$5, BasicUpload_default, _hoisted_1$4, MIN_WIDTH = 200, PPI = 96, alignment = "flex-end", Ruler_default, GenericPopover_default, _hoisted_1$3, _hoisted_2$1, RESIZE_HANDLE_WIDTH_PX = 9, RESIZE_HANDLE_HEIGHT_PX = 9, RESIZE_HANDLE_OFFSET_PX = 4, DRAG_OVERLAY_EXTENSION_PX = 1000, MIN_DRAG_OVERLAY_WIDTH_PX = 2000, THROTTLE_INTERVAL_MS = 16, MIN_RESIZE_DELTA_PX = 1, TableResizeOverlay_default, _hoisted_1$2, OVERLAY_EXPANSION_PX = 2000, RESIZE_HANDLE_SIZE_PX = 12, MOUSE_MOVE_THROTTLE_MS = 16, DIMENSION_CHANGE_THRESHOLD_PX = 1, Z_INDEX_OVERLAY = 10, Z_INDEX_HANDLE = 15, Z_INDEX_GUIDELINE = 20, ImageResizeOverlay_default, LINK_CLICK_DEBOUNCE_MS = 300, CURSOR_UPDATE_TIMEOUT_MS = 10, POPOVER_VERTICAL_OFFSET_PX = 15, LinkClickHandler_default, _hoisted_1$1, _hoisted_2, DOCX2 = "application/vnd.openxmlformats-officedocument.wordprocessingml.document", TABLE_RESIZE_HOVER_THRESHOLD = 8, TABLE_RESIZE_THROTTLE_MS = 16, SuperEditor_default, _hoisted_1, SuperInput_default, SlashMenu, Extensions;
|
|
196111
|
-
var
|
|
197251
|
+
var init_src_nq0HTKfv_es = __esm(() => {
|
|
196112
197252
|
init_rolldown_runtime_B2q5OVn9_es();
|
|
196113
|
-
|
|
197253
|
+
init_SuperConverter_C3jSWLmj_es();
|
|
196114
197254
|
init_jszip_ChlR43oI_es();
|
|
196115
197255
|
init_uuid_qzgm05fK_es();
|
|
196116
197256
|
init_constants_CMPtQbp7_es();
|
|
@@ -197125,9 +198265,9 @@ var init_src_BRb4tNf0_es = __esm(() => {
|
|
|
197125
198265
|
cssChecked = /* @__PURE__ */ new WeakMap;
|
|
197126
198266
|
isInline = /^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;
|
|
197127
198267
|
EditorView.prototype.dispatch = function(tr) {
|
|
197128
|
-
let dispatchTransaction = this._props.dispatchTransaction;
|
|
197129
|
-
if (dispatchTransaction)
|
|
197130
|
-
dispatchTransaction.call(this, tr);
|
|
198268
|
+
let dispatchTransaction$1 = this._props.dispatchTransaction;
|
|
198269
|
+
if (dispatchTransaction$1)
|
|
198270
|
+
dispatchTransaction$1.call(this, tr);
|
|
197131
198271
|
else
|
|
197132
198272
|
this.updateState(this.state.apply(tr));
|
|
197133
198273
|
};
|
|
@@ -227792,8 +228932,8 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
227792
228932
|
return isObjectLike_default(value) && hasOwnProperty$8.call(value, "callee") && !propertyIsEnumerable$1.call(value, "callee");
|
|
227793
228933
|
};
|
|
227794
228934
|
stubFalse_default = stubFalse;
|
|
227795
|
-
freeExports$2 = typeof
|
|
227796
|
-
freeModule$2 = freeExports$2 && typeof
|
|
228935
|
+
freeExports$2 = typeof exports_src_nq0HTKfv_es == "object" && exports_src_nq0HTKfv_es && !exports_src_nq0HTKfv_es.nodeType && exports_src_nq0HTKfv_es;
|
|
228936
|
+
freeModule$2 = freeExports$2 && typeof module_src_nq0HTKfv_es == "object" && module_src_nq0HTKfv_es && !module_src_nq0HTKfv_es.nodeType && module_src_nq0HTKfv_es;
|
|
227797
228937
|
Buffer$1 = freeModule$2 && freeModule$2.exports === freeExports$2 ? _root_default.Buffer : undefined;
|
|
227798
228938
|
isBuffer_default = (Buffer$1 ? Buffer$1.isBuffer : undefined) || stubFalse_default;
|
|
227799
228939
|
typedArrayTags = {};
|
|
@@ -227801,8 +228941,8 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
227801
228941
|
typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] = typedArrayTags[arrayBufferTag$1] = typedArrayTags[boolTag$1] = typedArrayTags[dataViewTag$2] = typedArrayTags[dateTag$1] = typedArrayTags[errorTag$1] = typedArrayTags[funcTag] = typedArrayTags[mapTag$2] = typedArrayTags[numberTag$1] = typedArrayTags[objectTag$3] = typedArrayTags[regexpTag$1] = typedArrayTags[setTag$2] = typedArrayTags[stringTag$1] = typedArrayTags[weakMapTag$1] = false;
|
|
227802
228942
|
_baseIsTypedArray_default = baseIsTypedArray;
|
|
227803
228943
|
_baseUnary_default = baseUnary;
|
|
227804
|
-
freeExports$1 = typeof
|
|
227805
|
-
freeModule$1 = freeExports$1 && typeof
|
|
228944
|
+
freeExports$1 = typeof exports_src_nq0HTKfv_es == "object" && exports_src_nq0HTKfv_es && !exports_src_nq0HTKfv_es.nodeType && exports_src_nq0HTKfv_es;
|
|
228945
|
+
freeModule$1 = freeExports$1 && typeof module_src_nq0HTKfv_es == "object" && module_src_nq0HTKfv_es && !module_src_nq0HTKfv_es.nodeType && module_src_nq0HTKfv_es;
|
|
227806
228946
|
freeProcess = freeModule$1 && freeModule$1.exports === freeExports$1 && _freeGlobal_default.process;
|
|
227807
228947
|
_nodeUtil_default = function() {
|
|
227808
228948
|
try {
|
|
@@ -227907,8 +229047,8 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
227907
229047
|
Stack.prototype.has = _stackHas_default;
|
|
227908
229048
|
Stack.prototype.set = _stackSet_default;
|
|
227909
229049
|
_Stack_default = Stack;
|
|
227910
|
-
freeExports = typeof
|
|
227911
|
-
freeModule = freeExports && typeof
|
|
229050
|
+
freeExports = typeof exports_src_nq0HTKfv_es == "object" && exports_src_nq0HTKfv_es && !exports_src_nq0HTKfv_es.nodeType && exports_src_nq0HTKfv_es;
|
|
229051
|
+
freeModule = freeExports && typeof module_src_nq0HTKfv_es == "object" && module_src_nq0HTKfv_es && !module_src_nq0HTKfv_es.nodeType && module_src_nq0HTKfv_es;
|
|
227912
229052
|
Buffer4 = freeModule && freeModule.exports === freeExports ? _root_default.Buffer : undefined;
|
|
227913
229053
|
allocUnsafe = Buffer4 ? Buffer4.allocUnsafe : undefined;
|
|
227914
229054
|
_cloneBuffer_default = cloneBuffer;
|
|
@@ -235988,8 +237128,8 @@ var init_zipper_DqXT7uTa_es = __esm(() => {
|
|
|
235988
237128
|
|
|
235989
237129
|
// ../../packages/superdoc/dist/super-editor.es.js
|
|
235990
237130
|
var init_super_editor_es = __esm(() => {
|
|
235991
|
-
|
|
235992
|
-
|
|
237131
|
+
init_src_nq0HTKfv_es();
|
|
237132
|
+
init_SuperConverter_C3jSWLmj_es();
|
|
235993
237133
|
init_jszip_ChlR43oI_es();
|
|
235994
237134
|
init_xml_js_DLE8mr0n_es();
|
|
235995
237135
|
init_constants_CMPtQbp7_es();
|
|
@@ -255472,7 +256612,152 @@ var init_CommandService = () => {};
|
|
|
255472
256612
|
// ../../packages/super-editor/src/core/helpers/getHTMLFromFragment.js
|
|
255473
256613
|
var init_getHTMLFromFragment = () => {};
|
|
255474
256614
|
// ../../shared/url-validation/index.js
|
|
255475
|
-
|
|
256615
|
+
function toProtocolSet2(values2) {
|
|
256616
|
+
const result = new Set;
|
|
256617
|
+
if (!values2)
|
|
256618
|
+
return result;
|
|
256619
|
+
values2.forEach((value) => {
|
|
256620
|
+
if (typeof value === "string" && value.trim()) {
|
|
256621
|
+
result.add(value.trim().toLowerCase());
|
|
256622
|
+
}
|
|
256623
|
+
});
|
|
256624
|
+
return result;
|
|
256625
|
+
}
|
|
256626
|
+
function buildAllowedProtocols2(config2 = {}) {
|
|
256627
|
+
const allowed = config2.allowedProtocols?.length ? toProtocolSet2(config2.allowedProtocols) : new Set(DEFAULT_ALLOWED_PROTOCOLS2);
|
|
256628
|
+
const optional = toProtocolSet2(config2.optionalProtocols);
|
|
256629
|
+
if (optional.size > 0) {
|
|
256630
|
+
optional.forEach((protocol) => {
|
|
256631
|
+
if (OPTIONAL_PROTOCOLS2.includes(protocol)) {
|
|
256632
|
+
allowed.add(protocol);
|
|
256633
|
+
}
|
|
256634
|
+
});
|
|
256635
|
+
}
|
|
256636
|
+
return allowed;
|
|
256637
|
+
}
|
|
256638
|
+
function normalizeBlocklist2(values2) {
|
|
256639
|
+
const hosts = new Set;
|
|
256640
|
+
const urls = new Set;
|
|
256641
|
+
if (!values2) {
|
|
256642
|
+
return { hosts, urls };
|
|
256643
|
+
}
|
|
256644
|
+
values2.forEach((entry) => {
|
|
256645
|
+
if (!entry || typeof entry !== "string")
|
|
256646
|
+
return;
|
|
256647
|
+
const trimmed = entry.trim().toLowerCase();
|
|
256648
|
+
if (!trimmed)
|
|
256649
|
+
return;
|
|
256650
|
+
if (trimmed.includes("://")) {
|
|
256651
|
+
urls.add(trimmed);
|
|
256652
|
+
} else {
|
|
256653
|
+
hosts.add(trimmed);
|
|
256654
|
+
}
|
|
256655
|
+
});
|
|
256656
|
+
return { hosts, urls };
|
|
256657
|
+
}
|
|
256658
|
+
function parseAnchorLink2(trimmed) {
|
|
256659
|
+
if (!trimmed.startsWith("#"))
|
|
256660
|
+
return null;
|
|
256661
|
+
const anchor = trimmed.slice(1);
|
|
256662
|
+
if (!anchor || !ANCHOR_NAME_PATTERN2.test(anchor)) {
|
|
256663
|
+
return null;
|
|
256664
|
+
}
|
|
256665
|
+
return { href: `#${anchor}`, protocol: null, isExternal: false };
|
|
256666
|
+
}
|
|
256667
|
+
function isProtocolAllowed2(scheme, allowedProtocols, blockedProtocols) {
|
|
256668
|
+
if (blockedProtocols.includes(scheme)) {
|
|
256669
|
+
return false;
|
|
256670
|
+
}
|
|
256671
|
+
return allowedProtocols.has(scheme);
|
|
256672
|
+
}
|
|
256673
|
+
function isBlockedByRedirectList2(normalizedHref, parsed, blocklist) {
|
|
256674
|
+
const { hosts, urls } = blocklist;
|
|
256675
|
+
const hostname2 = parsed.hostname ? parsed.hostname.toLowerCase() : "";
|
|
256676
|
+
if (hosts.size > 0 && hostname2 && hosts.has(hostname2)) {
|
|
256677
|
+
return true;
|
|
256678
|
+
}
|
|
256679
|
+
if (urls.size > 0) {
|
|
256680
|
+
const hrefLower = normalizedHref.toLowerCase();
|
|
256681
|
+
for (const blockedUrl of urls) {
|
|
256682
|
+
if (hrefLower.startsWith(blockedUrl)) {
|
|
256683
|
+
return true;
|
|
256684
|
+
}
|
|
256685
|
+
}
|
|
256686
|
+
}
|
|
256687
|
+
return false;
|
|
256688
|
+
}
|
|
256689
|
+
function sanitizeHref2(raw, config2 = {}) {
|
|
256690
|
+
if (typeof raw !== "string")
|
|
256691
|
+
return null;
|
|
256692
|
+
const trimmed = raw.trim();
|
|
256693
|
+
if (!trimmed)
|
|
256694
|
+
return null;
|
|
256695
|
+
const maxLength = typeof config2.maxLength === "number" ? config2.maxLength : DEFAULT_MAX_LENGTH2;
|
|
256696
|
+
if (trimmed.length > maxLength) {
|
|
256697
|
+
return null;
|
|
256698
|
+
}
|
|
256699
|
+
const anchorResult = parseAnchorLink2(trimmed);
|
|
256700
|
+
if (anchorResult !== null) {
|
|
256701
|
+
return anchorResult;
|
|
256702
|
+
}
|
|
256703
|
+
if (trimmed.startsWith("/") || trimmed.startsWith(".") || trimmed.startsWith("//") || /^www\./i.test(trimmed)) {
|
|
256704
|
+
return null;
|
|
256705
|
+
}
|
|
256706
|
+
const schemeMatch = trimmed.match(/^([a-z0-9+.-]+):/i);
|
|
256707
|
+
if (!schemeMatch) {
|
|
256708
|
+
return null;
|
|
256709
|
+
}
|
|
256710
|
+
const scheme = schemeMatch[1].toLowerCase();
|
|
256711
|
+
const allowedProtocols = buildAllowedProtocols2(config2);
|
|
256712
|
+
const blockedProtocols = BLOCKED_PROTOCOLS2.concat(config2.blockedProtocols ?? []).map((p4) => p4.toLowerCase());
|
|
256713
|
+
if (!isProtocolAllowed2(scheme, allowedProtocols, blockedProtocols)) {
|
|
256714
|
+
return null;
|
|
256715
|
+
}
|
|
256716
|
+
const hostStartIndex = trimmed.indexOf("://") + 3;
|
|
256717
|
+
let hostEndIndex = trimmed.indexOf("/", hostStartIndex);
|
|
256718
|
+
if (hostEndIndex === -1) {
|
|
256719
|
+
hostEndIndex = trimmed.indexOf("?", hostStartIndex);
|
|
256720
|
+
}
|
|
256721
|
+
if (hostEndIndex === -1) {
|
|
256722
|
+
hostEndIndex = trimmed.indexOf("#", hostStartIndex);
|
|
256723
|
+
}
|
|
256724
|
+
if (hostEndIndex === -1) {
|
|
256725
|
+
hostEndIndex = trimmed.length;
|
|
256726
|
+
}
|
|
256727
|
+
const rawHostname = trimmed.slice(hostStartIndex, hostEndIndex).toLowerCase();
|
|
256728
|
+
if (rawHostname && /[^\x00-\x7F]/.test(rawHostname)) {
|
|
256729
|
+
if (true) {
|
|
256730
|
+
console.warn(`[URL Validation] Potential homograph attack detected in hostname: ${rawHostname.slice(0, 50)}`);
|
|
256731
|
+
}
|
|
256732
|
+
}
|
|
256733
|
+
const queryStartIndex = trimmed.indexOf("?");
|
|
256734
|
+
if (queryStartIndex !== -1) {
|
|
256735
|
+
const queryString = trimmed.slice(queryStartIndex);
|
|
256736
|
+
if (/[<>"']/.test(queryString)) {
|
|
256737
|
+
return null;
|
|
256738
|
+
}
|
|
256739
|
+
}
|
|
256740
|
+
let parsed;
|
|
256741
|
+
try {
|
|
256742
|
+
parsed = new URL(trimmed);
|
|
256743
|
+
} catch {
|
|
256744
|
+
return null;
|
|
256745
|
+
}
|
|
256746
|
+
const normalizedHref = trimmed;
|
|
256747
|
+
const blocklist = normalizeBlocklist2(config2.redirectBlocklist);
|
|
256748
|
+
if (isBlockedByRedirectList2(normalizedHref, parsed, blocklist)) {
|
|
256749
|
+
return null;
|
|
256750
|
+
}
|
|
256751
|
+
const isExternal = scheme === "http" || scheme === "https";
|
|
256752
|
+
return { href: normalizedHref, protocol: scheme, isExternal };
|
|
256753
|
+
}
|
|
256754
|
+
var DEFAULT_ALLOWED_PROTOCOLS2, OPTIONAL_PROTOCOLS2, BLOCKED_PROTOCOLS2, DEFAULT_MAX_LENGTH2 = 2048, ANCHOR_NAME_PATTERN2;
|
|
256755
|
+
var init_url_validation = __esm(() => {
|
|
256756
|
+
DEFAULT_ALLOWED_PROTOCOLS2 = ["http", "https", "mailto", "tel", "sms"];
|
|
256757
|
+
OPTIONAL_PROTOCOLS2 = ["ftp", "sftp", "irc"];
|
|
256758
|
+
BLOCKED_PROTOCOLS2 = ["javascript", "data", "vbscript", "file", "ssh", "ws", "wss"];
|
|
256759
|
+
ANCHOR_NAME_PATTERN2 = /^[A-Za-z0-9._-]+$/;
|
|
256760
|
+
});
|
|
255476
256761
|
|
|
255477
256762
|
// ../../packages/super-editor/src/core/super-converter/docx-helpers/docx-constants.js
|
|
255478
256763
|
var RELATIONSHIP_TYPES2;
|
|
@@ -313223,6 +314508,545 @@ var init_images_wrappers = __esm(() => {
|
|
|
313223
314508
|
WRAP_TYPES_SUPPORTING_DISTANCES2 = new Set(["Square", "Tight", "Through", "TopAndBottom"]);
|
|
313224
314509
|
});
|
|
313225
314510
|
|
|
314511
|
+
// ../../packages/super-editor/src/document-api-adapters/helpers/hyperlink-mutation-helper.ts
|
|
314512
|
+
function getLinkMarkType2(editor) {
|
|
314513
|
+
const markType = editor.schema.marks.link;
|
|
314514
|
+
if (!markType) {
|
|
314515
|
+
throw new Error("Link mark type is not defined in the editor schema.");
|
|
314516
|
+
}
|
|
314517
|
+
return markType;
|
|
314518
|
+
}
|
|
314519
|
+
function dispatchTransaction2(editor, tr) {
|
|
314520
|
+
editor.dispatch(tr);
|
|
314521
|
+
}
|
|
314522
|
+
function dispatchIfChanged2(editor, tr) {
|
|
314523
|
+
if (!tr.docChanged)
|
|
314524
|
+
return false;
|
|
314525
|
+
dispatchTransaction2(editor, tr);
|
|
314526
|
+
return true;
|
|
314527
|
+
}
|
|
314528
|
+
function createRelationshipId2(editor, href) {
|
|
314529
|
+
if (editor.options.mode !== "docx")
|
|
314530
|
+
return null;
|
|
314531
|
+
try {
|
|
314532
|
+
return insertNewRelationship2(href, "hyperlink", editor);
|
|
314533
|
+
} catch {
|
|
314534
|
+
return null;
|
|
314535
|
+
}
|
|
314536
|
+
}
|
|
314537
|
+
function sanitizeHrefOrThrow2(href) {
|
|
314538
|
+
const result = sanitizeHref2(href);
|
|
314539
|
+
if (!result) {
|
|
314540
|
+
throw Object.assign(new Error(`Blocked or invalid href: "${href}"`), { code: "INVALID_INPUT" });
|
|
314541
|
+
}
|
|
314542
|
+
return result.href;
|
|
314543
|
+
}
|
|
314544
|
+
function buildMarkAttrs2(editor, spec) {
|
|
314545
|
+
const attrs = {};
|
|
314546
|
+
if (spec.href) {
|
|
314547
|
+
attrs.href = sanitizeHrefOrThrow2(spec.href);
|
|
314548
|
+
attrs.rId = createRelationshipId2(editor, attrs.href);
|
|
314549
|
+
}
|
|
314550
|
+
if (spec.anchor) {
|
|
314551
|
+
attrs.anchor = spec.anchor;
|
|
314552
|
+
if (!spec.href) {
|
|
314553
|
+
attrs.href = `#${spec.anchor}`;
|
|
314554
|
+
}
|
|
314555
|
+
}
|
|
314556
|
+
if (spec.docLocation)
|
|
314557
|
+
attrs.docLocation = spec.docLocation;
|
|
314558
|
+
if (spec.tooltip)
|
|
314559
|
+
attrs.tooltip = spec.tooltip;
|
|
314560
|
+
if (spec.target)
|
|
314561
|
+
attrs.target = spec.target;
|
|
314562
|
+
if (spec.rel)
|
|
314563
|
+
attrs.rel = spec.rel;
|
|
314564
|
+
return attrs;
|
|
314565
|
+
}
|
|
314566
|
+
function wrapWithLink2(editor, from4, to, spec) {
|
|
314567
|
+
const linkMarkType = getLinkMarkType2(editor);
|
|
314568
|
+
const attrs = buildMarkAttrs2(editor, spec);
|
|
314569
|
+
const tr = editor.state.tr;
|
|
314570
|
+
tr.addMark(from4, to, linkMarkType.create(attrs));
|
|
314571
|
+
applyDirectMutationMeta2(tr);
|
|
314572
|
+
dispatchTransaction2(editor, tr);
|
|
314573
|
+
return true;
|
|
314574
|
+
}
|
|
314575
|
+
function insertLinkedText2(editor, pos, text9, spec) {
|
|
314576
|
+
const linkMarkType = getLinkMarkType2(editor);
|
|
314577
|
+
const attrs = buildMarkAttrs2(editor, spec);
|
|
314578
|
+
const tr = editor.state.tr;
|
|
314579
|
+
const mark2 = linkMarkType.create(attrs);
|
|
314580
|
+
tr.insertText(text9, pos);
|
|
314581
|
+
tr.addMark(pos, pos + text9.length, mark2);
|
|
314582
|
+
applyDirectMutationMeta2(tr);
|
|
314583
|
+
dispatchTransaction2(editor, tr);
|
|
314584
|
+
return true;
|
|
314585
|
+
}
|
|
314586
|
+
function patchLinkMark2(editor, from4, to, existingMark, patch3) {
|
|
314587
|
+
const linkMarkType = getLinkMarkType2(editor);
|
|
314588
|
+
const oldAttrs = existingMark.attrs;
|
|
314589
|
+
const merged = { ...oldAttrs };
|
|
314590
|
+
for (const [key3, value] of Object.entries(patch3)) {
|
|
314591
|
+
if (value === undefined)
|
|
314592
|
+
continue;
|
|
314593
|
+
if (value === null) {
|
|
314594
|
+
merged[key3] = null;
|
|
314595
|
+
} else {
|
|
314596
|
+
merged[key3] = value;
|
|
314597
|
+
}
|
|
314598
|
+
}
|
|
314599
|
+
if (typeof patch3.href === "string") {
|
|
314600
|
+
merged.href = sanitizeHrefOrThrow2(patch3.href);
|
|
314601
|
+
merged.rId = createRelationshipId2(editor, merged.href);
|
|
314602
|
+
}
|
|
314603
|
+
if (patch3.href === null && typeof merged.anchor === "string") {
|
|
314604
|
+
merged.href = `#${merged.anchor}`;
|
|
314605
|
+
merged.rId = null;
|
|
314606
|
+
}
|
|
314607
|
+
if (typeof patch3.anchor === "string" && patch3.href === undefined) {
|
|
314608
|
+
const currentHref = merged.href;
|
|
314609
|
+
if (typeof currentHref === "string" && currentHref.startsWith("#")) {
|
|
314610
|
+
merged.href = `#${patch3.anchor}`;
|
|
314611
|
+
}
|
|
314612
|
+
}
|
|
314613
|
+
if (patch3.anchor === null && typeof merged.href === "string" && !merged.href.startsWith("#")) {
|
|
314614
|
+
merged.anchor = null;
|
|
314615
|
+
}
|
|
314616
|
+
const tr = editor.state.tr;
|
|
314617
|
+
tr.removeMark(from4, to, existingMark);
|
|
314618
|
+
tr.addMark(from4, to, linkMarkType.create(merged));
|
|
314619
|
+
applyDirectMutationMeta2(tr);
|
|
314620
|
+
return dispatchIfChanged2(editor, tr);
|
|
314621
|
+
}
|
|
314622
|
+
function unwrapLink2(editor, from4, to) {
|
|
314623
|
+
const linkMarkType = getLinkMarkType2(editor);
|
|
314624
|
+
const tr = editor.state.tr;
|
|
314625
|
+
tr.removeMark(from4, to, linkMarkType);
|
|
314626
|
+
applyDirectMutationMeta2(tr);
|
|
314627
|
+
return dispatchIfChanged2(editor, tr);
|
|
314628
|
+
}
|
|
314629
|
+
function deleteLinkedText2(editor, from4, to) {
|
|
314630
|
+
const tr = editor.state.tr;
|
|
314631
|
+
tr.delete(from4, to);
|
|
314632
|
+
applyDirectMutationMeta2(tr);
|
|
314633
|
+
dispatchTransaction2(editor, tr);
|
|
314634
|
+
return true;
|
|
314635
|
+
}
|
|
314636
|
+
var init_hyperlink_mutation_helper = __esm(() => {
|
|
314637
|
+
init_document_rels();
|
|
314638
|
+
init_url_validation();
|
|
314639
|
+
});
|
|
314640
|
+
|
|
314641
|
+
// ../../packages/super-editor/src/document-api-adapters/plan-engine/hyperlinks-wrappers.ts
|
|
314642
|
+
function normalizeReadProperties2(attrs) {
|
|
314643
|
+
const rawHref = typeof attrs.href === "string" ? attrs.href : undefined;
|
|
314644
|
+
const rawAnchor = typeof attrs.anchor === "string" ? attrs.anchor : undefined;
|
|
314645
|
+
const rawDocLocation = typeof attrs.docLocation === "string" ? attrs.docLocation : undefined;
|
|
314646
|
+
const rawTooltip = typeof attrs.tooltip === "string" ? attrs.tooltip : undefined;
|
|
314647
|
+
const rawTarget = typeof attrs.target === "string" ? attrs.target : undefined;
|
|
314648
|
+
const rawRel = typeof attrs.rel === "string" ? attrs.rel : undefined;
|
|
314649
|
+
const props = {};
|
|
314650
|
+
let effectiveAnchor = rawAnchor;
|
|
314651
|
+
let effectiveHref = rawHref;
|
|
314652
|
+
if (rawHref && rawHref.startsWith("#")) {
|
|
314653
|
+
const fragment = rawHref.slice(1);
|
|
314654
|
+
if (!rawAnchor) {
|
|
314655
|
+
effectiveAnchor = fragment;
|
|
314656
|
+
effectiveHref = undefined;
|
|
314657
|
+
} else if (rawAnchor === fragment) {
|
|
314658
|
+
effectiveHref = undefined;
|
|
314659
|
+
}
|
|
314660
|
+
}
|
|
314661
|
+
if (effectiveHref)
|
|
314662
|
+
props.href = effectiveHref;
|
|
314663
|
+
if (effectiveAnchor)
|
|
314664
|
+
props.anchor = effectiveAnchor;
|
|
314665
|
+
if (rawDocLocation)
|
|
314666
|
+
props.docLocation = rawDocLocation;
|
|
314667
|
+
if (rawTooltip)
|
|
314668
|
+
props.tooltip = rawTooltip;
|
|
314669
|
+
if (rawTarget)
|
|
314670
|
+
props.target = rawTarget;
|
|
314671
|
+
if (rawRel)
|
|
314672
|
+
props.rel = rawRel;
|
|
314673
|
+
return props;
|
|
314674
|
+
}
|
|
314675
|
+
function candidateToTarget2(candidate) {
|
|
314676
|
+
return {
|
|
314677
|
+
kind: "inline",
|
|
314678
|
+
nodeType: "hyperlink",
|
|
314679
|
+
anchor: candidate.anchor
|
|
314680
|
+
};
|
|
314681
|
+
}
|
|
314682
|
+
function candidateToReadProperties2(candidate) {
|
|
314683
|
+
const attrs = candidate.mark?.attrs ?? candidate.attrs ?? {};
|
|
314684
|
+
return normalizeReadProperties2(attrs);
|
|
314685
|
+
}
|
|
314686
|
+
function extractDisplayText2(editor, candidate) {
|
|
314687
|
+
const doc4 = editor.state.doc;
|
|
314688
|
+
try {
|
|
314689
|
+
return doc4.textBetween(candidate.pos, candidate.end, "");
|
|
314690
|
+
} catch {
|
|
314691
|
+
return;
|
|
314692
|
+
}
|
|
314693
|
+
}
|
|
314694
|
+
function candidateToDomain2(editor, candidate) {
|
|
314695
|
+
return {
|
|
314696
|
+
address: candidateToTarget2(candidate),
|
|
314697
|
+
properties: candidateToReadProperties2(candidate),
|
|
314698
|
+
text: extractDisplayText2(editor, candidate)
|
|
314699
|
+
};
|
|
314700
|
+
}
|
|
314701
|
+
function encodeInlineRef2(anchor) {
|
|
314702
|
+
return `${anchor.start.blockId}:${anchor.start.offset}:${anchor.end.offset}`;
|
|
314703
|
+
}
|
|
314704
|
+
function isInsideTocBlock2(editor, pos) {
|
|
314705
|
+
const resolved = editor.state.doc.resolve(pos);
|
|
314706
|
+
for (let depth = resolved.depth;depth > 0; depth--) {
|
|
314707
|
+
const node4 = resolved.node(depth);
|
|
314708
|
+
if (node4.type.name === "tableOfContents")
|
|
314709
|
+
return true;
|
|
314710
|
+
}
|
|
314711
|
+
return false;
|
|
314712
|
+
}
|
|
314713
|
+
function rejectIfInsideToc2(editor, pos, operationName) {
|
|
314714
|
+
if (isInsideTocBlock2(editor, pos)) {
|
|
314715
|
+
throw new DocumentApiAdapterError3("INVALID_TARGET", `${operationName}: target is inside a TOC block. TOC content is managed by toc.* operations.`);
|
|
314716
|
+
}
|
|
314717
|
+
}
|
|
314718
|
+
function findHyperlinkCandidates2(editor) {
|
|
314719
|
+
const blockIndex = getBlockIndex2(editor);
|
|
314720
|
+
const inlineIndex = buildInlineIndex2(editor, blockIndex);
|
|
314721
|
+
return findInlineByType2(inlineIndex, "hyperlink");
|
|
314722
|
+
}
|
|
314723
|
+
function resolveHyperlinkCandidate2(editor, target) {
|
|
314724
|
+
const blockIndex = getBlockIndex2(editor);
|
|
314725
|
+
const inlineIndex = buildInlineIndex2(editor, blockIndex);
|
|
314726
|
+
const candidate = findInlineByAnchor2(inlineIndex, target);
|
|
314727
|
+
if (!candidate) {
|
|
314728
|
+
throw new DocumentApiAdapterError3("TARGET_NOT_FOUND", "Hyperlink target not found in document.", { target });
|
|
314729
|
+
}
|
|
314730
|
+
return candidate;
|
|
314731
|
+
}
|
|
314732
|
+
function resolveCandidateTextRange2(editor, candidate, operationName) {
|
|
314733
|
+
const start2 = candidate.anchor.start;
|
|
314734
|
+
const end = candidate.anchor.end;
|
|
314735
|
+
if (start2.blockId !== end.blockId) {
|
|
314736
|
+
throw new DocumentApiAdapterError3("INVALID_TARGET", `${operationName}: hyperlink anchor spans multiple blocks.`, {
|
|
314737
|
+
anchor: candidate.anchor
|
|
314738
|
+
});
|
|
314739
|
+
}
|
|
314740
|
+
const resolved = resolveTextTarget2(editor, {
|
|
314741
|
+
kind: "text",
|
|
314742
|
+
blockId: start2.blockId,
|
|
314743
|
+
range: { start: start2.offset, end: end.offset }
|
|
314744
|
+
});
|
|
314745
|
+
if (!resolved) {
|
|
314746
|
+
throw new DocumentApiAdapterError3("TARGET_NOT_FOUND", `${operationName}: hyperlink text range could not be resolved.`, {
|
|
314747
|
+
anchor: candidate.anchor
|
|
314748
|
+
});
|
|
314749
|
+
}
|
|
314750
|
+
return resolved;
|
|
314751
|
+
}
|
|
314752
|
+
function hyperlinkSuccess2(target) {
|
|
314753
|
+
return { success: true, hyperlink: target };
|
|
314754
|
+
}
|
|
314755
|
+
function hyperlinkFailure2(code10, message) {
|
|
314756
|
+
return { success: false, failure: { code: code10, message } };
|
|
314757
|
+
}
|
|
314758
|
+
function receiptApplied4(receipt2) {
|
|
314759
|
+
return receipt2.steps[0]?.effect === "changed";
|
|
314760
|
+
}
|
|
314761
|
+
function matchesListQuery3(candidate, query2, editor) {
|
|
314762
|
+
if (!query2)
|
|
314763
|
+
return true;
|
|
314764
|
+
const props = candidateToReadProperties2(candidate);
|
|
314765
|
+
if (query2.hrefPattern && (!props.href || !props.href.includes(query2.hrefPattern))) {
|
|
314766
|
+
return false;
|
|
314767
|
+
}
|
|
314768
|
+
if (query2.anchor && props.anchor !== query2.anchor) {
|
|
314769
|
+
return false;
|
|
314770
|
+
}
|
|
314771
|
+
if (query2.textPattern) {
|
|
314772
|
+
const text9 = extractDisplayText2(editor, candidate);
|
|
314773
|
+
if (!text9 || !text9.includes(query2.textPattern))
|
|
314774
|
+
return false;
|
|
314775
|
+
}
|
|
314776
|
+
return true;
|
|
314777
|
+
}
|
|
314778
|
+
function hyperlinksListWrapper2(editor, query2) {
|
|
314779
|
+
const revision = getRevision2(editor);
|
|
314780
|
+
let candidates = findHyperlinkCandidates2(editor);
|
|
314781
|
+
if (query2?.within) {
|
|
314782
|
+
const blockIndex = getBlockIndex2(editor);
|
|
314783
|
+
const diagnostics = [];
|
|
314784
|
+
const withinResult = resolveWithinScope2(blockIndex, { within: query2.within }, diagnostics);
|
|
314785
|
+
if (!withinResult.ok) {
|
|
314786
|
+
candidates = [];
|
|
314787
|
+
} else {
|
|
314788
|
+
candidates = scopeByRange2(candidates, withinResult.range);
|
|
314789
|
+
}
|
|
314790
|
+
}
|
|
314791
|
+
const filtered = candidates.filter((c2) => matchesListQuery3(c2, query2, editor));
|
|
314792
|
+
const allItems = filtered.map((candidate) => {
|
|
314793
|
+
const domain3 = candidateToDomain2(editor, candidate);
|
|
314794
|
+
const ref4 = encodeInlineRef2(candidate.anchor);
|
|
314795
|
+
const handle4 = buildResolvedHandle(ref4, "ephemeral", "node");
|
|
314796
|
+
return buildDiscoveryItem(ref4, handle4, domain3);
|
|
314797
|
+
});
|
|
314798
|
+
const { total, items: paged } = paginate2(allItems, query2?.offset, query2?.limit);
|
|
314799
|
+
const effectiveLimit = query2?.limit ?? total;
|
|
314800
|
+
return buildDiscoveryResult({
|
|
314801
|
+
evaluatedRevision: revision,
|
|
314802
|
+
total,
|
|
314803
|
+
items: paged,
|
|
314804
|
+
page: { limit: effectiveLimit, offset: query2?.offset ?? 0, returned: paged.length }
|
|
314805
|
+
});
|
|
314806
|
+
}
|
|
314807
|
+
function hyperlinksGetWrapper2(editor, input2) {
|
|
314808
|
+
const candidate = resolveHyperlinkCandidate2(editor, input2.target);
|
|
314809
|
+
return {
|
|
314810
|
+
address: candidateToTarget2(candidate),
|
|
314811
|
+
properties: candidateToReadProperties2(candidate),
|
|
314812
|
+
text: extractDisplayText2(editor, candidate)
|
|
314813
|
+
};
|
|
314814
|
+
}
|
|
314815
|
+
function specFromInput2(link3) {
|
|
314816
|
+
return {
|
|
314817
|
+
href: link3.destination.href,
|
|
314818
|
+
anchor: link3.destination.anchor,
|
|
314819
|
+
docLocation: link3.destination.docLocation,
|
|
314820
|
+
tooltip: link3.tooltip,
|
|
314821
|
+
target: link3.target,
|
|
314822
|
+
rel: link3.rel
|
|
314823
|
+
};
|
|
314824
|
+
}
|
|
314825
|
+
function hyperlinksWrapWrapper2(editor, input2, options) {
|
|
314826
|
+
rejectTrackedMode2("hyperlinks.wrap", options);
|
|
314827
|
+
const resolved = resolveTextTarget2(editor, input2.target);
|
|
314828
|
+
if (!resolved) {
|
|
314829
|
+
throw new DocumentApiAdapterError3("TARGET_NOT_FOUND", "hyperlinks.wrap: text target block not found.", {
|
|
314830
|
+
target: input2.target
|
|
314831
|
+
});
|
|
314832
|
+
}
|
|
314833
|
+
rejectIfInsideToc2(editor, resolved.from, "hyperlinks.wrap");
|
|
314834
|
+
const blockIndex = getBlockIndex2(editor);
|
|
314835
|
+
const inlineIndex = buildInlineIndex2(editor, blockIndex);
|
|
314836
|
+
const hyperlinks = findInlineByType2(inlineIndex, "hyperlink");
|
|
314837
|
+
const overlapping = hyperlinks.filter((c2) => c2.pos < resolved.to && c2.end > resolved.from);
|
|
314838
|
+
if (overlapping.length > 1) {
|
|
314839
|
+
throw new DocumentApiAdapterError3("INVALID_TARGET", "hyperlinks.wrap: target range spans multiple existing links.");
|
|
314840
|
+
}
|
|
314841
|
+
if (overlapping.length === 1) {
|
|
314842
|
+
const existing = overlapping[0];
|
|
314843
|
+
if (existing.pos === resolved.from && existing.end === resolved.to) {
|
|
314844
|
+
const existingProps = candidateToReadProperties2(existing);
|
|
314845
|
+
const spec2 = specFromInput2(input2.link);
|
|
314846
|
+
if (existingProps.href === spec2.href && existingProps.anchor === spec2.anchor) {
|
|
314847
|
+
return hyperlinkFailure2("NO_OP", "Text range is already linked with the same destination.");
|
|
314848
|
+
}
|
|
314849
|
+
} else {
|
|
314850
|
+
throw new DocumentApiAdapterError3("INVALID_TARGET", "hyperlinks.wrap: target range partially overlaps an existing link. Remove the existing link first.");
|
|
314851
|
+
}
|
|
314852
|
+
}
|
|
314853
|
+
if (input2.link.destination.href) {
|
|
314854
|
+
sanitizeHrefOrThrow2(input2.link.destination.href);
|
|
314855
|
+
}
|
|
314856
|
+
if (options?.dryRun) {
|
|
314857
|
+
const dryTarget = {
|
|
314858
|
+
kind: "inline",
|
|
314859
|
+
nodeType: "hyperlink",
|
|
314860
|
+
anchor: {
|
|
314861
|
+
start: { blockId: input2.target.blockId, offset: input2.target.range.start },
|
|
314862
|
+
end: { blockId: input2.target.blockId, offset: input2.target.range.end }
|
|
314863
|
+
}
|
|
314864
|
+
};
|
|
314865
|
+
return hyperlinkSuccess2(dryTarget);
|
|
314866
|
+
}
|
|
314867
|
+
const spec = specFromInput2(input2.link);
|
|
314868
|
+
const receipt2 = executeDomainCommand2(editor, () => {
|
|
314869
|
+
const result = wrapWithLink2(editor, resolved.from, resolved.to, spec);
|
|
314870
|
+
if (result)
|
|
314871
|
+
clearIndexCache2(editor);
|
|
314872
|
+
return result;
|
|
314873
|
+
}, { expectedRevision: options?.expectedRevision });
|
|
314874
|
+
if (!receiptApplied4(receipt2)) {
|
|
314875
|
+
return hyperlinkFailure2("NO_OP", "Wrap operation produced no change.");
|
|
314876
|
+
}
|
|
314877
|
+
const postCandidate = findHyperlinkAtRange2(editor, resolved.from, resolved.to);
|
|
314878
|
+
return hyperlinkSuccess2(postCandidate ? candidateToTarget2(postCandidate) : {
|
|
314879
|
+
kind: "inline",
|
|
314880
|
+
nodeType: "hyperlink",
|
|
314881
|
+
anchor: {
|
|
314882
|
+
start: { blockId: input2.target.blockId, offset: input2.target.range.start },
|
|
314883
|
+
end: { blockId: input2.target.blockId, offset: input2.target.range.end }
|
|
314884
|
+
}
|
|
314885
|
+
});
|
|
314886
|
+
}
|
|
314887
|
+
function hyperlinksInsertWrapper2(editor, input2, options) {
|
|
314888
|
+
rejectTrackedMode2("hyperlinks.insert", options);
|
|
314889
|
+
let insertPos;
|
|
314890
|
+
let blockId;
|
|
314891
|
+
let offset2;
|
|
314892
|
+
let structuralEnd = false;
|
|
314893
|
+
if (input2.target) {
|
|
314894
|
+
const resolved = resolveTextTarget2(editor, input2.target);
|
|
314895
|
+
if (!resolved) {
|
|
314896
|
+
throw new DocumentApiAdapterError3("TARGET_NOT_FOUND", "hyperlinks.insert: text target block not found.", {
|
|
314897
|
+
target: input2.target
|
|
314898
|
+
});
|
|
314899
|
+
}
|
|
314900
|
+
rejectIfInsideToc2(editor, resolved.from, "hyperlinks.insert");
|
|
314901
|
+
insertPos = resolved.from;
|
|
314902
|
+
blockId = input2.target.blockId;
|
|
314903
|
+
offset2 = input2.target.range.start;
|
|
314904
|
+
} else {
|
|
314905
|
+
const fallback = resolveDefaultInsertTarget2(editor);
|
|
314906
|
+
if (!fallback) {
|
|
314907
|
+
throw new DocumentApiAdapterError3("TARGET_NOT_FOUND", "hyperlinks.insert: document has no content to insert into.");
|
|
314908
|
+
}
|
|
314909
|
+
if (fallback.kind === "text-block") {
|
|
314910
|
+
insertPos = fallback.range.from;
|
|
314911
|
+
blockId = fallback.target.blockId;
|
|
314912
|
+
offset2 = fallback.target.range.start;
|
|
314913
|
+
} else {
|
|
314914
|
+
insertPos = fallback.insertPos;
|
|
314915
|
+
blockId = "";
|
|
314916
|
+
offset2 = 0;
|
|
314917
|
+
structuralEnd = true;
|
|
314918
|
+
}
|
|
314919
|
+
}
|
|
314920
|
+
if (input2.link.destination.href) {
|
|
314921
|
+
sanitizeHrefOrThrow2(input2.link.destination.href);
|
|
314922
|
+
}
|
|
314923
|
+
if (options?.dryRun) {
|
|
314924
|
+
const dryTarget = {
|
|
314925
|
+
kind: "inline",
|
|
314926
|
+
nodeType: "hyperlink",
|
|
314927
|
+
anchor: {
|
|
314928
|
+
start: { blockId, offset: offset2 },
|
|
314929
|
+
end: { blockId, offset: offset2 + input2.text.length }
|
|
314930
|
+
}
|
|
314931
|
+
};
|
|
314932
|
+
return hyperlinkSuccess2(dryTarget);
|
|
314933
|
+
}
|
|
314934
|
+
const spec = specFromInput2(input2.link);
|
|
314935
|
+
const receipt2 = executeDomainCommand2(editor, () => {
|
|
314936
|
+
if (structuralEnd) {
|
|
314937
|
+
insertParagraphAtEnd2(editor, insertPos, input2.text);
|
|
314938
|
+
clearIndexCache2(editor);
|
|
314939
|
+
const textStart = insertPos + 1;
|
|
314940
|
+
const result2 = wrapWithLink2(editor, textStart, textStart + input2.text.length, spec);
|
|
314941
|
+
if (result2)
|
|
314942
|
+
clearIndexCache2(editor);
|
|
314943
|
+
return result2;
|
|
314944
|
+
}
|
|
314945
|
+
const result = insertLinkedText2(editor, insertPos, input2.text, spec);
|
|
314946
|
+
if (result)
|
|
314947
|
+
clearIndexCache2(editor);
|
|
314948
|
+
return result;
|
|
314949
|
+
}, { expectedRevision: options?.expectedRevision });
|
|
314950
|
+
if (!receiptApplied4(receipt2)) {
|
|
314951
|
+
return hyperlinkFailure2("NO_OP", "Insert operation produced no change.");
|
|
314952
|
+
}
|
|
314953
|
+
const searchFrom = structuralEnd ? insertPos + 1 : insertPos;
|
|
314954
|
+
const searchTo = searchFrom + input2.text.length;
|
|
314955
|
+
const postCandidate = findHyperlinkAtRange2(editor, searchFrom, searchTo);
|
|
314956
|
+
return hyperlinkSuccess2(postCandidate ? candidateToTarget2(postCandidate) : {
|
|
314957
|
+
kind: "inline",
|
|
314958
|
+
nodeType: "hyperlink",
|
|
314959
|
+
anchor: {
|
|
314960
|
+
start: { blockId, offset: offset2 },
|
|
314961
|
+
end: { blockId, offset: offset2 + input2.text.length }
|
|
314962
|
+
}
|
|
314963
|
+
});
|
|
314964
|
+
}
|
|
314965
|
+
function hyperlinksPatchWrapper2(editor, input2, options) {
|
|
314966
|
+
rejectTrackedMode2("hyperlinks.patch", options);
|
|
314967
|
+
const candidate = resolveHyperlinkCandidate2(editor, input2.target);
|
|
314968
|
+
const resolvedRange = resolveCandidateTextRange2(editor, candidate, "hyperlinks.patch");
|
|
314969
|
+
rejectIfInsideToc2(editor, resolvedRange.from, "hyperlinks.patch");
|
|
314970
|
+
const existingMark = candidate.mark;
|
|
314971
|
+
if (!existingMark) {
|
|
314972
|
+
throw new DocumentApiAdapterError3("TARGET_NOT_FOUND", "hyperlinks.patch: resolved candidate has no mark.");
|
|
314973
|
+
}
|
|
314974
|
+
const oldAttrs = existingMark.attrs;
|
|
314975
|
+
const mergedHref = input2.patch.href === undefined ? oldAttrs.href : input2.patch.href;
|
|
314976
|
+
const mergedAnchor = input2.patch.anchor === undefined ? oldAttrs.anchor : input2.patch.anchor;
|
|
314977
|
+
const hasHref = typeof mergedHref === "string" && mergedHref.length > 0;
|
|
314978
|
+
const hasAnchor = typeof mergedAnchor === "string" && mergedAnchor.length > 0;
|
|
314979
|
+
if (!hasHref && !hasAnchor) {
|
|
314980
|
+
throw new DocumentApiAdapterError3("INVALID_INPUT", "hyperlinks.patch: resulting destination must have at least one of href or anchor.");
|
|
314981
|
+
}
|
|
314982
|
+
if (typeof input2.patch.href === "string") {
|
|
314983
|
+
sanitizeHrefOrThrow2(input2.patch.href);
|
|
314984
|
+
}
|
|
314985
|
+
const currentProps = candidateToReadProperties2(candidate);
|
|
314986
|
+
const isNoop = Object.entries(input2.patch).every(([key3, value]) => {
|
|
314987
|
+
if (value === undefined)
|
|
314988
|
+
return true;
|
|
314989
|
+
if (value === null)
|
|
314990
|
+
return currentProps[key3] === undefined;
|
|
314991
|
+
return currentProps[key3] === value;
|
|
314992
|
+
});
|
|
314993
|
+
if (isNoop) {
|
|
314994
|
+
return hyperlinkFailure2("NO_OP", "Patch produces no change — all values already match.");
|
|
314995
|
+
}
|
|
314996
|
+
if (options?.dryRun) {
|
|
314997
|
+
return hyperlinkSuccess2(candidateToTarget2(candidate));
|
|
314998
|
+
}
|
|
314999
|
+
const receipt2 = executeDomainCommand2(editor, () => {
|
|
315000
|
+
const result = patchLinkMark2(editor, resolvedRange.from, resolvedRange.to, existingMark, input2.patch);
|
|
315001
|
+
if (result)
|
|
315002
|
+
clearIndexCache2(editor);
|
|
315003
|
+
return result;
|
|
315004
|
+
}, { expectedRevision: options?.expectedRevision });
|
|
315005
|
+
if (!receiptApplied4(receipt2)) {
|
|
315006
|
+
return hyperlinkFailure2("NO_OP", "Patch operation produced no change.");
|
|
315007
|
+
}
|
|
315008
|
+
const postCandidate = findHyperlinkAtRange2(editor, resolvedRange.from, resolvedRange.to);
|
|
315009
|
+
return hyperlinkSuccess2(postCandidate ? candidateToTarget2(postCandidate) : candidateToTarget2(candidate));
|
|
315010
|
+
}
|
|
315011
|
+
function hyperlinksRemoveWrapper2(editor, input2, options) {
|
|
315012
|
+
rejectTrackedMode2("hyperlinks.remove", options);
|
|
315013
|
+
const candidate = resolveHyperlinkCandidate2(editor, input2.target);
|
|
315014
|
+
const resolvedRange = resolveCandidateTextRange2(editor, candidate, "hyperlinks.remove");
|
|
315015
|
+
rejectIfInsideToc2(editor, resolvedRange.from, "hyperlinks.remove");
|
|
315016
|
+
const mode = input2.mode ?? "unwrap";
|
|
315017
|
+
const targetAddress = candidateToTarget2(candidate);
|
|
315018
|
+
if (options?.dryRun) {
|
|
315019
|
+
return hyperlinkSuccess2(targetAddress);
|
|
315020
|
+
}
|
|
315021
|
+
const receipt2 = executeDomainCommand2(editor, () => {
|
|
315022
|
+
const result = mode === "unwrap" ? unwrapLink2(editor, resolvedRange.from, resolvedRange.to) : deleteLinkedText2(editor, resolvedRange.from, resolvedRange.to);
|
|
315023
|
+
if (result)
|
|
315024
|
+
clearIndexCache2(editor);
|
|
315025
|
+
return result;
|
|
315026
|
+
}, { expectedRevision: options?.expectedRevision });
|
|
315027
|
+
if (!receiptApplied4(receipt2)) {
|
|
315028
|
+
return hyperlinkFailure2("NO_OP", `Remove (${mode}) operation produced no change.`);
|
|
315029
|
+
}
|
|
315030
|
+
return hyperlinkSuccess2(targetAddress);
|
|
315031
|
+
}
|
|
315032
|
+
function findHyperlinkAtRange2(editor, from4, to) {
|
|
315033
|
+
const blockIndex = getBlockIndex2(editor);
|
|
315034
|
+
const inlineIndex = buildInlineIndex2(editor, blockIndex);
|
|
315035
|
+
const hyperlinks = findInlineByType2(inlineIndex, "hyperlink");
|
|
315036
|
+
return hyperlinks.find((c2) => c2.pos >= from4 - 1 && c2.pos <= from4 + 1 && c2.end >= to - 1 && c2.end <= to + 1) ?? hyperlinks.find((c2) => c2.pos <= from4 && c2.end >= to);
|
|
315037
|
+
}
|
|
315038
|
+
var init_hyperlinks_wrappers = __esm(() => {
|
|
315039
|
+
init_src();
|
|
315040
|
+
init_index_cache();
|
|
315041
|
+
init_inline_address_resolver();
|
|
315042
|
+
init_adapter_utils();
|
|
315043
|
+
init_revision_tracker();
|
|
315044
|
+
init_plan_wrappers();
|
|
315045
|
+
init_mutation_helpers();
|
|
315046
|
+
init_errors3();
|
|
315047
|
+
init_hyperlink_mutation_helper();
|
|
315048
|
+
});
|
|
315049
|
+
|
|
313226
315050
|
// ../../packages/super-editor/src/document-api-adapters/assemble-adapters.ts
|
|
313227
315051
|
function assembleDocumentApiAdapters2(editor) {
|
|
313228
315052
|
registerBuiltInExecutors2();
|
|
@@ -313424,6 +315248,14 @@ function assembleDocumentApiAdapters2(editor) {
|
|
|
313424
315248
|
setAnchorOptions: (input2, options) => imagesSetAnchorOptionsWrapper2(editor, input2, options),
|
|
313425
315249
|
setZOrder: (input2, options) => imagesSetZOrderWrapper2(editor, input2, options)
|
|
313426
315250
|
},
|
|
315251
|
+
hyperlinks: {
|
|
315252
|
+
list: (query2) => hyperlinksListWrapper2(editor, query2),
|
|
315253
|
+
get: (input2) => hyperlinksGetWrapper2(editor, input2),
|
|
315254
|
+
wrap: (input2, options) => hyperlinksWrapWrapper2(editor, input2, options),
|
|
315255
|
+
insert: (input2, options) => hyperlinksInsertWrapper2(editor, input2, options),
|
|
315256
|
+
patch: (input2, options) => hyperlinksPatchWrapper2(editor, input2, options),
|
|
315257
|
+
remove: (input2, options) => hyperlinksRemoveWrapper2(editor, input2, options)
|
|
315258
|
+
},
|
|
313427
315259
|
query: {
|
|
313428
315260
|
match: (input2) => queryMatchAdapter2(editor, input2)
|
|
313429
315261
|
},
|
|
@@ -313462,6 +315294,7 @@ var init_assemble_adapters = __esm(() => {
|
|
|
313462
315294
|
init_toc_wrappers();
|
|
313463
315295
|
init_toc_entry_wrappers();
|
|
313464
315296
|
init_images_wrappers();
|
|
315297
|
+
init_hyperlinks_wrappers();
|
|
313465
315298
|
});
|
|
313466
315299
|
|
|
313467
315300
|
// ../../packages/super-editor/src/document-api-adapters/index.ts
|