@canvas-components/print-design 0.1.4 → 0.1.9

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/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  原生 Canvas 打印设计核心。文档和元素尺寸使用毫米保存,页面预览按 CSS 像素绘制,导出时可指定 DPI。此包不依赖 React。
4
4
 
5
+ 插件编写指南按打印设计版本存放在 [插件指南目录](./docs/plugins/README.md)。当前 `vnext` 内容是设计草案,现有版本尚未提供插件注册 API。
6
+
5
7
  ## 安装
6
8
 
7
9
  ```bash
@@ -35,11 +37,11 @@ design.addElement({
35
37
  fontSize: 18,
36
38
  });
37
39
 
38
- const pngCanvas = design.exportPageToCanvas(undefined, { dpi: 300 });
40
+ const pngCanvas = await design.exportPageToCanvasAsync(undefined, { dpi: 300 });
39
41
  design.destroy();
40
42
  ```
41
43
 
42
- `PrintDesign` 提供页面和元素增删改、选区、撤销重做、JSON 文档读写、PNG Canvas/Blob 导出及浏览器打印方法。图片使用浏览器可访问的 URL 或 data URL;跨域图片需要来源服务器允许 Canvas 读取。
44
+ `PrintDesign` 提供页面和元素增删改、选区、撤销重做、JSON 文档读写、PNG Canvas/Blob 导出及浏览器打印方法。`exportPageToCanvasAsync` 和 `exportPageToBlob` 会等待插件的图片、字体等资源完成准备;同步 `exportPageToCanvas` 仅适用于无需等待资源的页面。图片使用浏览器可访问的 URL 或 data URL;跨域图片需要来源服务器允许 Canvas 读取。
43
45
 
44
46
  连接线使用 `type: "connector"`。`start` 和 `end` 可通过 `elementId` 绑定页面上的组件,`anchor` 可选择 `auto`、四边中点、四角,或多边形的 `edge:0` / `vertex:0` 等控制点。`lineType` 支持 `straight`、`curve`、`polyline`;还可设置 `stroke`、`strokeWidth`、`arrowSize`、`showStartArrow`、`showEndArrow`、`text` 和沿线比例 `textPosition`。连接线可经过其他组件,由元素层级决定显示在组件上方或下方;绑定组件移动后路径会自动重新计算。React 设计器里拖动连接线端点可吸附到组件边缘控制点,拖动线上文本可调整位置。
45
47
  选中单个组件后,拖动四边的加号可创建绑定起点的连接线;拖到目标组件内部或边缘控制点时自动绑定终点。拖动期间的创建操作作为一次历史记录,支持撤销。
@@ -88,7 +90,7 @@ design.destroy();
88
90
 
89
91
  图表元素可设置 `chartData`:`mode: "static"` 使用 `categories` 和 `series[].values`;`mode: "binding"` 从实例 `data` 的 `source` 数组路径读取记录,以 `categoryField` 生成分类、`series[].field` 读取数值。路径支持点路径和数组索引(例如 `orders[0].items`),数值字符串可自动转换,缺失或非数值按 0 处理。切换模式保留静态数据。
90
92
 
91
- 画布、导出与打印使用同一份绑定结果,导出时可通过 `exportPageToCanvas(pageId, { data })` 覆盖实例数据。饼图、环形图、雷达图与仪表盘使用单个 `option.series` 对象,兼容历史模板中的单项数组写法。
93
+ 画布、导出与打印使用同一份绑定结果,导出时可通过 `exportPageToCanvasAsync(pageId, { data })` 覆盖实例数据并等待插件资源。饼图、环形图、雷达图与仪表盘使用单个 `option.series` 对象,兼容历史模板中的单项数组写法。
92
94
 
93
95
  ### 画布文本编辑
94
96
 
@@ -96,10 +98,12 @@ design.destroy();
96
98
 
97
99
  ### 表格组件
98
100
 
99
- 表格元素 `type: "table"` 复用 `list-table` 原生布局和绘制链路。`columns` 直接采用 `ListTableColumn<Record<string, unknown>>[]` 的声明式配置,支持嵌套表头、字段路径、`cellType`、金额格式、列样式与汇总;打印文档必须使用可 JSON 序列化的数据,不包含 `render`、`onCell` 等函数。
101
+ 表格元素由 `@canvas-components/print-design-plugin` 的 table 插件提供;`columns` 使用插件的 `TableColumn[]` 声明式配置,支持嵌套表头、字段路径、`cellType`、金额格式、列样式与汇总。打印文档必须使用可 JSON 序列化的数据,不包含 `render`、`onCell` 等函数。
100
102
 
101
103
  ```ts
102
- const table: PrintDesignTableElement = {
104
+ import type { TableElement } from "@canvas-components/print-design-plugin/native";
105
+
106
+ const table: TableElement = {
103
107
  id: "order-table",
104
108
  type: "table",
105
109
  x: 10,
@@ -143,7 +147,7 @@ const table: PrintDesignTableElement = {
143
147
 
144
148
  静态数据表格支持双击数据单元格原位编辑:Enter / Tab 或失焦保存,Esc 取消,Shift+Enter 换行,支持输入法与撤销重做。数值、布尔和 JSON 字段保留原类型并校验输入;表头、汇总行、绑定数据、锁定和只读表格不进入编辑。
145
149
 
146
- 设计画布选中表格后绘制行号、列字母和左上角全选选择器。`selectTableSelector` 可选择整行、整列或全表;`insertTableRow` 向静态数据插入空行,`insertTableColumn` 在可见叶列旁插入新列。插入时会移动或扩展已有手动合并区域,并纳入撤销历史。
150
+ 设计画布选中表格后绘制行号、列字母和左上角全选选择器。`selectComponentSelector` 可选择整行、整列或全表;`insertTableRow` 向静态数据插入空行,`insertTableColumn` 在可见叶列旁插入新列。插入时会移动或扩展已有手动合并区域,并纳入撤销历史。
147
151
 
148
152
  辅助线图层选中后可在右侧属性面板精确设置毫米位置(允许负数和纸张外坐标),位置修改支持撤销重做。原生 API 为 `updateGuide(axis, index, position)`。面板同时提供方向与参照边说明、删除及全局辅助线外观/吸附设置。
149
153
 
@@ -161,4 +165,4 @@ const table: PrintDesignTableElement = {
161
165
 
162
166
  ### ListTable 记录集与图表接入
163
167
 
164
- 传入 `data` 的命名字段可使用 `PrintDesignTableDataSource`(`dataSource` + 可选 `columns`)或原生 `ListTableChartData`(`labels`、`keys`、`series[].data`)。表格的 `dataPath` 可直接指向记录集对象,图表的 `chartData.source` 可指向记录集或已转换的图表数据;直接图表源不需要 `categoryField`/系列字段映射。原始数组绑定继续兼容。框架适配层无需被原生核心引用。
168
+ 传入 `data` 的命名字段可使用 `PrintDesignRecordCollection`(`dataSource` + 可选 `columns`)或原生 `ListTableChartData`(`labels`、`keys`、`series[].data`)。表格的 `dataPath` 可直接指向记录集对象,图表的 `chartData.source` 可指向记录集或已转换的图表数据;直接图表源不需要 `categoryField`/系列字段映射。原始数组绑定继续兼容。框架适配层无需被原生核心引用。
Binary file
@@ -0,0 +1,93 @@
1
+ Copyright 2026 The Arimo Project Authors (https://github.com/googlefonts/arimo)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ https://openfontlicense.org
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -0,0 +1,93 @@
1
+ Copyright 2014-2021 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ https://scripts.sil.org/OFL
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file
@@ -0,0 +1,93 @@
1
+ Copyright 2026 The Tinos Project Authors (https://github.com/googlefonts/tinos)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ https://openfontlicense.org
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.