@canvas-components/print-design 0.1.10 → 0.1.11
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.cjs +288 -39
- package/dist/index.d.cts +33 -2
- package/dist/index.d.ts +33 -2
- package/dist/index.js +287 -40
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2042,8 +2042,8 @@ async function* transformPrintDesignToHtmlBatches(document2, options) {
|
|
|
2042
2042
|
}
|
|
2043
2043
|
|
|
2044
2044
|
// src/helper/group-resize.ts
|
|
2045
|
-
function groupSelectionBounds(elements,
|
|
2046
|
-
const boxes = elements.filter((item) =>
|
|
2045
|
+
function groupSelectionBounds(elements, ids2, data = {}, componentRegistry) {
|
|
2046
|
+
const boxes = elements.filter((item) => ids2.includes(item.id) && item.visible !== false).map((element) => elementBounds(element, data, componentRegistry));
|
|
2047
2047
|
if (boxes.length < 2) return;
|
|
2048
2048
|
const x = Math.min(...boxes.map((box) => box.x)), y = Math.min(...boxes.map((box) => box.y));
|
|
2049
2049
|
return {
|
|
@@ -2172,9 +2172,9 @@ function groupMembers(elements, id) {
|
|
|
2172
2172
|
const groupId = element.groupPath?.[0]?.id;
|
|
2173
2173
|
return groupId ? elements.filter((item) => item.groupPath?.[0]?.id === groupId) : [element];
|
|
2174
2174
|
}
|
|
2175
|
-
function expandGroupSelection(elements,
|
|
2175
|
+
function expandGroupSelection(elements, ids2) {
|
|
2176
2176
|
const selected = new Set(
|
|
2177
|
-
|
|
2177
|
+
ids2.flatMap((id) => groupMembers(elements, id).map((item) => item.id))
|
|
2178
2178
|
);
|
|
2179
2179
|
return elements.filter((item) => selected.has(item.id)).map((item) => item.id);
|
|
2180
2180
|
}
|
|
@@ -4906,10 +4906,10 @@ var PrintDesignInteraction = class extends PrintDesignRenderer {
|
|
|
4906
4906
|
if (!this.componentCellSelection(previewComponent))
|
|
4907
4907
|
this.componentCellSelectionState = null;
|
|
4908
4908
|
} else this.componentCellSelectionState = null;
|
|
4909
|
-
const
|
|
4909
|
+
const ids2 = groupMembers(source.page.elements, source.element.id).map(
|
|
4910
4910
|
(item) => item.id
|
|
4911
4911
|
);
|
|
4912
|
-
this.selectedElementIds =
|
|
4912
|
+
this.selectedElementIds = ids2;
|
|
4913
4913
|
this.emitSelection();
|
|
4914
4914
|
this.canvas.setPointerCapture?.(event.pointerId);
|
|
4915
4915
|
this.dragSession = {
|
|
@@ -4919,7 +4919,7 @@ var PrintDesignInteraction = class extends PrintDesignRenderer {
|
|
|
4919
4919
|
startClient: { x: event.clientX, y: event.clientY },
|
|
4920
4920
|
documentBefore: clonePrintDesignDocument(this.document),
|
|
4921
4921
|
elementPositions: new Map(
|
|
4922
|
-
source.page.elements.filter((item) =>
|
|
4922
|
+
source.page.elements.filter((item) => ids2.includes(item.id)).map((item) => [item.id, { x: item.x, y: item.y }])
|
|
4923
4923
|
),
|
|
4924
4924
|
changed: false
|
|
4925
4925
|
};
|
|
@@ -5548,7 +5548,7 @@ var PrintDesignInteraction = class extends PrintDesignRenderer {
|
|
|
5548
5548
|
const left = Math.min(point.x, session.start.x), top = Math.min(point.y, session.start.y);
|
|
5549
5549
|
const right = Math.max(point.x, session.start.x), bottom = Math.max(point.y, session.start.y);
|
|
5550
5550
|
const page2 = this.getActivePage();
|
|
5551
|
-
const
|
|
5551
|
+
const ids2 = new Set(session.marquee.initialIds);
|
|
5552
5552
|
for (const element of page2.elements) {
|
|
5553
5553
|
if (element.visible === false) continue;
|
|
5554
5554
|
const bounds = elementBounds(
|
|
@@ -5558,9 +5558,9 @@ var PrintDesignInteraction = class extends PrintDesignRenderer {
|
|
|
5558
5558
|
);
|
|
5559
5559
|
if (bounds.x <= right && bounds.y <= bottom && bounds.x + bounds.width >= left && bounds.y + bounds.height >= top)
|
|
5560
5560
|
for (const member of groupMembers(page2.elements, element.id))
|
|
5561
|
-
|
|
5561
|
+
ids2.add(member.id);
|
|
5562
5562
|
}
|
|
5563
|
-
this.selectedElementIds = [...
|
|
5563
|
+
this.selectedElementIds = [...ids2];
|
|
5564
5564
|
this.emitSelection();
|
|
5565
5565
|
this.render();
|
|
5566
5566
|
return;
|
|
@@ -6921,8 +6921,8 @@ var PrintDesignGrouping = class extends PrintDesignInteraction {
|
|
|
6921
6921
|
groupElements(elementIds = this.selectedElementIds) {
|
|
6922
6922
|
if (this.options.readonly) return this;
|
|
6923
6923
|
const elements = this.getActivePage().elements;
|
|
6924
|
-
const
|
|
6925
|
-
const members = elements.filter((item) =>
|
|
6924
|
+
const ids2 = expandGroupSelection(elements, elementIds);
|
|
6925
|
+
const members = elements.filter((item) => ids2.includes(item.id));
|
|
6926
6926
|
const units = new Set(
|
|
6927
6927
|
members.map((item) => item.groupPath?.[0]?.id ?? item.id)
|
|
6928
6928
|
);
|
|
@@ -6930,41 +6930,41 @@ var PrintDesignGrouping = class extends PrintDesignInteraction {
|
|
|
6930
6930
|
const group = { id: createPrintDesignId("group"), name: "\u7EC4\u5408" };
|
|
6931
6931
|
this.commitMutation((document2) => {
|
|
6932
6932
|
const page = this.getPageIn(document2);
|
|
6933
|
-
const selected = page.elements.filter((item) =>
|
|
6933
|
+
const selected = page.elements.filter((item) => ids2.includes(item.id));
|
|
6934
6934
|
const highest = Math.max(
|
|
6935
6935
|
...selected.map((item) => page.elements.indexOf(item))
|
|
6936
6936
|
);
|
|
6937
|
-
const before = page.elements.slice(0, highest + 1).filter((item) => !
|
|
6937
|
+
const before = page.elements.slice(0, highest + 1).filter((item) => !ids2.includes(item.id));
|
|
6938
6938
|
const after = page.elements.slice(highest + 1);
|
|
6939
6939
|
selected.forEach((item) => {
|
|
6940
6940
|
item.groupPath = [group, ...item.groupPath ?? []];
|
|
6941
6941
|
});
|
|
6942
6942
|
page.elements = [...before, ...selected, ...after];
|
|
6943
6943
|
});
|
|
6944
|
-
return this.selectElements(
|
|
6944
|
+
return this.selectElements(ids2);
|
|
6945
6945
|
}
|
|
6946
6946
|
/** 取消选中组合的最外层,保留其内部嵌套组合。 */
|
|
6947
6947
|
ungroupElements(elementIds = this.selectedElementIds) {
|
|
6948
6948
|
if (this.options.readonly) return this;
|
|
6949
|
-
const
|
|
6949
|
+
const ids2 = expandGroupSelection(this.getActivePage().elements, elementIds);
|
|
6950
6950
|
if (this.getActivePage().elements.some(
|
|
6951
|
-
(item) =>
|
|
6951
|
+
(item) => ids2.includes(item.id) && item.locked
|
|
6952
6952
|
))
|
|
6953
6953
|
return this;
|
|
6954
6954
|
this.commitMutation((document2) => {
|
|
6955
6955
|
for (const item of this.getPageIn(document2).elements) {
|
|
6956
|
-
if (!
|
|
6956
|
+
if (!ids2.includes(item.id) || !item.groupPath?.length) continue;
|
|
6957
6957
|
item.groupPath = item.groupPath.slice(1);
|
|
6958
6958
|
if (!item.groupPath.length) delete item.groupPath;
|
|
6959
6959
|
}
|
|
6960
6960
|
});
|
|
6961
|
-
return this.selectElements(
|
|
6961
|
+
return this.selectElements(ids2);
|
|
6962
6962
|
}
|
|
6963
6963
|
};
|
|
6964
6964
|
|
|
6965
6965
|
// src/helper/layer-alignment.ts
|
|
6966
|
-
function getPrintDesignAlignmentUnits(elements,
|
|
6967
|
-
const selected = new Set(
|
|
6966
|
+
function getPrintDesignAlignmentUnits(elements, ids2) {
|
|
6967
|
+
const selected = new Set(ids2);
|
|
6968
6968
|
const groups = /* @__PURE__ */ new Map();
|
|
6969
6969
|
for (const element of elements)
|
|
6970
6970
|
for (const group of element.groupPath ?? []) {
|
|
@@ -6986,8 +6986,8 @@ function getPrintDesignAlignmentUnits(elements, ids) {
|
|
|
6986
6986
|
}
|
|
6987
6987
|
return units;
|
|
6988
6988
|
}
|
|
6989
|
-
function alignPrintDesignLayers(page,
|
|
6990
|
-
const units = getPrintDesignAlignmentUnits(page.elements,
|
|
6989
|
+
function alignPrintDesignLayers(page, ids2, align, data = {}, componentRegistry) {
|
|
6990
|
+
const units = getPrintDesignAlignmentUnits(page.elements, ids2);
|
|
6991
6991
|
if (!units.length || units.some((unit) => unit.some((item) => item.locked)))
|
|
6992
6992
|
return;
|
|
6993
6993
|
const boxes = units.map((unit) => {
|
|
@@ -7257,7 +7257,7 @@ var PrintDesignActions = class extends PrintDesignGrouping {
|
|
|
7257
7257
|
/** 设置选区锁定或显隐状态。 */
|
|
7258
7258
|
setSelectionState(patch) {
|
|
7259
7259
|
if (this.options.readonly) return this;
|
|
7260
|
-
const
|
|
7260
|
+
const ids2 = new Set(
|
|
7261
7261
|
expandGroupSelection(
|
|
7262
7262
|
this.getActivePage().elements,
|
|
7263
7263
|
this.selectedElementIds
|
|
@@ -7265,17 +7265,17 @@ var PrintDesignActions = class extends PrintDesignGrouping {
|
|
|
7265
7265
|
);
|
|
7266
7266
|
this.commitMutation((document2) => {
|
|
7267
7267
|
for (const item of this.getPageIn(document2).elements)
|
|
7268
|
-
if (
|
|
7268
|
+
if (ids2.has(item.id)) Object.assign(item, patch);
|
|
7269
7269
|
});
|
|
7270
7270
|
return this;
|
|
7271
7271
|
}
|
|
7272
7272
|
/** 精确设置指定图层状态;组合节点由调用方传入全部成员,一次操作对应一次撤销。 */
|
|
7273
7273
|
setElementsState(elementIds, patch) {
|
|
7274
7274
|
if (this.options.readonly) return this;
|
|
7275
|
-
const
|
|
7275
|
+
const ids2 = new Set(elementIds);
|
|
7276
7276
|
this.commitMutation((document2) => {
|
|
7277
7277
|
for (const item of this.getPageIn(document2).elements)
|
|
7278
|
-
if (
|
|
7278
|
+
if (ids2.has(item.id)) Object.assign(item, patch);
|
|
7279
7279
|
});
|
|
7280
7280
|
return this;
|
|
7281
7281
|
}
|
|
@@ -7292,7 +7292,7 @@ var PrintDesignActions = class extends PrintDesignGrouping {
|
|
|
7292
7292
|
moveSelectionLayer(direction) {
|
|
7293
7293
|
if (this.options.readonly || this.selectedElements().some((item) => item.locked))
|
|
7294
7294
|
return this;
|
|
7295
|
-
const
|
|
7295
|
+
const ids2 = new Set(this.selectedElementIds);
|
|
7296
7296
|
this.commitMutation((document2) => {
|
|
7297
7297
|
const page = this.getPageIn(document2);
|
|
7298
7298
|
const units = [];
|
|
@@ -7303,7 +7303,7 @@ var PrintDesignActions = class extends PrintDesignGrouping {
|
|
|
7303
7303
|
members.forEach((member) => seen.add(member.id));
|
|
7304
7304
|
units.push(members);
|
|
7305
7305
|
}
|
|
7306
|
-
const selected = (unit) => unit.some((item) =>
|
|
7306
|
+
const selected = (unit) => unit.some((item) => ids2.has(item.id));
|
|
7307
7307
|
if (direction === "front" || direction === "back") {
|
|
7308
7308
|
const picked = units.filter(selected), rest = units.filter((unit) => !selected(unit));
|
|
7309
7309
|
page.elements = (direction === "front" ? [...rest, ...picked] : [...picked, ...rest]).flat();
|
|
@@ -7650,18 +7650,18 @@ var PrintDesign = class extends PrintDesignActions {
|
|
|
7650
7650
|
/** 一次重置选中组件的通用和组件专属变形。 */
|
|
7651
7651
|
resetElementTransforms(elementIds = this.selectedElementIds) {
|
|
7652
7652
|
if (!elementIds.length) return this;
|
|
7653
|
-
const
|
|
7653
|
+
const ids2 = new Set(elementIds);
|
|
7654
7654
|
const targets = this.getActivePage().elements.filter(
|
|
7655
|
-
(element) =>
|
|
7655
|
+
(element) => ids2.has(element.id)
|
|
7656
7656
|
);
|
|
7657
7657
|
if (targets.some((element) => element.groupPath?.length)) return this;
|
|
7658
7658
|
if (!targets.some(
|
|
7659
|
-
(element) =>
|
|
7659
|
+
(element) => ids2.has(element.id) && !element.locked && this.hasElementTransform(element)
|
|
7660
7660
|
))
|
|
7661
7661
|
return this;
|
|
7662
7662
|
this.commitMutation((document2) => {
|
|
7663
7663
|
for (const element of this.getPageIn(document2).elements) {
|
|
7664
|
-
if (!
|
|
7664
|
+
if (!ids2.has(element.id) || element.locked) continue;
|
|
7665
7665
|
element.transform = void 0;
|
|
7666
7666
|
this.options.componentRegistry?.get(element.type)?.transformReset?.reset(element);
|
|
7667
7667
|
}
|
|
@@ -7671,25 +7671,25 @@ var PrintDesign = class extends PrintDesignActions {
|
|
|
7671
7671
|
/** 删除当前选区或指定元素。 */
|
|
7672
7672
|
removeElements(elementIds = this.selectedElementIds) {
|
|
7673
7673
|
if (!elementIds.length) return this;
|
|
7674
|
-
const
|
|
7674
|
+
const ids2 = new Set(
|
|
7675
7675
|
expandGroupSelection(this.getActivePage().elements, elementIds)
|
|
7676
7676
|
);
|
|
7677
7677
|
this.commitMutation((document2) => {
|
|
7678
7678
|
const page = this.getPageIn(document2);
|
|
7679
7679
|
const componentRegistry = this.options.componentRegistry ?? builtinPrintDesignComponentRegistry;
|
|
7680
7680
|
for (const element of page.elements) {
|
|
7681
|
-
if (
|
|
7681
|
+
if (ids2.has(element.id)) continue;
|
|
7682
7682
|
componentRegistry.get(element.type)?.onElementsRemoved?.(element, {
|
|
7683
7683
|
page,
|
|
7684
|
-
removedIds:
|
|
7684
|
+
removedIds: ids2,
|
|
7685
7685
|
data: this.options.data ?? {},
|
|
7686
7686
|
componentRegistry
|
|
7687
7687
|
});
|
|
7688
7688
|
}
|
|
7689
|
-
page.elements = page.elements.filter((element) => !
|
|
7689
|
+
page.elements = page.elements.filter((element) => !ids2.has(element.id));
|
|
7690
7690
|
});
|
|
7691
7691
|
this.selectedElementIds = this.selectedElementIds.filter(
|
|
7692
|
-
(id) => !
|
|
7692
|
+
(id) => !ids2.has(id)
|
|
7693
7693
|
);
|
|
7694
7694
|
this.emitSelection();
|
|
7695
7695
|
this.render();
|
|
@@ -7902,13 +7902,260 @@ function getPrintDesignPageSize(page) {
|
|
|
7902
7902
|
return { width: page.width, height: page.height };
|
|
7903
7903
|
}
|
|
7904
7904
|
|
|
7905
|
+
// src/agent/agent-api.ts
|
|
7906
|
+
var objectSchema = (properties, required = []) => ({
|
|
7907
|
+
type: "object",
|
|
7908
|
+
properties,
|
|
7909
|
+
required,
|
|
7910
|
+
additionalProperties: false
|
|
7911
|
+
});
|
|
7912
|
+
var idSchema = { type: "string", minLength: 1 };
|
|
7913
|
+
var idsSchema = { type: "array", items: idSchema, minItems: 1 };
|
|
7914
|
+
var printDesignAgentTools = [
|
|
7915
|
+
{
|
|
7916
|
+
name: "get_document",
|
|
7917
|
+
description: "\u8BFB\u53D6\u5F53\u524D\u6253\u5370\u8BBE\u8BA1\u6587\u6863\u3002\u9875\u9762\u5C3A\u5BF8\u548C\u5143\u7D20\u5750\u6807\u5355\u4F4D\u4E3A\u6BEB\u7C73\u3002",
|
|
7918
|
+
parameters: objectSchema({})
|
|
7919
|
+
},
|
|
7920
|
+
{
|
|
7921
|
+
name: "get_selection",
|
|
7922
|
+
description: "\u8BFB\u53D6\u5F53\u524D\u6D3B\u52A8\u9875\u548C\u9009\u4E2D\u7684\u5143\u7D20 ID\u3002",
|
|
7923
|
+
parameters: objectSchema({})
|
|
7924
|
+
},
|
|
7925
|
+
{
|
|
7926
|
+
name: "list_components",
|
|
7927
|
+
description: "\u5217\u51FA\u5BBF\u4E3B\u5DF2\u6CE8\u518C\u7684\u7EC4\u4EF6\u7C7B\u578B\uFF1B\u65B0\u589E\u8868\u683C\u7B49\u63D2\u4EF6\u7EC4\u4EF6\u524D\u5148\u67E5\u770B\u6B64\u5217\u8868\u3002",
|
|
7928
|
+
parameters: objectSchema({})
|
|
7929
|
+
},
|
|
7930
|
+
{
|
|
7931
|
+
name: "get_component_template",
|
|
7932
|
+
description: "\u8BFB\u53D6\u5DF2\u6CE8\u518C\u7EC4\u4EF6\u7684\u9ED8\u8BA4\u5143\u7D20\u548C\u53EF\u7528\u547D\u4EE4\uFF1B\u521B\u5EFA\u6216\u4FEE\u6539\u590D\u6742\u7EC4\u4EF6\u524D\u5148\u67E5\u770B\u3002",
|
|
7933
|
+
parameters: objectSchema({ type: idSchema, preset: { type: "string" } }, [
|
|
7934
|
+
"type"
|
|
7935
|
+
])
|
|
7936
|
+
},
|
|
7937
|
+
{
|
|
7938
|
+
name: "get_element",
|
|
7939
|
+
description: "\u8BFB\u53D6\u5F53\u524D\u9875\u6307\u5B9A\u5143\u7D20\u7684\u5B8C\u6574\u914D\u7F6E\u3002",
|
|
7940
|
+
parameters: objectSchema({ elementId: idSchema }, ["elementId"])
|
|
7941
|
+
},
|
|
7942
|
+
{
|
|
7943
|
+
name: "set_active_page",
|
|
7944
|
+
description: "\u5207\u6362\u5F53\u524D\u6D3B\u52A8\u9875\u3002",
|
|
7945
|
+
parameters: objectSchema({ pageId: idSchema }, ["pageId"])
|
|
7946
|
+
},
|
|
7947
|
+
{
|
|
7948
|
+
name: "select_elements",
|
|
7949
|
+
description: "\u5728\u5F53\u524D\u9875\u9009\u4E2D\u5143\u7D20\u3002",
|
|
7950
|
+
parameters: objectSchema({ elementIds: idsSchema }, ["elementIds"])
|
|
7951
|
+
},
|
|
7952
|
+
{
|
|
7953
|
+
name: "add_element",
|
|
7954
|
+
description: "\u5728\u5F53\u524D\u9875\u65B0\u589E\u5143\u7D20\u3002\u4F20\u5165 type \u548C\u9700\u8981\u8986\u76D6\u7684\u5B57\u6BB5\uFF1B\u5DF2\u6CE8\u518C\u7EC4\u4EF6\u4F1A\u81EA\u52A8\u8865\u9F50\u5DE5\u5382\u9ED8\u8BA4\u503C\uFF0C\u590D\u6742\u7EC4\u4EF6\u8BF7\u5148\u8BFB\u53D6\u6A21\u677F\u3002",
|
|
7955
|
+
parameters: objectSchema({ element: { type: "object" } }, ["element"])
|
|
7956
|
+
},
|
|
7957
|
+
{
|
|
7958
|
+
name: "update_element",
|
|
7959
|
+
description: "\u66F4\u65B0\u5F53\u524D\u9875\u6307\u5B9A\u5143\u7D20\u7684\u5C5E\u6027\uFF1B\u4E0D\u80FD\u4FEE\u6539 id \u6216 type\u3002",
|
|
7960
|
+
parameters: objectSchema(
|
|
7961
|
+
{ elementId: idSchema, patch: { type: "object" } },
|
|
7962
|
+
["elementId", "patch"]
|
|
7963
|
+
)
|
|
7964
|
+
},
|
|
7965
|
+
{
|
|
7966
|
+
name: "remove_elements",
|
|
7967
|
+
description: "\u5220\u9664\u5F53\u524D\u9875\u6307\u5B9A\u5143\u7D20\u3002",
|
|
7968
|
+
parameters: objectSchema({ elementIds: idsSchema }, ["elementIds"])
|
|
7969
|
+
},
|
|
7970
|
+
{
|
|
7971
|
+
name: "execute_component_command",
|
|
7972
|
+
description: "\u6267\u884C\u7EC4\u4EF6\u6CE8\u518C\u7684\u547D\u4EE4\uFF0C\u4F8B\u5982\u8868\u683C\u63D2\u5165\u884C\u5217\u6216\u5408\u5E76\u5355\u5143\u683C\uFF1B\u5148\u8BFB\u53D6\u7EC4\u4EF6\u6A21\u677F\u4E2D\u7684\u547D\u4EE4\u5217\u8868\u3002",
|
|
7973
|
+
parameters: objectSchema(
|
|
7974
|
+
{
|
|
7975
|
+
elementId: idSchema,
|
|
7976
|
+
command: idSchema,
|
|
7977
|
+
payload: { type: "object" }
|
|
7978
|
+
},
|
|
7979
|
+
["elementId", "command", "payload"]
|
|
7980
|
+
)
|
|
7981
|
+
},
|
|
7982
|
+
{
|
|
7983
|
+
name: "undo",
|
|
7984
|
+
description: "\u64A4\u9500\u4E0A\u4E00\u6B65\u7F16\u8F91\u3002",
|
|
7985
|
+
parameters: objectSchema({})
|
|
7986
|
+
},
|
|
7987
|
+
{
|
|
7988
|
+
name: "redo",
|
|
7989
|
+
description: "\u91CD\u505A\u4E0A\u4E00\u6B65\u7F16\u8F91\u3002",
|
|
7990
|
+
parameters: objectSchema({})
|
|
7991
|
+
}
|
|
7992
|
+
];
|
|
7993
|
+
function record(input) {
|
|
7994
|
+
if (!input || typeof input !== "object" || Array.isArray(input))
|
|
7995
|
+
throw new TypeError("\u5DE5\u5177\u53C2\u6570\u5FC5\u987B\u662F\u5BF9\u8C61\u3002");
|
|
7996
|
+
return input;
|
|
7997
|
+
}
|
|
7998
|
+
function string(input, name) {
|
|
7999
|
+
if (typeof input !== "string" || !input.trim())
|
|
8000
|
+
throw new TypeError(`${name} \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32\u3002`);
|
|
8001
|
+
return input;
|
|
8002
|
+
}
|
|
8003
|
+
function ids(input) {
|
|
8004
|
+
if (!Array.isArray(input) || !input.length)
|
|
8005
|
+
throw new TypeError("elementIds \u5FC5\u987B\u662F\u975E\u7A7A\u6570\u7EC4\u3002");
|
|
8006
|
+
return input.map((id) => string(id, "elementId"));
|
|
8007
|
+
}
|
|
8008
|
+
function safeJson(input, depth = 0) {
|
|
8009
|
+
if (depth > 20) throw new RangeError("\u5DE5\u5177\u53C2\u6570\u5D4C\u5957\u8FC7\u6DF1\u3002");
|
|
8010
|
+
if (input === null || typeof input === "string" || typeof input === "boolean")
|
|
8011
|
+
return;
|
|
8012
|
+
if (typeof input === "number" && Number.isFinite(input)) return;
|
|
8013
|
+
if (Array.isArray(input)) {
|
|
8014
|
+
if (input.length > 1e4) throw new RangeError("\u5DE5\u5177\u6570\u7EC4\u8FC7\u957F\u3002");
|
|
8015
|
+
input.forEach((item) => safeJson(item, depth + 1));
|
|
8016
|
+
return;
|
|
8017
|
+
}
|
|
8018
|
+
if (!input || typeof input !== "object")
|
|
8019
|
+
throw new TypeError("\u5DE5\u5177\u53C2\u6570\u5FC5\u987B\u662F JSON \u6570\u636E\u3002");
|
|
8020
|
+
const entries = Object.entries(input);
|
|
8021
|
+
if (entries.length > 1e3) throw new RangeError("\u5DE5\u5177\u5BF9\u8C61\u5B57\u6BB5\u8FC7\u591A\u3002");
|
|
8022
|
+
for (const [key, value] of entries) {
|
|
8023
|
+
if (["__proto__", "prototype", "constructor"].includes(key))
|
|
8024
|
+
throw new TypeError("\u5DE5\u5177\u53C2\u6570\u5305\u542B\u975E\u6CD5\u5B57\u6BB5\u3002");
|
|
8025
|
+
safeJson(value, depth + 1);
|
|
8026
|
+
}
|
|
8027
|
+
}
|
|
8028
|
+
function createPrintDesignAgentApi(getInstance, options = {}) {
|
|
8029
|
+
return {
|
|
8030
|
+
tools: printDesignAgentTools,
|
|
8031
|
+
call(name, input) {
|
|
8032
|
+
const instance = getInstance();
|
|
8033
|
+
if (!instance) throw new Error("\u6253\u5370\u8BBE\u8BA1\u5668\u5C1A\u672A\u5C31\u7EEA\u3002");
|
|
8034
|
+
const args = record(input);
|
|
8035
|
+
safeJson(args);
|
|
8036
|
+
if (name === "get_document") return instance.getDocument();
|
|
8037
|
+
if (name === "get_selection") return instance.getSelection();
|
|
8038
|
+
if (name === "list_components")
|
|
8039
|
+
return options.componentCatalog?.list().map(({ type, label }) => ({
|
|
8040
|
+
type,
|
|
8041
|
+
label
|
|
8042
|
+
})) ?? [];
|
|
8043
|
+
if (name === "get_component_template") {
|
|
8044
|
+
const type = string(args.type, "type");
|
|
8045
|
+
const factory = options.componentCatalog?.list().find((item) => item.type === type);
|
|
8046
|
+
if (!factory || !options.componentCatalog)
|
|
8047
|
+
throw new Error(`\u672A\u6CE8\u518C\u7EC4\u4EF6\u521B\u5EFA\u5668\uFF1A${type}`);
|
|
8048
|
+
const preset = args.preset === void 0 ? void 0 : string(args.preset, "preset");
|
|
8049
|
+
const { id: _ignored, ...element } = options.componentCatalog.create(
|
|
8050
|
+
type,
|
|
8051
|
+
preset
|
|
8052
|
+
);
|
|
8053
|
+
return {
|
|
8054
|
+
type,
|
|
8055
|
+
label: factory.label,
|
|
8056
|
+
element,
|
|
8057
|
+
commands: factory.agentCommands ?? []
|
|
8058
|
+
};
|
|
8059
|
+
}
|
|
8060
|
+
if (name === "get_element") {
|
|
8061
|
+
const elementId = string(args.elementId, "elementId");
|
|
8062
|
+
const found = instance.getDocument().pages.find((item) => item.id === instance.getActivePageId())?.elements.find((item) => item.id === elementId);
|
|
8063
|
+
if (!found) throw new Error(`\u627E\u4E0D\u5230\u5143\u7D20\uFF1A${elementId}`);
|
|
8064
|
+
return found;
|
|
8065
|
+
}
|
|
8066
|
+
if (options.readonly?.()) throw new Error("\u5F53\u524D\u8BBE\u8BA1\u5668\u4E3A\u53EA\u8BFB\u72B6\u6001\u3002");
|
|
8067
|
+
const document2 = instance.getDocument();
|
|
8068
|
+
const page = document2.pages.find(
|
|
8069
|
+
(item) => item.id === instance.getActivePageId()
|
|
8070
|
+
);
|
|
8071
|
+
if (name === "set_active_page") {
|
|
8072
|
+
const pageId = string(args.pageId, "pageId");
|
|
8073
|
+
if (!document2.pages.some((item) => item.id === pageId))
|
|
8074
|
+
throw new Error(`\u627E\u4E0D\u5230\u9875\u9762\uFF1A${pageId}`);
|
|
8075
|
+
instance.setActivePage(pageId);
|
|
8076
|
+
return instance.getSelection();
|
|
8077
|
+
}
|
|
8078
|
+
if (name === "select_elements") {
|
|
8079
|
+
const elementIds = ids(args.elementIds);
|
|
8080
|
+
if (elementIds.some((id) => !page.elements.some((item) => item.id === id)))
|
|
8081
|
+
throw new Error("\u5F53\u524D\u9875\u4E0D\u5B58\u5728\u6307\u5B9A\u5143\u7D20\u3002");
|
|
8082
|
+
instance.selectElements(elementIds);
|
|
8083
|
+
return instance.getSelection();
|
|
8084
|
+
}
|
|
8085
|
+
if (name === "add_element") {
|
|
8086
|
+
const element = record(args.element);
|
|
8087
|
+
const type = string(element.type, "type");
|
|
8088
|
+
const { id: _ignored, ...fields } = element;
|
|
8089
|
+
const defaults = options.componentCatalog?.list().some((item) => item.type === type) ? options.componentCatalog.create(type) : null;
|
|
8090
|
+
if (options.componentCatalog && !defaults)
|
|
8091
|
+
throw new Error(`\u672A\u6CE8\u518C\u7EC4\u4EF6\u521B\u5EFA\u5668\uFF1A${type}`);
|
|
8092
|
+
const { id: _defaultId, ...defaultFields } = defaults ?? {};
|
|
8093
|
+
const id = instance.addElement({
|
|
8094
|
+
...defaultFields,
|
|
8095
|
+
...fields
|
|
8096
|
+
});
|
|
8097
|
+
return { id };
|
|
8098
|
+
}
|
|
8099
|
+
if (name === "update_element") {
|
|
8100
|
+
const elementId = string(args.elementId, "elementId");
|
|
8101
|
+
const target = page.elements.find((item) => item.id === elementId);
|
|
8102
|
+
if (!target) throw new Error(`\u627E\u4E0D\u5230\u5143\u7D20\uFF1A${elementId}`);
|
|
8103
|
+
if (target.locked) throw new Error(`\u5143\u7D20\u5DF2\u9501\u5B9A\uFF1A${elementId}`);
|
|
8104
|
+
const patch = record(args.patch);
|
|
8105
|
+
if ("id" in patch || "type" in patch)
|
|
8106
|
+
throw new TypeError("\u4E0D\u80FD\u4FEE\u6539\u5143\u7D20 id \u6216 type\u3002");
|
|
8107
|
+
instance.updateElement(elementId, patch);
|
|
8108
|
+
return { elementId };
|
|
8109
|
+
}
|
|
8110
|
+
if (name === "remove_elements") {
|
|
8111
|
+
const elementIds = ids(args.elementIds);
|
|
8112
|
+
if (elementIds.some((id) => !page.elements.some((item) => item.id === id)))
|
|
8113
|
+
throw new Error("\u5F53\u524D\u9875\u4E0D\u5B58\u5728\u6307\u5B9A\u5143\u7D20\u3002");
|
|
8114
|
+
if (page.elements.some(
|
|
8115
|
+
(item) => elementIds.includes(item.id) && item.locked
|
|
8116
|
+
))
|
|
8117
|
+
throw new Error("\u4E0D\u80FD\u5220\u9664\u5DF2\u9501\u5B9A\u5143\u7D20\u3002");
|
|
8118
|
+
instance.removeElements(elementIds);
|
|
8119
|
+
return { removed: elementIds };
|
|
8120
|
+
}
|
|
8121
|
+
if (name === "execute_component_command") {
|
|
8122
|
+
const elementId = string(args.elementId, "elementId");
|
|
8123
|
+
const command = string(args.command, "command");
|
|
8124
|
+
const target = page.elements.find((item) => item.id === elementId);
|
|
8125
|
+
if (!target) throw new Error(`\u627E\u4E0D\u5230\u5143\u7D20\uFF1A${elementId}`);
|
|
8126
|
+
if (target.locked) throw new Error(`\u5143\u7D20\u5DF2\u9501\u5B9A\uFF1A${elementId}`);
|
|
8127
|
+
const definitions = options.componentCatalog?.list().find((item) => item.type === target.type)?.agentCommands;
|
|
8128
|
+
if (definitions && !definitions.some((item) => item.name === command))
|
|
8129
|
+
throw new Error(`\u7EC4\u4EF6\u4E0D\u652F\u6301\u547D\u4EE4\uFF1A${command}`);
|
|
8130
|
+
const payload = record(args.payload);
|
|
8131
|
+
instance.executeComponentCommand(elementId, command, payload);
|
|
8132
|
+
const updated = instance.getDocument().pages.find((item) => item.id === page.id)?.elements.find((item) => item.id === elementId);
|
|
8133
|
+
return {
|
|
8134
|
+
elementId,
|
|
8135
|
+
command,
|
|
8136
|
+
applied: JSON.stringify(updated) !== JSON.stringify(target)
|
|
8137
|
+
};
|
|
8138
|
+
}
|
|
8139
|
+
if (name === "undo") {
|
|
8140
|
+
instance.undo();
|
|
8141
|
+
return { canUndo: instance.canUndo(), canRedo: instance.canRedo() };
|
|
8142
|
+
}
|
|
8143
|
+
if (name === "redo") {
|
|
8144
|
+
instance.redo();
|
|
8145
|
+
return { canUndo: instance.canUndo(), canRedo: instance.canRedo() };
|
|
8146
|
+
}
|
|
8147
|
+
throw new Error(`\u672A\u77E5 Agent \u5DE5\u5177\uFF1A${name}`);
|
|
8148
|
+
}
|
|
8149
|
+
};
|
|
8150
|
+
}
|
|
8151
|
+
|
|
7905
8152
|
// src/model/collection-data.ts
|
|
7906
8153
|
function isPrintDesignRecordCollection(value) {
|
|
7907
8154
|
return !!value && typeof value === "object" && !Array.isArray(value) && Array.isArray(value.dataSource);
|
|
7908
8155
|
}
|
|
7909
8156
|
|
|
7910
8157
|
// package.json
|
|
7911
|
-
var version = "0.1.
|
|
8158
|
+
var version = "0.1.11";
|
|
7912
8159
|
|
|
7913
8160
|
exports.DEFAULT_PRINT_DESIGN_DEBUG_OPTIONS = DEFAULT_PRINT_DESIGN_DEBUG_OPTIONS;
|
|
7914
8161
|
exports.PRINT_DESIGN_CSS_DPI = PRINT_DESIGN_CSS_DPI;
|
|
@@ -7923,6 +8170,7 @@ exports.buildPrintDesignLayerTree = buildPrintDesignLayerTree;
|
|
|
7923
8170
|
exports.builtinPrintDesignComponentRegistry = builtinPrintDesignComponentRegistry;
|
|
7924
8171
|
exports.canvasPointToPageMillimeters = canvasPointToPageMillimeters;
|
|
7925
8172
|
exports.clonePrintDesignDocument = clonePrintDesignDocument;
|
|
8173
|
+
exports.createPrintDesignAgentApi = createPrintDesignAgentApi;
|
|
7926
8174
|
exports.createPrintDesignDocument = createPrintDesignDocument;
|
|
7927
8175
|
exports.createPrintDesignId = createPrintDesignId;
|
|
7928
8176
|
exports.createPrintDesignPage = createPrintDesignPage;
|
|
@@ -7958,6 +8206,7 @@ exports.parsePrintDesignDocument = parsePrintDesignDocument;
|
|
|
7958
8206
|
exports.pixelsToMillimeters = pixelsToMillimeters;
|
|
7959
8207
|
exports.preparePrintDesignCanvasPage = preparePrintDesignCanvasPage;
|
|
7960
8208
|
exports.preparePrintDesignDefaultFonts = preparePrintDesignDefaultFonts;
|
|
8209
|
+
exports.printDesignAgentTools = printDesignAgentTools;
|
|
7961
8210
|
exports.printPrintDesignHtml = printPrintDesignHtml;
|
|
7962
8211
|
exports.printPrintDesignHtmlInFrame = printPrintDesignHtmlInFrame;
|
|
7963
8212
|
exports.projectTransformPoint = projectTransformPoint;
|
package/dist/index.d.cts
CHANGED
|
@@ -2198,6 +2198,37 @@ declare function getPrintDesignPageSize(page: PrintDesignPage): {
|
|
|
2198
2198
|
height: number;
|
|
2199
2199
|
};
|
|
2200
2200
|
|
|
2201
|
+
/** 与模型服务无关的工具描述,可映射到常见函数调用协议。 */
|
|
2202
|
+
interface PrintDesignAgentToolDefinition {
|
|
2203
|
+
name: string;
|
|
2204
|
+
description: string;
|
|
2205
|
+
parameters: Record<string, unknown>;
|
|
2206
|
+
}
|
|
2207
|
+
/** Agent 仅通过设计器公开命令访问画布,写入保留撤销历史。 */
|
|
2208
|
+
interface PrintDesignAgentApi {
|
|
2209
|
+
tools: readonly PrintDesignAgentToolDefinition[];
|
|
2210
|
+
call(name: string, input: unknown): unknown;
|
|
2211
|
+
}
|
|
2212
|
+
/** 宿主提供已注册组件的创建能力,核心 API 不依赖任何框架适配层。 */
|
|
2213
|
+
interface PrintDesignAgentComponentCatalog {
|
|
2214
|
+
list(): readonly {
|
|
2215
|
+
type: string;
|
|
2216
|
+
label: string;
|
|
2217
|
+
agentCommands?: readonly {
|
|
2218
|
+
name: string;
|
|
2219
|
+
description: string;
|
|
2220
|
+
}[];
|
|
2221
|
+
}[];
|
|
2222
|
+
create(type: string, preset?: string): PrintDesignElementBase;
|
|
2223
|
+
}
|
|
2224
|
+
/** 打印设计器内置的通用 Agent 工具,不包含模型连接、React 或存储。 */
|
|
2225
|
+
declare const printDesignAgentTools: readonly PrintDesignAgentToolDefinition[];
|
|
2226
|
+
/** 创建仅针对当前编辑器实例生效的 Agent API。 */
|
|
2227
|
+
declare function createPrintDesignAgentApi(getInstance: () => PrintDesign | null, options?: {
|
|
2228
|
+
readonly?: () => boolean;
|
|
2229
|
+
componentCatalog?: PrintDesignAgentComponentCatalog;
|
|
2230
|
+
}): PrintDesignAgentApi;
|
|
2231
|
+
|
|
2201
2232
|
/** 核心默认注册表为空,具体组件由插件显式注册。 */
|
|
2202
2233
|
declare const builtinPrintDesignComponentRegistry: PrintDesignComponentRegistry;
|
|
2203
2234
|
|
|
@@ -2273,6 +2304,6 @@ interface PrintDesignRecordCollection {
|
|
|
2273
2304
|
/** 识别包含记录数组的对象,不把普通对象当作数据行。 */
|
|
2274
2305
|
declare function isPrintDesignRecordCollection(value: unknown): value is PrintDesignRecordCollection;
|
|
2275
2306
|
|
|
2276
|
-
var version = "0.1.
|
|
2307
|
+
var version = "0.1.11";
|
|
2277
2308
|
|
|
2278
|
-
export { DEFAULT_PRINT_DESIGN_DEBUG_OPTIONS, type ElementDrawContext, PRINT_DESIGN_CSS_DPI, PRINT_DESIGN_DEFAULT_FONT_FAMILY, PRINT_DESIGN_MM_PER_INCH, PRINT_DESIGN_SCHEMA_VERSION, PRINT_DESIGN_UNIT_MM, version as PRINT_DESIGN_VERSION, PrintDesign, type PrintDesignComponentBoundaryResize, type PrintDesignComponentCellContextTarget, type PrintDesignComponentCellEditor, type PrintDesignComponentCellHit, type PrintDesignComponentCellSelection, type PrintDesignComponentCellSelectionBehavior, type PrintDesignComponentCellSelectionContext, type PrintDesignComponentCellSelectionState, type PrintDesignComponentClickContext, type PrintDesignComponentCommands, type PrintDesignComponentConnection, type PrintDesignComponentCrop, type PrintDesignComponentDebugContext, type PrintDesignComponentDebugRegion, type PrintDesignComponentEditHandleContext, type PrintDesignComponentHandleContext, type PrintDesignComponentHandleDrag, type PrintDesignComponentHitContext, type PrintDesignComponentPathDrawing, type PrintDesignComponentPointerContext, type PrintDesignComponentPointerStroke, PrintDesignComponentRegistry, type PrintDesignComponentRenderer, type PrintDesignComponentResource, type PrintDesignComponentSelectionContext, type PrintDesignComponentSelector, type PrintDesignComponentSelectorDrawContext, type PrintDesignComponentSourceCreate, type PrintDesignConnectionAnchorContext, type PrintDesignConnectionCreateHandle, type PrintDesignCropRect, type PrintDesignDataField, type PrintDesignDebugOptions, type PrintDesignDocument, type PrintDesignElement, type PrintDesignElementBase, type PrintDesignElementTypeMap, type PrintDesignExportOptions, type PrintDesignHtmlOptions, type PrintDesignInlineTextEditor, type PrintDesignInlineTextPresentation, type PrintDesignLayerAlignment, type PrintDesignLayerNode, type PrintDesignOptions, type PrintDesignOrientation, type PrintDesignPage, type PrintDesignPageMargins, type PrintDesignPluginRenderer, type PrintDesignRecordCollection, type PrintDesignSelection, type PrintDesignToolDebugContribution, type PrintDesignToolDebugRegion, type PrintDesignUnit, type TransformPoint, buildPrintDesignLayerTree, builtinPrintDesignComponentRegistry, canvasPointToPageMillimeters, clonePrintDesignDocument, createPrintDesignDocument, createPrintDesignId, createPrintDesignPage, createPrintDesignPrintFrame, cssColor, cssFont, cssNumber, definePrintDesignComponentRenderer, definePrintDesignPluginRenderer, drawPrintDesignElement, drawPrintDesignPage, elementTransformCss, elementTransformHomography, escapeHtml, formatDisplayUnit, fromDisplayUnit, getPrintDesignAlignmentUnits, getPrintDesignDataFields, getPrintDesignDefaultFontUrl, getPrintDesignElementDataConfig, getPrintDesignLatinFontUrl, getPrintDesignPageSize, getPrintDesignSerifFontUrl, getSelectionRect, hitTestPrintDesignPage, inverseTransformPoint, isPrintDesignColorValue, isPrintDesignRecordCollection, materializePrintDesignDocument, millimetersToPixels, paginatePrintDesignDocument, parsePrintDesignDocument, pixelsToMillimeters, preparePrintDesignCanvasPage, preparePrintDesignDefaultFonts, printPrintDesignHtml, printPrintDesignHtmlInFrame, projectTransformPoint, renderPrintDesignHtmlFrame, renderPrintDesignPageToCanvas, resolveDesignText, resolvePrintDesignBinding, resolvePrintDesignDataPath, resolvePrintDesignDebugOptions, resolvePrintDesignElementData, resolvePrintDesignElementVisible, resolvePrintDesignPageVisible, rotatePoint, serializePrintDesignDocument, stringifyPrintDesignBinding, toDisplayUnit, transformPrintDesignToHtml, transformPrintDesignToHtmlAsync, transformPrintDesignToHtmlBatches, transformRect };
|
|
2309
|
+
export { DEFAULT_PRINT_DESIGN_DEBUG_OPTIONS, type ElementDrawContext, PRINT_DESIGN_CSS_DPI, PRINT_DESIGN_DEFAULT_FONT_FAMILY, PRINT_DESIGN_MM_PER_INCH, PRINT_DESIGN_SCHEMA_VERSION, PRINT_DESIGN_UNIT_MM, version as PRINT_DESIGN_VERSION, PrintDesign, type PrintDesignAgentApi, type PrintDesignAgentComponentCatalog, type PrintDesignAgentToolDefinition, type PrintDesignComponentBoundaryResize, type PrintDesignComponentCellContextTarget, type PrintDesignComponentCellEditor, type PrintDesignComponentCellHit, type PrintDesignComponentCellSelection, type PrintDesignComponentCellSelectionBehavior, type PrintDesignComponentCellSelectionContext, type PrintDesignComponentCellSelectionState, type PrintDesignComponentClickContext, type PrintDesignComponentCommands, type PrintDesignComponentConnection, type PrintDesignComponentCrop, type PrintDesignComponentDebugContext, type PrintDesignComponentDebugRegion, type PrintDesignComponentEditHandleContext, type PrintDesignComponentHandleContext, type PrintDesignComponentHandleDrag, type PrintDesignComponentHitContext, type PrintDesignComponentPathDrawing, type PrintDesignComponentPointerContext, type PrintDesignComponentPointerStroke, PrintDesignComponentRegistry, type PrintDesignComponentRenderer, type PrintDesignComponentResource, type PrintDesignComponentSelectionContext, type PrintDesignComponentSelector, type PrintDesignComponentSelectorDrawContext, type PrintDesignComponentSourceCreate, type PrintDesignConnectionAnchorContext, type PrintDesignConnectionCreateHandle, type PrintDesignCropRect, type PrintDesignDataField, type PrintDesignDebugOptions, type PrintDesignDocument, type PrintDesignElement, type PrintDesignElementBase, type PrintDesignElementTypeMap, type PrintDesignExportOptions, type PrintDesignHtmlOptions, type PrintDesignInlineTextEditor, type PrintDesignInlineTextPresentation, type PrintDesignLayerAlignment, type PrintDesignLayerNode, type PrintDesignOptions, type PrintDesignOrientation, type PrintDesignPage, type PrintDesignPageMargins, type PrintDesignPluginRenderer, type PrintDesignRecordCollection, type PrintDesignSelection, type PrintDesignToolDebugContribution, type PrintDesignToolDebugRegion, type PrintDesignUnit, type TransformPoint, buildPrintDesignLayerTree, builtinPrintDesignComponentRegistry, canvasPointToPageMillimeters, clonePrintDesignDocument, createPrintDesignAgentApi, createPrintDesignDocument, createPrintDesignId, createPrintDesignPage, createPrintDesignPrintFrame, cssColor, cssFont, cssNumber, definePrintDesignComponentRenderer, definePrintDesignPluginRenderer, drawPrintDesignElement, drawPrintDesignPage, elementTransformCss, elementTransformHomography, escapeHtml, formatDisplayUnit, fromDisplayUnit, getPrintDesignAlignmentUnits, getPrintDesignDataFields, getPrintDesignDefaultFontUrl, getPrintDesignElementDataConfig, getPrintDesignLatinFontUrl, getPrintDesignPageSize, getPrintDesignSerifFontUrl, getSelectionRect, hitTestPrintDesignPage, inverseTransformPoint, isPrintDesignColorValue, isPrintDesignRecordCollection, materializePrintDesignDocument, millimetersToPixels, paginatePrintDesignDocument, parsePrintDesignDocument, pixelsToMillimeters, preparePrintDesignCanvasPage, preparePrintDesignDefaultFonts, printDesignAgentTools, printPrintDesignHtml, printPrintDesignHtmlInFrame, projectTransformPoint, renderPrintDesignHtmlFrame, renderPrintDesignPageToCanvas, resolveDesignText, resolvePrintDesignBinding, resolvePrintDesignDataPath, resolvePrintDesignDebugOptions, resolvePrintDesignElementData, resolvePrintDesignElementVisible, resolvePrintDesignPageVisible, rotatePoint, serializePrintDesignDocument, stringifyPrintDesignBinding, toDisplayUnit, transformPrintDesignToHtml, transformPrintDesignToHtmlAsync, transformPrintDesignToHtmlBatches, transformRect };
|
package/dist/index.d.ts
CHANGED
|
@@ -2198,6 +2198,37 @@ declare function getPrintDesignPageSize(page: PrintDesignPage): {
|
|
|
2198
2198
|
height: number;
|
|
2199
2199
|
};
|
|
2200
2200
|
|
|
2201
|
+
/** 与模型服务无关的工具描述,可映射到常见函数调用协议。 */
|
|
2202
|
+
interface PrintDesignAgentToolDefinition {
|
|
2203
|
+
name: string;
|
|
2204
|
+
description: string;
|
|
2205
|
+
parameters: Record<string, unknown>;
|
|
2206
|
+
}
|
|
2207
|
+
/** Agent 仅通过设计器公开命令访问画布,写入保留撤销历史。 */
|
|
2208
|
+
interface PrintDesignAgentApi {
|
|
2209
|
+
tools: readonly PrintDesignAgentToolDefinition[];
|
|
2210
|
+
call(name: string, input: unknown): unknown;
|
|
2211
|
+
}
|
|
2212
|
+
/** 宿主提供已注册组件的创建能力,核心 API 不依赖任何框架适配层。 */
|
|
2213
|
+
interface PrintDesignAgentComponentCatalog {
|
|
2214
|
+
list(): readonly {
|
|
2215
|
+
type: string;
|
|
2216
|
+
label: string;
|
|
2217
|
+
agentCommands?: readonly {
|
|
2218
|
+
name: string;
|
|
2219
|
+
description: string;
|
|
2220
|
+
}[];
|
|
2221
|
+
}[];
|
|
2222
|
+
create(type: string, preset?: string): PrintDesignElementBase;
|
|
2223
|
+
}
|
|
2224
|
+
/** 打印设计器内置的通用 Agent 工具,不包含模型连接、React 或存储。 */
|
|
2225
|
+
declare const printDesignAgentTools: readonly PrintDesignAgentToolDefinition[];
|
|
2226
|
+
/** 创建仅针对当前编辑器实例生效的 Agent API。 */
|
|
2227
|
+
declare function createPrintDesignAgentApi(getInstance: () => PrintDesign | null, options?: {
|
|
2228
|
+
readonly?: () => boolean;
|
|
2229
|
+
componentCatalog?: PrintDesignAgentComponentCatalog;
|
|
2230
|
+
}): PrintDesignAgentApi;
|
|
2231
|
+
|
|
2201
2232
|
/** 核心默认注册表为空,具体组件由插件显式注册。 */
|
|
2202
2233
|
declare const builtinPrintDesignComponentRegistry: PrintDesignComponentRegistry;
|
|
2203
2234
|
|
|
@@ -2273,6 +2304,6 @@ interface PrintDesignRecordCollection {
|
|
|
2273
2304
|
/** 识别包含记录数组的对象,不把普通对象当作数据行。 */
|
|
2274
2305
|
declare function isPrintDesignRecordCollection(value: unknown): value is PrintDesignRecordCollection;
|
|
2275
2306
|
|
|
2276
|
-
var version = "0.1.
|
|
2307
|
+
var version = "0.1.11";
|
|
2277
2308
|
|
|
2278
|
-
export { DEFAULT_PRINT_DESIGN_DEBUG_OPTIONS, type ElementDrawContext, PRINT_DESIGN_CSS_DPI, PRINT_DESIGN_DEFAULT_FONT_FAMILY, PRINT_DESIGN_MM_PER_INCH, PRINT_DESIGN_SCHEMA_VERSION, PRINT_DESIGN_UNIT_MM, version as PRINT_DESIGN_VERSION, PrintDesign, type PrintDesignComponentBoundaryResize, type PrintDesignComponentCellContextTarget, type PrintDesignComponentCellEditor, type PrintDesignComponentCellHit, type PrintDesignComponentCellSelection, type PrintDesignComponentCellSelectionBehavior, type PrintDesignComponentCellSelectionContext, type PrintDesignComponentCellSelectionState, type PrintDesignComponentClickContext, type PrintDesignComponentCommands, type PrintDesignComponentConnection, type PrintDesignComponentCrop, type PrintDesignComponentDebugContext, type PrintDesignComponentDebugRegion, type PrintDesignComponentEditHandleContext, type PrintDesignComponentHandleContext, type PrintDesignComponentHandleDrag, type PrintDesignComponentHitContext, type PrintDesignComponentPathDrawing, type PrintDesignComponentPointerContext, type PrintDesignComponentPointerStroke, PrintDesignComponentRegistry, type PrintDesignComponentRenderer, type PrintDesignComponentResource, type PrintDesignComponentSelectionContext, type PrintDesignComponentSelector, type PrintDesignComponentSelectorDrawContext, type PrintDesignComponentSourceCreate, type PrintDesignConnectionAnchorContext, type PrintDesignConnectionCreateHandle, type PrintDesignCropRect, type PrintDesignDataField, type PrintDesignDebugOptions, type PrintDesignDocument, type PrintDesignElement, type PrintDesignElementBase, type PrintDesignElementTypeMap, type PrintDesignExportOptions, type PrintDesignHtmlOptions, type PrintDesignInlineTextEditor, type PrintDesignInlineTextPresentation, type PrintDesignLayerAlignment, type PrintDesignLayerNode, type PrintDesignOptions, type PrintDesignOrientation, type PrintDesignPage, type PrintDesignPageMargins, type PrintDesignPluginRenderer, type PrintDesignRecordCollection, type PrintDesignSelection, type PrintDesignToolDebugContribution, type PrintDesignToolDebugRegion, type PrintDesignUnit, type TransformPoint, buildPrintDesignLayerTree, builtinPrintDesignComponentRegistry, canvasPointToPageMillimeters, clonePrintDesignDocument, createPrintDesignDocument, createPrintDesignId, createPrintDesignPage, createPrintDesignPrintFrame, cssColor, cssFont, cssNumber, definePrintDesignComponentRenderer, definePrintDesignPluginRenderer, drawPrintDesignElement, drawPrintDesignPage, elementTransformCss, elementTransformHomography, escapeHtml, formatDisplayUnit, fromDisplayUnit, getPrintDesignAlignmentUnits, getPrintDesignDataFields, getPrintDesignDefaultFontUrl, getPrintDesignElementDataConfig, getPrintDesignLatinFontUrl, getPrintDesignPageSize, getPrintDesignSerifFontUrl, getSelectionRect, hitTestPrintDesignPage, inverseTransformPoint, isPrintDesignColorValue, isPrintDesignRecordCollection, materializePrintDesignDocument, millimetersToPixels, paginatePrintDesignDocument, parsePrintDesignDocument, pixelsToMillimeters, preparePrintDesignCanvasPage, preparePrintDesignDefaultFonts, printPrintDesignHtml, printPrintDesignHtmlInFrame, projectTransformPoint, renderPrintDesignHtmlFrame, renderPrintDesignPageToCanvas, resolveDesignText, resolvePrintDesignBinding, resolvePrintDesignDataPath, resolvePrintDesignDebugOptions, resolvePrintDesignElementData, resolvePrintDesignElementVisible, resolvePrintDesignPageVisible, rotatePoint, serializePrintDesignDocument, stringifyPrintDesignBinding, toDisplayUnit, transformPrintDesignToHtml, transformPrintDesignToHtmlAsync, transformPrintDesignToHtmlBatches, transformRect };
|
|
2309
|
+
export { DEFAULT_PRINT_DESIGN_DEBUG_OPTIONS, type ElementDrawContext, PRINT_DESIGN_CSS_DPI, PRINT_DESIGN_DEFAULT_FONT_FAMILY, PRINT_DESIGN_MM_PER_INCH, PRINT_DESIGN_SCHEMA_VERSION, PRINT_DESIGN_UNIT_MM, version as PRINT_DESIGN_VERSION, PrintDesign, type PrintDesignAgentApi, type PrintDesignAgentComponentCatalog, type PrintDesignAgentToolDefinition, type PrintDesignComponentBoundaryResize, type PrintDesignComponentCellContextTarget, type PrintDesignComponentCellEditor, type PrintDesignComponentCellHit, type PrintDesignComponentCellSelection, type PrintDesignComponentCellSelectionBehavior, type PrintDesignComponentCellSelectionContext, type PrintDesignComponentCellSelectionState, type PrintDesignComponentClickContext, type PrintDesignComponentCommands, type PrintDesignComponentConnection, type PrintDesignComponentCrop, type PrintDesignComponentDebugContext, type PrintDesignComponentDebugRegion, type PrintDesignComponentEditHandleContext, type PrintDesignComponentHandleContext, type PrintDesignComponentHandleDrag, type PrintDesignComponentHitContext, type PrintDesignComponentPathDrawing, type PrintDesignComponentPointerContext, type PrintDesignComponentPointerStroke, PrintDesignComponentRegistry, type PrintDesignComponentRenderer, type PrintDesignComponentResource, type PrintDesignComponentSelectionContext, type PrintDesignComponentSelector, type PrintDesignComponentSelectorDrawContext, type PrintDesignComponentSourceCreate, type PrintDesignConnectionAnchorContext, type PrintDesignConnectionCreateHandle, type PrintDesignCropRect, type PrintDesignDataField, type PrintDesignDebugOptions, type PrintDesignDocument, type PrintDesignElement, type PrintDesignElementBase, type PrintDesignElementTypeMap, type PrintDesignExportOptions, type PrintDesignHtmlOptions, type PrintDesignInlineTextEditor, type PrintDesignInlineTextPresentation, type PrintDesignLayerAlignment, type PrintDesignLayerNode, type PrintDesignOptions, type PrintDesignOrientation, type PrintDesignPage, type PrintDesignPageMargins, type PrintDesignPluginRenderer, type PrintDesignRecordCollection, type PrintDesignSelection, type PrintDesignToolDebugContribution, type PrintDesignToolDebugRegion, type PrintDesignUnit, type TransformPoint, buildPrintDesignLayerTree, builtinPrintDesignComponentRegistry, canvasPointToPageMillimeters, clonePrintDesignDocument, createPrintDesignAgentApi, createPrintDesignDocument, createPrintDesignId, createPrintDesignPage, createPrintDesignPrintFrame, cssColor, cssFont, cssNumber, definePrintDesignComponentRenderer, definePrintDesignPluginRenderer, drawPrintDesignElement, drawPrintDesignPage, elementTransformCss, elementTransformHomography, escapeHtml, formatDisplayUnit, fromDisplayUnit, getPrintDesignAlignmentUnits, getPrintDesignDataFields, getPrintDesignDefaultFontUrl, getPrintDesignElementDataConfig, getPrintDesignLatinFontUrl, getPrintDesignPageSize, getPrintDesignSerifFontUrl, getSelectionRect, hitTestPrintDesignPage, inverseTransformPoint, isPrintDesignColorValue, isPrintDesignRecordCollection, materializePrintDesignDocument, millimetersToPixels, paginatePrintDesignDocument, parsePrintDesignDocument, pixelsToMillimeters, preparePrintDesignCanvasPage, preparePrintDesignDefaultFonts, printDesignAgentTools, printPrintDesignHtml, printPrintDesignHtmlInFrame, projectTransformPoint, renderPrintDesignHtmlFrame, renderPrintDesignPageToCanvas, resolveDesignText, resolvePrintDesignBinding, resolvePrintDesignDataPath, resolvePrintDesignDebugOptions, resolvePrintDesignElementData, resolvePrintDesignElementVisible, resolvePrintDesignPageVisible, rotatePoint, serializePrintDesignDocument, stringifyPrintDesignBinding, toDisplayUnit, transformPrintDesignToHtml, transformPrintDesignToHtmlAsync, transformPrintDesignToHtmlBatches, transformRect };
|
package/dist/index.js
CHANGED
|
@@ -2039,8 +2039,8 @@ async function* transformPrintDesignToHtmlBatches(document2, options) {
|
|
|
2039
2039
|
}
|
|
2040
2040
|
|
|
2041
2041
|
// src/helper/group-resize.ts
|
|
2042
|
-
function groupSelectionBounds(elements,
|
|
2043
|
-
const boxes = elements.filter((item) =>
|
|
2042
|
+
function groupSelectionBounds(elements, ids2, data = {}, componentRegistry) {
|
|
2043
|
+
const boxes = elements.filter((item) => ids2.includes(item.id) && item.visible !== false).map((element) => elementBounds(element, data, componentRegistry));
|
|
2044
2044
|
if (boxes.length < 2) return;
|
|
2045
2045
|
const x = Math.min(...boxes.map((box) => box.x)), y = Math.min(...boxes.map((box) => box.y));
|
|
2046
2046
|
return {
|
|
@@ -2169,9 +2169,9 @@ function groupMembers(elements, id) {
|
|
|
2169
2169
|
const groupId = element.groupPath?.[0]?.id;
|
|
2170
2170
|
return groupId ? elements.filter((item) => item.groupPath?.[0]?.id === groupId) : [element];
|
|
2171
2171
|
}
|
|
2172
|
-
function expandGroupSelection(elements,
|
|
2172
|
+
function expandGroupSelection(elements, ids2) {
|
|
2173
2173
|
const selected = new Set(
|
|
2174
|
-
|
|
2174
|
+
ids2.flatMap((id) => groupMembers(elements, id).map((item) => item.id))
|
|
2175
2175
|
);
|
|
2176
2176
|
return elements.filter((item) => selected.has(item.id)).map((item) => item.id);
|
|
2177
2177
|
}
|
|
@@ -4903,10 +4903,10 @@ var PrintDesignInteraction = class extends PrintDesignRenderer {
|
|
|
4903
4903
|
if (!this.componentCellSelection(previewComponent))
|
|
4904
4904
|
this.componentCellSelectionState = null;
|
|
4905
4905
|
} else this.componentCellSelectionState = null;
|
|
4906
|
-
const
|
|
4906
|
+
const ids2 = groupMembers(source.page.elements, source.element.id).map(
|
|
4907
4907
|
(item) => item.id
|
|
4908
4908
|
);
|
|
4909
|
-
this.selectedElementIds =
|
|
4909
|
+
this.selectedElementIds = ids2;
|
|
4910
4910
|
this.emitSelection();
|
|
4911
4911
|
this.canvas.setPointerCapture?.(event.pointerId);
|
|
4912
4912
|
this.dragSession = {
|
|
@@ -4916,7 +4916,7 @@ var PrintDesignInteraction = class extends PrintDesignRenderer {
|
|
|
4916
4916
|
startClient: { x: event.clientX, y: event.clientY },
|
|
4917
4917
|
documentBefore: clonePrintDesignDocument(this.document),
|
|
4918
4918
|
elementPositions: new Map(
|
|
4919
|
-
source.page.elements.filter((item) =>
|
|
4919
|
+
source.page.elements.filter((item) => ids2.includes(item.id)).map((item) => [item.id, { x: item.x, y: item.y }])
|
|
4920
4920
|
),
|
|
4921
4921
|
changed: false
|
|
4922
4922
|
};
|
|
@@ -5545,7 +5545,7 @@ var PrintDesignInteraction = class extends PrintDesignRenderer {
|
|
|
5545
5545
|
const left = Math.min(point.x, session.start.x), top = Math.min(point.y, session.start.y);
|
|
5546
5546
|
const right = Math.max(point.x, session.start.x), bottom = Math.max(point.y, session.start.y);
|
|
5547
5547
|
const page2 = this.getActivePage();
|
|
5548
|
-
const
|
|
5548
|
+
const ids2 = new Set(session.marquee.initialIds);
|
|
5549
5549
|
for (const element of page2.elements) {
|
|
5550
5550
|
if (element.visible === false) continue;
|
|
5551
5551
|
const bounds = elementBounds(
|
|
@@ -5555,9 +5555,9 @@ var PrintDesignInteraction = class extends PrintDesignRenderer {
|
|
|
5555
5555
|
);
|
|
5556
5556
|
if (bounds.x <= right && bounds.y <= bottom && bounds.x + bounds.width >= left && bounds.y + bounds.height >= top)
|
|
5557
5557
|
for (const member of groupMembers(page2.elements, element.id))
|
|
5558
|
-
|
|
5558
|
+
ids2.add(member.id);
|
|
5559
5559
|
}
|
|
5560
|
-
this.selectedElementIds = [...
|
|
5560
|
+
this.selectedElementIds = [...ids2];
|
|
5561
5561
|
this.emitSelection();
|
|
5562
5562
|
this.render();
|
|
5563
5563
|
return;
|
|
@@ -6918,8 +6918,8 @@ var PrintDesignGrouping = class extends PrintDesignInteraction {
|
|
|
6918
6918
|
groupElements(elementIds = this.selectedElementIds) {
|
|
6919
6919
|
if (this.options.readonly) return this;
|
|
6920
6920
|
const elements = this.getActivePage().elements;
|
|
6921
|
-
const
|
|
6922
|
-
const members = elements.filter((item) =>
|
|
6921
|
+
const ids2 = expandGroupSelection(elements, elementIds);
|
|
6922
|
+
const members = elements.filter((item) => ids2.includes(item.id));
|
|
6923
6923
|
const units = new Set(
|
|
6924
6924
|
members.map((item) => item.groupPath?.[0]?.id ?? item.id)
|
|
6925
6925
|
);
|
|
@@ -6927,41 +6927,41 @@ var PrintDesignGrouping = class extends PrintDesignInteraction {
|
|
|
6927
6927
|
const group = { id: createPrintDesignId("group"), name: "\u7EC4\u5408" };
|
|
6928
6928
|
this.commitMutation((document2) => {
|
|
6929
6929
|
const page = this.getPageIn(document2);
|
|
6930
|
-
const selected = page.elements.filter((item) =>
|
|
6930
|
+
const selected = page.elements.filter((item) => ids2.includes(item.id));
|
|
6931
6931
|
const highest = Math.max(
|
|
6932
6932
|
...selected.map((item) => page.elements.indexOf(item))
|
|
6933
6933
|
);
|
|
6934
|
-
const before = page.elements.slice(0, highest + 1).filter((item) => !
|
|
6934
|
+
const before = page.elements.slice(0, highest + 1).filter((item) => !ids2.includes(item.id));
|
|
6935
6935
|
const after = page.elements.slice(highest + 1);
|
|
6936
6936
|
selected.forEach((item) => {
|
|
6937
6937
|
item.groupPath = [group, ...item.groupPath ?? []];
|
|
6938
6938
|
});
|
|
6939
6939
|
page.elements = [...before, ...selected, ...after];
|
|
6940
6940
|
});
|
|
6941
|
-
return this.selectElements(
|
|
6941
|
+
return this.selectElements(ids2);
|
|
6942
6942
|
}
|
|
6943
6943
|
/** 取消选中组合的最外层,保留其内部嵌套组合。 */
|
|
6944
6944
|
ungroupElements(elementIds = this.selectedElementIds) {
|
|
6945
6945
|
if (this.options.readonly) return this;
|
|
6946
|
-
const
|
|
6946
|
+
const ids2 = expandGroupSelection(this.getActivePage().elements, elementIds);
|
|
6947
6947
|
if (this.getActivePage().elements.some(
|
|
6948
|
-
(item) =>
|
|
6948
|
+
(item) => ids2.includes(item.id) && item.locked
|
|
6949
6949
|
))
|
|
6950
6950
|
return this;
|
|
6951
6951
|
this.commitMutation((document2) => {
|
|
6952
6952
|
for (const item of this.getPageIn(document2).elements) {
|
|
6953
|
-
if (!
|
|
6953
|
+
if (!ids2.includes(item.id) || !item.groupPath?.length) continue;
|
|
6954
6954
|
item.groupPath = item.groupPath.slice(1);
|
|
6955
6955
|
if (!item.groupPath.length) delete item.groupPath;
|
|
6956
6956
|
}
|
|
6957
6957
|
});
|
|
6958
|
-
return this.selectElements(
|
|
6958
|
+
return this.selectElements(ids2);
|
|
6959
6959
|
}
|
|
6960
6960
|
};
|
|
6961
6961
|
|
|
6962
6962
|
// src/helper/layer-alignment.ts
|
|
6963
|
-
function getPrintDesignAlignmentUnits(elements,
|
|
6964
|
-
const selected = new Set(
|
|
6963
|
+
function getPrintDesignAlignmentUnits(elements, ids2) {
|
|
6964
|
+
const selected = new Set(ids2);
|
|
6965
6965
|
const groups = /* @__PURE__ */ new Map();
|
|
6966
6966
|
for (const element of elements)
|
|
6967
6967
|
for (const group of element.groupPath ?? []) {
|
|
@@ -6983,8 +6983,8 @@ function getPrintDesignAlignmentUnits(elements, ids) {
|
|
|
6983
6983
|
}
|
|
6984
6984
|
return units;
|
|
6985
6985
|
}
|
|
6986
|
-
function alignPrintDesignLayers(page,
|
|
6987
|
-
const units = getPrintDesignAlignmentUnits(page.elements,
|
|
6986
|
+
function alignPrintDesignLayers(page, ids2, align, data = {}, componentRegistry) {
|
|
6987
|
+
const units = getPrintDesignAlignmentUnits(page.elements, ids2);
|
|
6988
6988
|
if (!units.length || units.some((unit) => unit.some((item) => item.locked)))
|
|
6989
6989
|
return;
|
|
6990
6990
|
const boxes = units.map((unit) => {
|
|
@@ -7254,7 +7254,7 @@ var PrintDesignActions = class extends PrintDesignGrouping {
|
|
|
7254
7254
|
/** 设置选区锁定或显隐状态。 */
|
|
7255
7255
|
setSelectionState(patch) {
|
|
7256
7256
|
if (this.options.readonly) return this;
|
|
7257
|
-
const
|
|
7257
|
+
const ids2 = new Set(
|
|
7258
7258
|
expandGroupSelection(
|
|
7259
7259
|
this.getActivePage().elements,
|
|
7260
7260
|
this.selectedElementIds
|
|
@@ -7262,17 +7262,17 @@ var PrintDesignActions = class extends PrintDesignGrouping {
|
|
|
7262
7262
|
);
|
|
7263
7263
|
this.commitMutation((document2) => {
|
|
7264
7264
|
for (const item of this.getPageIn(document2).elements)
|
|
7265
|
-
if (
|
|
7265
|
+
if (ids2.has(item.id)) Object.assign(item, patch);
|
|
7266
7266
|
});
|
|
7267
7267
|
return this;
|
|
7268
7268
|
}
|
|
7269
7269
|
/** 精确设置指定图层状态;组合节点由调用方传入全部成员,一次操作对应一次撤销。 */
|
|
7270
7270
|
setElementsState(elementIds, patch) {
|
|
7271
7271
|
if (this.options.readonly) return this;
|
|
7272
|
-
const
|
|
7272
|
+
const ids2 = new Set(elementIds);
|
|
7273
7273
|
this.commitMutation((document2) => {
|
|
7274
7274
|
for (const item of this.getPageIn(document2).elements)
|
|
7275
|
-
if (
|
|
7275
|
+
if (ids2.has(item.id)) Object.assign(item, patch);
|
|
7276
7276
|
});
|
|
7277
7277
|
return this;
|
|
7278
7278
|
}
|
|
@@ -7289,7 +7289,7 @@ var PrintDesignActions = class extends PrintDesignGrouping {
|
|
|
7289
7289
|
moveSelectionLayer(direction) {
|
|
7290
7290
|
if (this.options.readonly || this.selectedElements().some((item) => item.locked))
|
|
7291
7291
|
return this;
|
|
7292
|
-
const
|
|
7292
|
+
const ids2 = new Set(this.selectedElementIds);
|
|
7293
7293
|
this.commitMutation((document2) => {
|
|
7294
7294
|
const page = this.getPageIn(document2);
|
|
7295
7295
|
const units = [];
|
|
@@ -7300,7 +7300,7 @@ var PrintDesignActions = class extends PrintDesignGrouping {
|
|
|
7300
7300
|
members.forEach((member) => seen.add(member.id));
|
|
7301
7301
|
units.push(members);
|
|
7302
7302
|
}
|
|
7303
|
-
const selected = (unit) => unit.some((item) =>
|
|
7303
|
+
const selected = (unit) => unit.some((item) => ids2.has(item.id));
|
|
7304
7304
|
if (direction === "front" || direction === "back") {
|
|
7305
7305
|
const picked = units.filter(selected), rest = units.filter((unit) => !selected(unit));
|
|
7306
7306
|
page.elements = (direction === "front" ? [...rest, ...picked] : [...picked, ...rest]).flat();
|
|
@@ -7647,18 +7647,18 @@ var PrintDesign = class extends PrintDesignActions {
|
|
|
7647
7647
|
/** 一次重置选中组件的通用和组件专属变形。 */
|
|
7648
7648
|
resetElementTransforms(elementIds = this.selectedElementIds) {
|
|
7649
7649
|
if (!elementIds.length) return this;
|
|
7650
|
-
const
|
|
7650
|
+
const ids2 = new Set(elementIds);
|
|
7651
7651
|
const targets = this.getActivePage().elements.filter(
|
|
7652
|
-
(element) =>
|
|
7652
|
+
(element) => ids2.has(element.id)
|
|
7653
7653
|
);
|
|
7654
7654
|
if (targets.some((element) => element.groupPath?.length)) return this;
|
|
7655
7655
|
if (!targets.some(
|
|
7656
|
-
(element) =>
|
|
7656
|
+
(element) => ids2.has(element.id) && !element.locked && this.hasElementTransform(element)
|
|
7657
7657
|
))
|
|
7658
7658
|
return this;
|
|
7659
7659
|
this.commitMutation((document2) => {
|
|
7660
7660
|
for (const element of this.getPageIn(document2).elements) {
|
|
7661
|
-
if (!
|
|
7661
|
+
if (!ids2.has(element.id) || element.locked) continue;
|
|
7662
7662
|
element.transform = void 0;
|
|
7663
7663
|
this.options.componentRegistry?.get(element.type)?.transformReset?.reset(element);
|
|
7664
7664
|
}
|
|
@@ -7668,25 +7668,25 @@ var PrintDesign = class extends PrintDesignActions {
|
|
|
7668
7668
|
/** 删除当前选区或指定元素。 */
|
|
7669
7669
|
removeElements(elementIds = this.selectedElementIds) {
|
|
7670
7670
|
if (!elementIds.length) return this;
|
|
7671
|
-
const
|
|
7671
|
+
const ids2 = new Set(
|
|
7672
7672
|
expandGroupSelection(this.getActivePage().elements, elementIds)
|
|
7673
7673
|
);
|
|
7674
7674
|
this.commitMutation((document2) => {
|
|
7675
7675
|
const page = this.getPageIn(document2);
|
|
7676
7676
|
const componentRegistry = this.options.componentRegistry ?? builtinPrintDesignComponentRegistry;
|
|
7677
7677
|
for (const element of page.elements) {
|
|
7678
|
-
if (
|
|
7678
|
+
if (ids2.has(element.id)) continue;
|
|
7679
7679
|
componentRegistry.get(element.type)?.onElementsRemoved?.(element, {
|
|
7680
7680
|
page,
|
|
7681
|
-
removedIds:
|
|
7681
|
+
removedIds: ids2,
|
|
7682
7682
|
data: this.options.data ?? {},
|
|
7683
7683
|
componentRegistry
|
|
7684
7684
|
});
|
|
7685
7685
|
}
|
|
7686
|
-
page.elements = page.elements.filter((element) => !
|
|
7686
|
+
page.elements = page.elements.filter((element) => !ids2.has(element.id));
|
|
7687
7687
|
});
|
|
7688
7688
|
this.selectedElementIds = this.selectedElementIds.filter(
|
|
7689
|
-
(id) => !
|
|
7689
|
+
(id) => !ids2.has(id)
|
|
7690
7690
|
);
|
|
7691
7691
|
this.emitSelection();
|
|
7692
7692
|
this.render();
|
|
@@ -7899,12 +7899,259 @@ function getPrintDesignPageSize(page) {
|
|
|
7899
7899
|
return { width: page.width, height: page.height };
|
|
7900
7900
|
}
|
|
7901
7901
|
|
|
7902
|
+
// src/agent/agent-api.ts
|
|
7903
|
+
var objectSchema = (properties, required = []) => ({
|
|
7904
|
+
type: "object",
|
|
7905
|
+
properties,
|
|
7906
|
+
required,
|
|
7907
|
+
additionalProperties: false
|
|
7908
|
+
});
|
|
7909
|
+
var idSchema = { type: "string", minLength: 1 };
|
|
7910
|
+
var idsSchema = { type: "array", items: idSchema, minItems: 1 };
|
|
7911
|
+
var printDesignAgentTools = [
|
|
7912
|
+
{
|
|
7913
|
+
name: "get_document",
|
|
7914
|
+
description: "\u8BFB\u53D6\u5F53\u524D\u6253\u5370\u8BBE\u8BA1\u6587\u6863\u3002\u9875\u9762\u5C3A\u5BF8\u548C\u5143\u7D20\u5750\u6807\u5355\u4F4D\u4E3A\u6BEB\u7C73\u3002",
|
|
7915
|
+
parameters: objectSchema({})
|
|
7916
|
+
},
|
|
7917
|
+
{
|
|
7918
|
+
name: "get_selection",
|
|
7919
|
+
description: "\u8BFB\u53D6\u5F53\u524D\u6D3B\u52A8\u9875\u548C\u9009\u4E2D\u7684\u5143\u7D20 ID\u3002",
|
|
7920
|
+
parameters: objectSchema({})
|
|
7921
|
+
},
|
|
7922
|
+
{
|
|
7923
|
+
name: "list_components",
|
|
7924
|
+
description: "\u5217\u51FA\u5BBF\u4E3B\u5DF2\u6CE8\u518C\u7684\u7EC4\u4EF6\u7C7B\u578B\uFF1B\u65B0\u589E\u8868\u683C\u7B49\u63D2\u4EF6\u7EC4\u4EF6\u524D\u5148\u67E5\u770B\u6B64\u5217\u8868\u3002",
|
|
7925
|
+
parameters: objectSchema({})
|
|
7926
|
+
},
|
|
7927
|
+
{
|
|
7928
|
+
name: "get_component_template",
|
|
7929
|
+
description: "\u8BFB\u53D6\u5DF2\u6CE8\u518C\u7EC4\u4EF6\u7684\u9ED8\u8BA4\u5143\u7D20\u548C\u53EF\u7528\u547D\u4EE4\uFF1B\u521B\u5EFA\u6216\u4FEE\u6539\u590D\u6742\u7EC4\u4EF6\u524D\u5148\u67E5\u770B\u3002",
|
|
7930
|
+
parameters: objectSchema({ type: idSchema, preset: { type: "string" } }, [
|
|
7931
|
+
"type"
|
|
7932
|
+
])
|
|
7933
|
+
},
|
|
7934
|
+
{
|
|
7935
|
+
name: "get_element",
|
|
7936
|
+
description: "\u8BFB\u53D6\u5F53\u524D\u9875\u6307\u5B9A\u5143\u7D20\u7684\u5B8C\u6574\u914D\u7F6E\u3002",
|
|
7937
|
+
parameters: objectSchema({ elementId: idSchema }, ["elementId"])
|
|
7938
|
+
},
|
|
7939
|
+
{
|
|
7940
|
+
name: "set_active_page",
|
|
7941
|
+
description: "\u5207\u6362\u5F53\u524D\u6D3B\u52A8\u9875\u3002",
|
|
7942
|
+
parameters: objectSchema({ pageId: idSchema }, ["pageId"])
|
|
7943
|
+
},
|
|
7944
|
+
{
|
|
7945
|
+
name: "select_elements",
|
|
7946
|
+
description: "\u5728\u5F53\u524D\u9875\u9009\u4E2D\u5143\u7D20\u3002",
|
|
7947
|
+
parameters: objectSchema({ elementIds: idsSchema }, ["elementIds"])
|
|
7948
|
+
},
|
|
7949
|
+
{
|
|
7950
|
+
name: "add_element",
|
|
7951
|
+
description: "\u5728\u5F53\u524D\u9875\u65B0\u589E\u5143\u7D20\u3002\u4F20\u5165 type \u548C\u9700\u8981\u8986\u76D6\u7684\u5B57\u6BB5\uFF1B\u5DF2\u6CE8\u518C\u7EC4\u4EF6\u4F1A\u81EA\u52A8\u8865\u9F50\u5DE5\u5382\u9ED8\u8BA4\u503C\uFF0C\u590D\u6742\u7EC4\u4EF6\u8BF7\u5148\u8BFB\u53D6\u6A21\u677F\u3002",
|
|
7952
|
+
parameters: objectSchema({ element: { type: "object" } }, ["element"])
|
|
7953
|
+
},
|
|
7954
|
+
{
|
|
7955
|
+
name: "update_element",
|
|
7956
|
+
description: "\u66F4\u65B0\u5F53\u524D\u9875\u6307\u5B9A\u5143\u7D20\u7684\u5C5E\u6027\uFF1B\u4E0D\u80FD\u4FEE\u6539 id \u6216 type\u3002",
|
|
7957
|
+
parameters: objectSchema(
|
|
7958
|
+
{ elementId: idSchema, patch: { type: "object" } },
|
|
7959
|
+
["elementId", "patch"]
|
|
7960
|
+
)
|
|
7961
|
+
},
|
|
7962
|
+
{
|
|
7963
|
+
name: "remove_elements",
|
|
7964
|
+
description: "\u5220\u9664\u5F53\u524D\u9875\u6307\u5B9A\u5143\u7D20\u3002",
|
|
7965
|
+
parameters: objectSchema({ elementIds: idsSchema }, ["elementIds"])
|
|
7966
|
+
},
|
|
7967
|
+
{
|
|
7968
|
+
name: "execute_component_command",
|
|
7969
|
+
description: "\u6267\u884C\u7EC4\u4EF6\u6CE8\u518C\u7684\u547D\u4EE4\uFF0C\u4F8B\u5982\u8868\u683C\u63D2\u5165\u884C\u5217\u6216\u5408\u5E76\u5355\u5143\u683C\uFF1B\u5148\u8BFB\u53D6\u7EC4\u4EF6\u6A21\u677F\u4E2D\u7684\u547D\u4EE4\u5217\u8868\u3002",
|
|
7970
|
+
parameters: objectSchema(
|
|
7971
|
+
{
|
|
7972
|
+
elementId: idSchema,
|
|
7973
|
+
command: idSchema,
|
|
7974
|
+
payload: { type: "object" }
|
|
7975
|
+
},
|
|
7976
|
+
["elementId", "command", "payload"]
|
|
7977
|
+
)
|
|
7978
|
+
},
|
|
7979
|
+
{
|
|
7980
|
+
name: "undo",
|
|
7981
|
+
description: "\u64A4\u9500\u4E0A\u4E00\u6B65\u7F16\u8F91\u3002",
|
|
7982
|
+
parameters: objectSchema({})
|
|
7983
|
+
},
|
|
7984
|
+
{
|
|
7985
|
+
name: "redo",
|
|
7986
|
+
description: "\u91CD\u505A\u4E0A\u4E00\u6B65\u7F16\u8F91\u3002",
|
|
7987
|
+
parameters: objectSchema({})
|
|
7988
|
+
}
|
|
7989
|
+
];
|
|
7990
|
+
function record(input) {
|
|
7991
|
+
if (!input || typeof input !== "object" || Array.isArray(input))
|
|
7992
|
+
throw new TypeError("\u5DE5\u5177\u53C2\u6570\u5FC5\u987B\u662F\u5BF9\u8C61\u3002");
|
|
7993
|
+
return input;
|
|
7994
|
+
}
|
|
7995
|
+
function string(input, name) {
|
|
7996
|
+
if (typeof input !== "string" || !input.trim())
|
|
7997
|
+
throw new TypeError(`${name} \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32\u3002`);
|
|
7998
|
+
return input;
|
|
7999
|
+
}
|
|
8000
|
+
function ids(input) {
|
|
8001
|
+
if (!Array.isArray(input) || !input.length)
|
|
8002
|
+
throw new TypeError("elementIds \u5FC5\u987B\u662F\u975E\u7A7A\u6570\u7EC4\u3002");
|
|
8003
|
+
return input.map((id) => string(id, "elementId"));
|
|
8004
|
+
}
|
|
8005
|
+
function safeJson(input, depth = 0) {
|
|
8006
|
+
if (depth > 20) throw new RangeError("\u5DE5\u5177\u53C2\u6570\u5D4C\u5957\u8FC7\u6DF1\u3002");
|
|
8007
|
+
if (input === null || typeof input === "string" || typeof input === "boolean")
|
|
8008
|
+
return;
|
|
8009
|
+
if (typeof input === "number" && Number.isFinite(input)) return;
|
|
8010
|
+
if (Array.isArray(input)) {
|
|
8011
|
+
if (input.length > 1e4) throw new RangeError("\u5DE5\u5177\u6570\u7EC4\u8FC7\u957F\u3002");
|
|
8012
|
+
input.forEach((item) => safeJson(item, depth + 1));
|
|
8013
|
+
return;
|
|
8014
|
+
}
|
|
8015
|
+
if (!input || typeof input !== "object")
|
|
8016
|
+
throw new TypeError("\u5DE5\u5177\u53C2\u6570\u5FC5\u987B\u662F JSON \u6570\u636E\u3002");
|
|
8017
|
+
const entries = Object.entries(input);
|
|
8018
|
+
if (entries.length > 1e3) throw new RangeError("\u5DE5\u5177\u5BF9\u8C61\u5B57\u6BB5\u8FC7\u591A\u3002");
|
|
8019
|
+
for (const [key, value] of entries) {
|
|
8020
|
+
if (["__proto__", "prototype", "constructor"].includes(key))
|
|
8021
|
+
throw new TypeError("\u5DE5\u5177\u53C2\u6570\u5305\u542B\u975E\u6CD5\u5B57\u6BB5\u3002");
|
|
8022
|
+
safeJson(value, depth + 1);
|
|
8023
|
+
}
|
|
8024
|
+
}
|
|
8025
|
+
function createPrintDesignAgentApi(getInstance, options = {}) {
|
|
8026
|
+
return {
|
|
8027
|
+
tools: printDesignAgentTools,
|
|
8028
|
+
call(name, input) {
|
|
8029
|
+
const instance = getInstance();
|
|
8030
|
+
if (!instance) throw new Error("\u6253\u5370\u8BBE\u8BA1\u5668\u5C1A\u672A\u5C31\u7EEA\u3002");
|
|
8031
|
+
const args = record(input);
|
|
8032
|
+
safeJson(args);
|
|
8033
|
+
if (name === "get_document") return instance.getDocument();
|
|
8034
|
+
if (name === "get_selection") return instance.getSelection();
|
|
8035
|
+
if (name === "list_components")
|
|
8036
|
+
return options.componentCatalog?.list().map(({ type, label }) => ({
|
|
8037
|
+
type,
|
|
8038
|
+
label
|
|
8039
|
+
})) ?? [];
|
|
8040
|
+
if (name === "get_component_template") {
|
|
8041
|
+
const type = string(args.type, "type");
|
|
8042
|
+
const factory = options.componentCatalog?.list().find((item) => item.type === type);
|
|
8043
|
+
if (!factory || !options.componentCatalog)
|
|
8044
|
+
throw new Error(`\u672A\u6CE8\u518C\u7EC4\u4EF6\u521B\u5EFA\u5668\uFF1A${type}`);
|
|
8045
|
+
const preset = args.preset === void 0 ? void 0 : string(args.preset, "preset");
|
|
8046
|
+
const { id: _ignored, ...element } = options.componentCatalog.create(
|
|
8047
|
+
type,
|
|
8048
|
+
preset
|
|
8049
|
+
);
|
|
8050
|
+
return {
|
|
8051
|
+
type,
|
|
8052
|
+
label: factory.label,
|
|
8053
|
+
element,
|
|
8054
|
+
commands: factory.agentCommands ?? []
|
|
8055
|
+
};
|
|
8056
|
+
}
|
|
8057
|
+
if (name === "get_element") {
|
|
8058
|
+
const elementId = string(args.elementId, "elementId");
|
|
8059
|
+
const found = instance.getDocument().pages.find((item) => item.id === instance.getActivePageId())?.elements.find((item) => item.id === elementId);
|
|
8060
|
+
if (!found) throw new Error(`\u627E\u4E0D\u5230\u5143\u7D20\uFF1A${elementId}`);
|
|
8061
|
+
return found;
|
|
8062
|
+
}
|
|
8063
|
+
if (options.readonly?.()) throw new Error("\u5F53\u524D\u8BBE\u8BA1\u5668\u4E3A\u53EA\u8BFB\u72B6\u6001\u3002");
|
|
8064
|
+
const document2 = instance.getDocument();
|
|
8065
|
+
const page = document2.pages.find(
|
|
8066
|
+
(item) => item.id === instance.getActivePageId()
|
|
8067
|
+
);
|
|
8068
|
+
if (name === "set_active_page") {
|
|
8069
|
+
const pageId = string(args.pageId, "pageId");
|
|
8070
|
+
if (!document2.pages.some((item) => item.id === pageId))
|
|
8071
|
+
throw new Error(`\u627E\u4E0D\u5230\u9875\u9762\uFF1A${pageId}`);
|
|
8072
|
+
instance.setActivePage(pageId);
|
|
8073
|
+
return instance.getSelection();
|
|
8074
|
+
}
|
|
8075
|
+
if (name === "select_elements") {
|
|
8076
|
+
const elementIds = ids(args.elementIds);
|
|
8077
|
+
if (elementIds.some((id) => !page.elements.some((item) => item.id === id)))
|
|
8078
|
+
throw new Error("\u5F53\u524D\u9875\u4E0D\u5B58\u5728\u6307\u5B9A\u5143\u7D20\u3002");
|
|
8079
|
+
instance.selectElements(elementIds);
|
|
8080
|
+
return instance.getSelection();
|
|
8081
|
+
}
|
|
8082
|
+
if (name === "add_element") {
|
|
8083
|
+
const element = record(args.element);
|
|
8084
|
+
const type = string(element.type, "type");
|
|
8085
|
+
const { id: _ignored, ...fields } = element;
|
|
8086
|
+
const defaults = options.componentCatalog?.list().some((item) => item.type === type) ? options.componentCatalog.create(type) : null;
|
|
8087
|
+
if (options.componentCatalog && !defaults)
|
|
8088
|
+
throw new Error(`\u672A\u6CE8\u518C\u7EC4\u4EF6\u521B\u5EFA\u5668\uFF1A${type}`);
|
|
8089
|
+
const { id: _defaultId, ...defaultFields } = defaults ?? {};
|
|
8090
|
+
const id = instance.addElement({
|
|
8091
|
+
...defaultFields,
|
|
8092
|
+
...fields
|
|
8093
|
+
});
|
|
8094
|
+
return { id };
|
|
8095
|
+
}
|
|
8096
|
+
if (name === "update_element") {
|
|
8097
|
+
const elementId = string(args.elementId, "elementId");
|
|
8098
|
+
const target = page.elements.find((item) => item.id === elementId);
|
|
8099
|
+
if (!target) throw new Error(`\u627E\u4E0D\u5230\u5143\u7D20\uFF1A${elementId}`);
|
|
8100
|
+
if (target.locked) throw new Error(`\u5143\u7D20\u5DF2\u9501\u5B9A\uFF1A${elementId}`);
|
|
8101
|
+
const patch = record(args.patch);
|
|
8102
|
+
if ("id" in patch || "type" in patch)
|
|
8103
|
+
throw new TypeError("\u4E0D\u80FD\u4FEE\u6539\u5143\u7D20 id \u6216 type\u3002");
|
|
8104
|
+
instance.updateElement(elementId, patch);
|
|
8105
|
+
return { elementId };
|
|
8106
|
+
}
|
|
8107
|
+
if (name === "remove_elements") {
|
|
8108
|
+
const elementIds = ids(args.elementIds);
|
|
8109
|
+
if (elementIds.some((id) => !page.elements.some((item) => item.id === id)))
|
|
8110
|
+
throw new Error("\u5F53\u524D\u9875\u4E0D\u5B58\u5728\u6307\u5B9A\u5143\u7D20\u3002");
|
|
8111
|
+
if (page.elements.some(
|
|
8112
|
+
(item) => elementIds.includes(item.id) && item.locked
|
|
8113
|
+
))
|
|
8114
|
+
throw new Error("\u4E0D\u80FD\u5220\u9664\u5DF2\u9501\u5B9A\u5143\u7D20\u3002");
|
|
8115
|
+
instance.removeElements(elementIds);
|
|
8116
|
+
return { removed: elementIds };
|
|
8117
|
+
}
|
|
8118
|
+
if (name === "execute_component_command") {
|
|
8119
|
+
const elementId = string(args.elementId, "elementId");
|
|
8120
|
+
const command = string(args.command, "command");
|
|
8121
|
+
const target = page.elements.find((item) => item.id === elementId);
|
|
8122
|
+
if (!target) throw new Error(`\u627E\u4E0D\u5230\u5143\u7D20\uFF1A${elementId}`);
|
|
8123
|
+
if (target.locked) throw new Error(`\u5143\u7D20\u5DF2\u9501\u5B9A\uFF1A${elementId}`);
|
|
8124
|
+
const definitions = options.componentCatalog?.list().find((item) => item.type === target.type)?.agentCommands;
|
|
8125
|
+
if (definitions && !definitions.some((item) => item.name === command))
|
|
8126
|
+
throw new Error(`\u7EC4\u4EF6\u4E0D\u652F\u6301\u547D\u4EE4\uFF1A${command}`);
|
|
8127
|
+
const payload = record(args.payload);
|
|
8128
|
+
instance.executeComponentCommand(elementId, command, payload);
|
|
8129
|
+
const updated = instance.getDocument().pages.find((item) => item.id === page.id)?.elements.find((item) => item.id === elementId);
|
|
8130
|
+
return {
|
|
8131
|
+
elementId,
|
|
8132
|
+
command,
|
|
8133
|
+
applied: JSON.stringify(updated) !== JSON.stringify(target)
|
|
8134
|
+
};
|
|
8135
|
+
}
|
|
8136
|
+
if (name === "undo") {
|
|
8137
|
+
instance.undo();
|
|
8138
|
+
return { canUndo: instance.canUndo(), canRedo: instance.canRedo() };
|
|
8139
|
+
}
|
|
8140
|
+
if (name === "redo") {
|
|
8141
|
+
instance.redo();
|
|
8142
|
+
return { canUndo: instance.canUndo(), canRedo: instance.canRedo() };
|
|
8143
|
+
}
|
|
8144
|
+
throw new Error(`\u672A\u77E5 Agent \u5DE5\u5177\uFF1A${name}`);
|
|
8145
|
+
}
|
|
8146
|
+
};
|
|
8147
|
+
}
|
|
8148
|
+
|
|
7902
8149
|
// src/model/collection-data.ts
|
|
7903
8150
|
function isPrintDesignRecordCollection(value) {
|
|
7904
8151
|
return !!value && typeof value === "object" && !Array.isArray(value) && Array.isArray(value.dataSource);
|
|
7905
8152
|
}
|
|
7906
8153
|
|
|
7907
8154
|
// package.json
|
|
7908
|
-
var version = "0.1.
|
|
8155
|
+
var version = "0.1.11";
|
|
7909
8156
|
|
|
7910
|
-
export { DEFAULT_PRINT_DESIGN_DEBUG_OPTIONS, PRINT_DESIGN_CSS_DPI, PRINT_DESIGN_DEFAULT_FONT_FAMILY, PRINT_DESIGN_MM_PER_INCH, PRINT_DESIGN_SCHEMA_VERSION, PRINT_DESIGN_UNIT_MM, version as PRINT_DESIGN_VERSION, PrintDesign, PrintDesignComponentRegistry, buildPrintDesignLayerTree, builtinPrintDesignComponentRegistry, canvasPointToPageMillimeters, clonePrintDesignDocument, createPrintDesignDocument, createPrintDesignId, createPrintDesignPage, createPrintDesignPrintFrame, cssColor, cssFont, cssNumber, definePrintDesignComponentRenderer, definePrintDesignPluginRenderer, drawPrintDesignElement, drawPrintDesignPage, elementTransformCss, elementTransformHomography, escapeHtml, formatDisplayUnit, fromDisplayUnit, getPrintDesignAlignmentUnits, getPrintDesignDataFields, getPrintDesignDefaultFontUrl, getPrintDesignElementDataConfig, getPrintDesignLatinFontUrl, getPrintDesignPageSize, getPrintDesignSerifFontUrl, getSelectionRect, hitTestPrintDesignPage, inverseTransformPoint, isPrintDesignColorValue, isPrintDesignRecordCollection, materializePrintDesignDocument, millimetersToPixels, paginatePrintDesignDocument, parsePrintDesignDocument, pixelsToMillimeters, preparePrintDesignCanvasPage, preparePrintDesignDefaultFonts, printPrintDesignHtml, printPrintDesignHtmlInFrame, projectTransformPoint, renderPrintDesignHtmlFrame, renderPrintDesignPageToCanvas, resolveDesignText, resolvePrintDesignBinding, resolvePrintDesignDataPath, resolvePrintDesignDebugOptions, resolvePrintDesignElementData, resolvePrintDesignElementVisible, resolvePrintDesignPageVisible, rotatePoint2 as rotatePoint, serializePrintDesignDocument, stringifyPrintDesignBinding, toDisplayUnit, transformPrintDesignToHtml, transformPrintDesignToHtmlAsync, transformPrintDesignToHtmlBatches, transformRect };
|
|
8157
|
+
export { DEFAULT_PRINT_DESIGN_DEBUG_OPTIONS, PRINT_DESIGN_CSS_DPI, PRINT_DESIGN_DEFAULT_FONT_FAMILY, PRINT_DESIGN_MM_PER_INCH, PRINT_DESIGN_SCHEMA_VERSION, PRINT_DESIGN_UNIT_MM, version as PRINT_DESIGN_VERSION, PrintDesign, PrintDesignComponentRegistry, buildPrintDesignLayerTree, builtinPrintDesignComponentRegistry, canvasPointToPageMillimeters, clonePrintDesignDocument, createPrintDesignAgentApi, createPrintDesignDocument, createPrintDesignId, createPrintDesignPage, createPrintDesignPrintFrame, cssColor, cssFont, cssNumber, definePrintDesignComponentRenderer, definePrintDesignPluginRenderer, drawPrintDesignElement, drawPrintDesignPage, elementTransformCss, elementTransformHomography, escapeHtml, formatDisplayUnit, fromDisplayUnit, getPrintDesignAlignmentUnits, getPrintDesignDataFields, getPrintDesignDefaultFontUrl, getPrintDesignElementDataConfig, getPrintDesignLatinFontUrl, getPrintDesignPageSize, getPrintDesignSerifFontUrl, getSelectionRect, hitTestPrintDesignPage, inverseTransformPoint, isPrintDesignColorValue, isPrintDesignRecordCollection, materializePrintDesignDocument, millimetersToPixels, paginatePrintDesignDocument, parsePrintDesignDocument, pixelsToMillimeters, preparePrintDesignCanvasPage, preparePrintDesignDefaultFonts, printDesignAgentTools, printPrintDesignHtml, printPrintDesignHtmlInFrame, projectTransformPoint, renderPrintDesignHtmlFrame, renderPrintDesignPageToCanvas, resolveDesignText, resolvePrintDesignBinding, resolvePrintDesignDataPath, resolvePrintDesignDebugOptions, resolvePrintDesignElementData, resolvePrintDesignElementVisible, resolvePrintDesignPageVisible, rotatePoint2 as rotatePoint, serializePrintDesignDocument, stringifyPrintDesignBinding, toDisplayUnit, transformPrintDesignToHtml, transformPrintDesignToHtmlAsync, transformPrintDesignToHtmlBatches, transformRect };
|