@hankchen/canvas-editor 0.5.0 → 0.6.0
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.d.ts +190 -37
- package/dist/index.js +196 -45
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -295,6 +295,31 @@ declare function resizeBox(start: ResizeBoxGeometry, handle: ResizeHandle, dx: n
|
|
|
295
295
|
* 缩放期跟随动缘即可)。
|
|
296
296
|
*/
|
|
297
297
|
declare function resizeSnapPoints(start: ResizeBoxGeometry, handle: ResizeHandle, dx: number, dy: number): SnapPoints;
|
|
298
|
+
/** 等比缩放的驱动轴(image-ratio-preset 工单 01):角柄取位移较大轴(|Δx| ≥
|
|
299
|
+
* |Δy| 宽驱动,画拉比例钳同门)、边中柄恒取被拖轴。几何求位与吸附位点消费
|
|
300
|
+
* 同一判定(resizeBoxProportional 与 resizeProportionalSnapPoints 共读)。 */
|
|
301
|
+
type ProportionalDrivingAxis = 'width' | 'height';
|
|
302
|
+
declare function proportionalDrivingAxis(handle: ResizeHandle, dx: number, dy: number): ProportionalDrivingAxis;
|
|
303
|
+
/**
|
|
304
|
+
* Shift 等比缩放求位(image-ratio-preset 工单 01,spec 决策 5):参照 reference
|
|
305
|
+
* (手势起始盒的声明宽高比)保持宽高比——驱动维随指针(对缘/对角固定语义与
|
|
306
|
+
* resizeBox 同款),钳到 minSize 后派生维随动 = round(驱动维 × 短比)(Math.round
|
|
307
|
+
* 对正数 half-up);派生维同样钳 minSize(极扁/极窄盒派生维可 round 到 0,不钳
|
|
308
|
+
* 会产出零尺寸不可见层)。仅接受双轴皆可写的柄(beginResize 的角色过滤已保证,
|
|
309
|
+
* 派生轴写不出去的面不该进等比模式)。driving 由调用方经 proportionalDrivingAxis
|
|
310
|
+
* 判定一次传入——与吸附位点(resizeProportionalSnapPoints)消费同一判定,吸附
|
|
311
|
+
* 修正并入位移后驱动轴不随修正值翻转(单一事实源)。
|
|
312
|
+
*/
|
|
313
|
+
declare function resizeBoxProportional(start: ResizeBoxGeometry, handle: ResizeHandle, reference: {
|
|
314
|
+
w: number;
|
|
315
|
+
h: number;
|
|
316
|
+
}, driving: ProportionalDrivingAxis, dx: number, dy: number, minSize?: number): ResizeBoxResult;
|
|
317
|
+
/**
|
|
318
|
+
* 等比缩放的吸附位点:只收驱动轴的移动缘——派生维是算术产物,不独立吸附
|
|
319
|
+
* (钳先于吸附同门:吸附修正施加在驱动轴位移上,进 resizeBoxProportional 后
|
|
320
|
+
* 派生维按比例跟随,吸附不破比例)。
|
|
321
|
+
*/
|
|
322
|
+
declare function resizeProportionalSnapPoints(start: ResizeBoxGeometry, handle: ResizeHandle, driving: ProportionalDrivingAxis, dx: number, dy: number): SnapPoints;
|
|
298
323
|
/** 可缩放轴(width = 横向宽字段可写、height = 纵向高字段可写) */
|
|
299
324
|
interface ResizeAxes {
|
|
300
325
|
readonly width: boolean;
|
|
@@ -491,6 +516,46 @@ declare const TEXT_PRESETS: readonly {
|
|
|
491
516
|
}[];
|
|
492
517
|
/** 新层样式槽初值:自工厂 TextLayer 形态派生(工厂缺省是单一事实源,槽跟着走) */
|
|
493
518
|
declare function defaultNextTextStyle(): NextTextStyle;
|
|
519
|
+
/**
|
|
520
|
+
* 建层比例档位(spec 决策 1/2):'free' = 自由钳(工厂行为兜底),其余五个具名
|
|
521
|
+
* 有理数比。v1 固定清单、无自定义输入。
|
|
522
|
+
*/
|
|
523
|
+
type RatioPresetId = 'free' | '1:1' | '4:3' | '3:4' | '16:9' | '9:16';
|
|
524
|
+
/** 比例预设档位:具名 id + 有理数宽高比(free 档 ratio = null,即不钳) */
|
|
525
|
+
interface RatioPreset {
|
|
526
|
+
readonly id: RatioPresetId;
|
|
527
|
+
readonly ratio: Readonly<{
|
|
528
|
+
w: number;
|
|
529
|
+
h: number;
|
|
530
|
+
}> | null;
|
|
531
|
+
}
|
|
532
|
+
/** 比例预设常量六档(顺序即面板平铺序:自由在前,其余按惯例短比在前) */
|
|
533
|
+
declare const RATIO_PRESETS: readonly RatioPreset[];
|
|
534
|
+
/** 建层比例槽初值:自由(工厂画拉行为兜底) */
|
|
535
|
+
declare function defaultNextLayerRatio(): RatioPresetId;
|
|
536
|
+
/** 档位 → 钳制用有理数比:'free' → null(不钳),具名档 → {w, h} 副本 */
|
|
537
|
+
declare function ratioValue(id: RatioPresetId): {
|
|
538
|
+
w: number;
|
|
539
|
+
h: number;
|
|
540
|
+
} | null;
|
|
541
|
+
/**
|
|
542
|
+
* 建层比例槽的宽容读(prefs 恢复唯一入口):六档枚举值原样收,其余(旧快照
|
|
543
|
+
* 缺字段/存储端脏值)回落 'free'。载荷来自宿主 JSON 快照,类型层的形状信任
|
|
544
|
+
* 不了,运行时验;未知 prefs 键由调用方整体忽略(不进本函数视野)。
|
|
545
|
+
*/
|
|
546
|
+
declare function pickNextLayerRatio(raw: unknown): RatioPresetId;
|
|
547
|
+
/**
|
|
548
|
+
* 死区点击缺省盒的比例派生(spec 决策 3):长边 200 定短边——短边 = round(长边
|
|
549
|
+
* × 短比)(Math.round 对正数 half-up:16:9 → 200×113)。自由档不进本函数
|
|
550
|
+
* (调用方以 ratioValue 为 null 分流到工厂缺省 200×150)。
|
|
551
|
+
*/
|
|
552
|
+
declare function defaultSizeForRatio(ratio: {
|
|
553
|
+
w: number;
|
|
554
|
+
h: number;
|
|
555
|
+
}): {
|
|
556
|
+
width: number;
|
|
557
|
+
height: number;
|
|
558
|
+
};
|
|
494
559
|
/**
|
|
495
560
|
* 新层样式字段的宽容读逐字段收口(text-defaults 工单 01;评审合流——捕获与
|
|
496
561
|
* prefs 恢复共用同一谓词,不再双写):合法字段进合并集,缺字/类型不符忽略
|
|
@@ -514,10 +579,16 @@ declare function createDefaultLayer(type: LayerType, textDefaults?: Partial<Next
|
|
|
514
579
|
* 高按解码归一为 0、宽 := 表宽关 autoWidth)+ 满宽 60 高缺省格带缺省文本内容
|
|
515
580
|
* (内容宽度同步、零高度耦合,ADR 0006)。rowsPath 由调用方必填(解码
|
|
516
581
|
* rows_path_missing 硬约束,创建表单校验前置);缺省格 60 高保证空态预览行可见
|
|
517
|
-
* 可点(合成高 = 最高格,03 票 E1 机制)。
|
|
582
|
+
* 可点(合成高 = 最高格,03 票 E1 机制)。shape(template-table-drag-create 工单
|
|
583
|
+
* 01):画拉建层的手势矩形尺寸参数化——表壳宽高照落,行模板/格/内容宽 := 表宽
|
|
584
|
+
* 的既有耦合自然生效;缺省 400×120 不变。
|
|
518
585
|
*/
|
|
519
586
|
declare function createTemplateTable(options: {
|
|
520
587
|
rowsPath: string;
|
|
588
|
+
shape?: {
|
|
589
|
+
width: number;
|
|
590
|
+
height: number;
|
|
591
|
+
};
|
|
521
592
|
}): TableLayer;
|
|
522
593
|
/**
|
|
523
594
|
* 「insert-before 原始序号 to」移动的公共守卫与落点折算:from/to 须为安全整数、
|
|
@@ -817,6 +888,13 @@ interface ResizeGesture {
|
|
|
817
888
|
interface CreateGesture {
|
|
818
889
|
/** 本次画拉的层型(beginLayerCreate 时从 armedCreate 捕获,会话内定死) */
|
|
819
890
|
type: LayerType;
|
|
891
|
+
/**
|
|
892
|
+
* 模板表风味的行路径载荷(canvas-web-template-table-drag-create 工单 01):
|
|
893
|
+
* beginLayerCreate 时从 ui.armedCreateRowsPath 捕获(会话内定死),非空串 =
|
|
894
|
+
* 模板表风味(endCreate 分派 createTemplateTable);undefined = 普通武装
|
|
895
|
+
* (G 快捷键 V1 空表语义原样)。
|
|
896
|
+
*/
|
|
897
|
+
templateRowsPath?: string;
|
|
820
898
|
/** 起点场景坐标(两点正规化与死区判定基准) */
|
|
821
899
|
startScene: Point;
|
|
822
900
|
/** 当前指针场景坐标 */
|
|
@@ -879,6 +957,14 @@ interface EditorUi {
|
|
|
879
957
|
* 解除。无粘性工具态(spec 决策 2);openDocument 重置。
|
|
880
958
|
*/
|
|
881
959
|
armedCreate: LayerType | null;
|
|
960
|
+
/**
|
|
961
|
+
* 武装 token 的模板表风味载荷(canvas-web-template-table-drag-create 工单 01):
|
|
962
|
+
* 行路径表单确认即武装(spec 决策 3)——armedCreate === 'TableLayer' 且本载荷
|
|
963
|
+
* 非空串 = 模板表风味(endCreate 按风味分派 createTemplateTable);空串 = 普通
|
|
964
|
+
* 表武装(G 快捷键语义不受染指)。rowsPath 是 ui 瞬态载荷——不进 graph、
|
|
965
|
+
* 不进 wire(红线 3 延伸),beginLayerCreate 捕获进建层会话;openDocument 重置。
|
|
966
|
+
*/
|
|
967
|
+
armedCreateRowsPath: string;
|
|
882
968
|
/** 进行中的画拉建层橡皮筋会话(拖拽期纯视觉,文档零变更);null = 无 */
|
|
883
969
|
create: CreateGesture | null;
|
|
884
970
|
/** 进行中的文本编辑会话;null = 非编辑态 */
|
|
@@ -902,6 +988,16 @@ interface EditorUi {
|
|
|
902
988
|
* 置,永不进历史;随工程数据 prefs 桶跨会话持久(宿主通道,内核零 localStorage)。
|
|
903
989
|
*/
|
|
904
990
|
nextTextStyle: NextTextStyle;
|
|
991
|
+
/**
|
|
992
|
+
* 建层比例槽(image-ratio-preset 工单 01,CONTEXT「建层比例」词条):记忆
|
|
993
|
+
* 「下一个新建图片层用什么宽高比」的编辑器级偏好——六档、缺省自由,仅
|
|
994
|
+
* ImageLayer 消费(QR 恒方是层型硬钳,其余层型无此槽)。比例预设的应用 =
|
|
995
|
+
* 写槽再武装画拉(armLayerCreate),普通图片层项/快捷键 I 不带 preset、武装
|
|
996
|
+
* 后按槽值钳制——槽是唯一偏好源。与锚点折叠同款的面板偏好——openDocument
|
|
997
|
+
* 换文档不重置,永不进历史;随工程数据 prefs 桶跨会话持久(宿主通道,内核
|
|
998
|
+
* 零 localStorage)。
|
|
999
|
+
*/
|
|
1000
|
+
nextLayerRatio: RatioPresetId;
|
|
905
1001
|
/**
|
|
906
1002
|
* 数据源 schema 声明(content-completion 工单 03/08,D2 宿主随会话注入):
|
|
907
1003
|
* 编译产物形状树或降级 null(根级结构性拒绝,注入期经
|
|
@@ -999,7 +1095,7 @@ declare class EditorStore {
|
|
|
999
1095
|
get canRedo(): boolean;
|
|
1000
1096
|
/** 打开/替换文档:ui 选择/编辑/重命名会话与双向历史一并重置(新文档不继承旧路径/旧事务);
|
|
1001
1097
|
* 参考线/锁定集合/查找会话/建层武装与画拉会话随当次会话清空(对位轴/文档内容防护/
|
|
1002
|
-
*
|
|
1098
|
+
* 查询词/待命层型不跨文档),标尺显隐/锚点折叠/新层样式/建层比例作为偏好保留 */
|
|
1003
1099
|
openDocument(canvas: Canvas): void;
|
|
1004
1100
|
/**
|
|
1005
1101
|
* 文档事务唯一入口:produceWithPatches 求新树,无变化即空转(不进历史不通知);
|
|
@@ -1029,8 +1125,13 @@ declare class EditorStore {
|
|
|
1029
1125
|
setDrag(gesture: DragGesture | null): void;
|
|
1030
1126
|
/** 缩放会话开始/结束(null,工单 07);会话对象住 ui 分支,文档只收缩放事务 */
|
|
1031
1127
|
setResize(gesture: ResizeGesture | null): void;
|
|
1032
|
-
/**
|
|
1033
|
-
|
|
1128
|
+
/**
|
|
1129
|
+
* 建层武装置/解除(null,drag-create 工单 01);标量值等短路(重复武装同型
|
|
1130
|
+
* 不通知)。rowsPath(template-table-drag-create 工单 01):模板表风味载荷
|
|
1131
|
+
* 与层型一体写——同层型同载荷才短路(重复武装同型换载荷要更新),解除
|
|
1132
|
+
* (null)一律清载荷。
|
|
1133
|
+
*/
|
|
1134
|
+
setArmedCreate(type: LayerType | null, rowsPath?: string): void;
|
|
1034
1135
|
/** 画拉橡皮筋会话开始/更新/结束(null);会话对象住 ui 分支,落库在 endCreate 单事务 */
|
|
1035
1136
|
setCreate(gesture: CreateGesture | null): void;
|
|
1036
1137
|
/** 文本编辑会话开始/结束(null);会话住 ui 分支,文本经 commitTextEdit 一次性落文档 */
|
|
@@ -1044,6 +1145,11 @@ declare class EditorStore {
|
|
|
1044
1145
|
* 写入口):patch 并入现值,五字段值等短路(重复写同值零通知),不进历史。
|
|
1045
1146
|
*/
|
|
1046
1147
|
setNextTextStyle(patch: Partial<NextTextStyle>): void;
|
|
1148
|
+
/**
|
|
1149
|
+
* 建层比例槽写入(image-ratio-preset 工单 01:比例预设应用 / prefs 恢复的
|
|
1150
|
+
* 统一写入口):值等短路(重复写同档零通知),仅 ui 通知、不进历史。
|
|
1151
|
+
*/
|
|
1152
|
+
setNextLayerRatio(id: RatioPresetId): void;
|
|
1047
1153
|
/**
|
|
1048
1154
|
* 数据源 schema 声明替换(归一产物或降级 null,校验收口在注入缝不在这里):
|
|
1049
1155
|
* 同引用短路(重复注入同一归一产物不惊动订阅方);仅 ui 通知,不参与重绘
|
|
@@ -1184,6 +1290,12 @@ interface EditorPrefsState {
|
|
|
1184
1290
|
* 由 applyEditorPrefs 宽容读兜底为现值(会话内即工厂缺省)。
|
|
1185
1291
|
*/
|
|
1186
1292
|
nextTextStyle: NextTextStyle;
|
|
1293
|
+
/**
|
|
1294
|
+
* 建层比例槽(image-ratio-preset 工单 01,CONTEXT「建层比例」词条):随 prefs
|
|
1295
|
+
* 桶跨会话持久(per-模板记忆,「自由」即显式重置档)。schemaVersion 不升——
|
|
1296
|
+
* 加法演进,旧快照缺字段或脏值由 applyEditorPrefs 宽容读回落 'free'。
|
|
1297
|
+
*/
|
|
1298
|
+
nextLayerRatio: RatioPresetId;
|
|
1187
1299
|
}
|
|
1188
1300
|
|
|
1189
1301
|
/**
|
|
@@ -1583,8 +1695,17 @@ declare class EditorSession {
|
|
|
1583
1695
|
*
|
|
1584
1696
|
* 拖不动写不动的同门守卫:无会话、目标层被结构编辑移除(悬空路径)整体
|
|
1585
1697
|
* 空转(不发事务、不发布命中轴)。
|
|
1698
|
+
*
|
|
1699
|
+
* Shift 等比(image-ratio-preset 工单 01,spec 决策 5):仅 ImageLayer 生效
|
|
1700
|
+
* (其余层型 shift 空转走现状——自适应与尺寸耦合面不被触碰),且须双轴皆在
|
|
1701
|
+
* 可缩放面(格内容等强同步面派生轴写不出去,不进等比模式)、起始盒零维空转
|
|
1702
|
+
* (无比例可参照,回落自由)。参照手势起始盒实际宽高比;驱动轴 = 角柄取位
|
|
1703
|
+
* 移较大轴、边中柄取被拖轴;派生维 = round(驱动维 × 短比)(钳后驱动维跟随,
|
|
1704
|
+
* 最小钳位随动);对缘/对角固定照旧;吸附只在驱动轴移动缘候选(派生轴是算
|
|
1705
|
+
* 术产物不独立吸附,钳先于吸附同门)。等比模式双轴都落声明值(派生轴写算
|
|
1706
|
+
* 术积并清 auto 标志),canonicalize 以驱动轴键收口。
|
|
1586
1707
|
*/
|
|
1587
|
-
resizeTo(sceneX: number, sceneY: number): void;
|
|
1708
|
+
resizeTo(sceneX: number, sceneY: number, shift?: boolean): void;
|
|
1588
1709
|
/**
|
|
1589
1710
|
* 结束缩放:闭合合并事务(下一步历史定格),会话态与命中轴回显清空。
|
|
1590
1711
|
* 无会话空转(幂等,pointercancel 与 pointerup 双路同达)。
|
|
@@ -1595,14 +1716,27 @@ declare class EditorSession {
|
|
|
1595
1716
|
* 分支待命层型,下一次画布按下即开画拉;建层提交或 Esc 即解除——一次性
|
|
1596
1717
|
* 待命态,无粘性工具(spec 决策 2)。重复武装同型值等短路零通知。
|
|
1597
1718
|
*
|
|
1598
|
-
* preset(text-defaults 工单 01
|
|
1599
|
-
*
|
|
1600
|
-
*
|
|
1601
|
-
*
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1719
|
+
* preset(text-defaults 工单 01 + image-ratio-preset 工单 01):层型相关预设 =
|
|
1720
|
+
* 写槽的快捷方式——命中档位先把档位值并入对应偏好槽再武装;未知 id = 跳过
|
|
1721
|
+
* 写槽、武装照常(评审口径统一:「空转」只指写槽,武装层型本身仍合法)。
|
|
1722
|
+
* - TextLayer + 文本预设档:写新层样式槽(v1 只 fontSize);
|
|
1723
|
+
* - ImageLayer + 比例预设档:写建层比例槽('free' 即显式重置档);QR 恒方
|
|
1724
|
+
* 是层型硬钳、无比例槽(spec 豁免面);
|
|
1725
|
+
* - 交叉类型(文本层带比例档/图片层带文本档)各在对方清单查无此档、天然
|
|
1726
|
+
* 跳写槽。
|
|
1727
|
+
*/
|
|
1728
|
+
armLayerCreate(type: LayerType, preset?: TextPresetId | RatioPresetId): void;
|
|
1729
|
+
/** 解除建层武装(取消入口):仅清待命态(含模板表风味载荷),零副作用。 */
|
|
1605
1730
|
cancelArmLayerCreate(): void;
|
|
1731
|
+
/**
|
|
1732
|
+
* 武装模板表建层(canvas-web-template-table-drag-create 工单 01,spec 决策 3):
|
|
1733
|
+
* 行路径表单确认即武装——rowsPath 随武装进 ui 瞬态载荷(armedCreate 仍为
|
|
1734
|
+
* 'TableLayer'、不新增 LayerType、不进 graph),下一次画拉或死区点击落模板表。
|
|
1735
|
+
* 空串 no-op(内核防御,表单层已拦);重复武装同 rowsPath 值等短路,换
|
|
1736
|
+
* rowsPath 更新载荷。TableLayer 的 G 武装语义(V1 普通表,armLayerCreate 走
|
|
1737
|
+
* 空载荷)不受染指。
|
|
1738
|
+
*/
|
|
1739
|
+
armTemplateTableCreate(rowsPath: string): void;
|
|
1606
1740
|
/**
|
|
1607
1741
|
* 开始画拉会话:须已武装(未武装空转防御——画布手势态机的分派前置,此守卫
|
|
1608
1742
|
* 兜其余调用来源),与拖动/缩放会话互斥(手势起点一次性定死,beginDrag/
|
|
@@ -1613,24 +1747,37 @@ declare class EditorSession {
|
|
|
1613
1747
|
beginLayerCreate(sceneX: number, sceneY: number): boolean;
|
|
1614
1748
|
/**
|
|
1615
1749
|
* 画拉进行中:橡皮筋求位(spatial/create.createRubberBandRect——两点正规化
|
|
1616
|
-
* + QR 钳 height := width + 左右/上下缘各两点进
|
|
1617
|
-
*
|
|
1618
|
-
* ui.snapAxes 走 GuidesOverlay
|
|
1619
|
-
* (snapAxesForGesture(null)
|
|
1620
|
-
*
|
|
1750
|
+
* + QR 钳 height := width / 比例钳长轴驱动 + 左右/上下缘各两点进
|
|
1751
|
+
* resolveSnapPoints,吸附数学零新增)写回会话 rect 供 overlay 直读(虚线
|
|
1752
|
+
* 矩形 + W×H 气泡),命中轴回写 ui.snapAxes 走 GuidesOverlay 既有通道回显
|
|
1753
|
+
* (dragTo 同门)。吸附排除面为空(snapAxesForGesture(null)——新层尚未入库,
|
|
1754
|
+
* 全部可见根层供轴,copyMode 首移同门)。零文档事务:修正只进会话几何,
|
|
1755
|
+
* 落库在 endCreate。
|
|
1756
|
+
*
|
|
1757
|
+
* 建层比例槽(image-ratio-preset 工单 01,spec 决策 3/4):仅 ImageLayer 按槽
|
|
1758
|
+
* 钳制(QR 层不传 ratio、恒方语义不动,两钳互斥;其余层型无槽);Shift 瞬时
|
|
1759
|
+
* 反转槽态——槽非自由按 Shift = 临时自由、槽自由按 Shift = 临时钳 1:1,按住
|
|
1760
|
+
* 生效松开还原(逐帧求位、不写槽、不改武装态,Figma 惯例的手势瞬时语义)。
|
|
1621
1761
|
*/
|
|
1622
|
-
createTo(sceneX: number, sceneY: number): void;
|
|
1762
|
+
createTo(sceneX: number, sceneY: number, shift?: boolean): void;
|
|
1623
1763
|
/**
|
|
1624
1764
|
* 结束画拉:按死区分流落库(一次手势 = 一步历史,undo 整体回退落位 + 尺寸
|
|
1625
1765
|
* + priority)。先清会话再落文档(commitTextEdit 同门——退出路径级联时幂等):
|
|
1626
1766
|
* - 死区外:单事务写入「createDefaultLayer 缺省形态 + position 左上角对准
|
|
1627
1767
|
* 橡皮筋矩形(含吸附修正)+ shape.width/height」并 insertRootLayerInDraft
|
|
1628
|
-
* 置顶(priority min−1、push
|
|
1768
|
+
* 置顶(priority min−1、push 数组尾)——尺寸取手势末态钳制结果(含 Shift
|
|
1769
|
+
* 反转末态,image-ratio-preset 工单 01 spec 决策 4);
|
|
1629
1770
|
* - 死区内(点击兜底,位移按 CREATE_DEAD_ZONE_SCREEN_PX 屏幕 px 随 zoom 折算,
|
|
1630
|
-
* ALT_DRAG_DEAD_ZONE_SCREEN_PX
|
|
1771
|
+
* ALT_DRAG_DEAD_ZONE_SCREEN_PX 同门):左上角对准点击点;尺寸按槽派生缺省
|
|
1772
|
+
* 盒(image-ratio-preset 工单 01:ImageLayer 长边 200 定短边,自由 = 工厂
|
|
1773
|
+
* 200×150 现状;忽略 shift——无位移可供等比约束;其余层型保持工厂缺省)。
|
|
1631
1774
|
* 落库后自动选中新层并解除武装;返回新层路径(绑定层消费:文本层据此自动
|
|
1632
1775
|
* 进文本编辑,spec 决策 6)。无会话/无文档空转返回 null。点击兜底不产生
|
|
1633
1776
|
* 零尺寸层(缺省形态自带可见尺寸)。
|
|
1777
|
+
*
|
|
1778
|
+
* 模板表风味(template-table-drag-create 工单 01):会话载荷 templateRowsPath
|
|
1779
|
+
* 非空即分派 createTemplateTable 工厂(死区外 shape = 手势正规化矩形,死区内
|
|
1780
|
+
* 缺省壳 400×120、左上角对准点击点);模板层不自动进文本编辑(文本层专属)。
|
|
1634
1781
|
*/
|
|
1635
1782
|
endCreate(): LayerPath | null;
|
|
1636
1783
|
/**
|
|
@@ -1729,7 +1876,9 @@ declare class EditorSession {
|
|
|
1729
1876
|
* 应用偏好(会话建立时一次性,跨会话恢复 prefs 的写入口):整体替换
|
|
1730
1877
|
* rulersVisible/anchorExpanded,不进历史;值等写入经 store 短路零通知。
|
|
1731
1878
|
* 新层样式(text-defaults 工单 01)走宽容读逐字段合并(pickNextTextStylePatch
|
|
1732
|
-
*
|
|
1879
|
+
* 共享谓词——与捕获同门,缺字/类型不符保留现值);建层比例(image-ratio-preset
|
|
1880
|
+
* 工单 01)走宽容读枚举收口(pickNextLayerRatio——非六档枚举值/旧快照缺字段
|
|
1881
|
+
* 回落 'free')。
|
|
1733
1882
|
*/
|
|
1734
1883
|
applyEditorPrefs(prefs: EditorPrefsState): void;
|
|
1735
1884
|
/**
|
|
@@ -2133,12 +2282,6 @@ declare class EditorSession {
|
|
|
2133
2282
|
* 一次调用 = 一步历史。
|
|
2134
2283
|
*/
|
|
2135
2284
|
addTableCell(rowPath: LayerPath): void;
|
|
2136
|
-
/**
|
|
2137
|
-
* 新增模板表(「+」选择器入口,spec §2.1):createTemplateTable 缺省形态 +
|
|
2138
|
-
* 置顶 + 自动选中;一次调用 = 一步历史。rowsPath 必填(解码 rows_path_missing
|
|
2139
|
-
* 硬约束的对齐兜底,表单校验前置),空串 no-op。
|
|
2140
|
-
*/
|
|
2141
|
-
addTemplateTable(rowsPath: string): void;
|
|
2142
2285
|
/**
|
|
2143
2286
|
* 模板行加格(spec §3.1):addTemplateCellInDraft 重建路径(末格宽/首格行宽、
|
|
2144
2287
|
* 零高度耦合),自动选中新格;一次调用 = 一步历史。非模板态 no-op。
|
|
@@ -2266,10 +2409,11 @@ declare function hitTest(canvas: Canvas, sceneX: number, sceneY: number, policie
|
|
|
2266
2409
|
*
|
|
2267
2410
|
* 拖拽期两点正规化出橡皮筋矩形(x = min、width = |dx|,y 同,反向拖不翻转);
|
|
2268
2411
|
* QrCodeLayer 钳 height := width(高随宽从动保持方形,八柄缩放「QR 从动轴不
|
|
2269
|
-
*
|
|
2270
|
-
*
|
|
2271
|
-
*
|
|
2272
|
-
*
|
|
2412
|
+
* 采纳」同门);可选 ratio(image-ratio-preset 工单 01)长轴驱动钳制橡皮筋到
|
|
2413
|
+
* 目标宽高比;橡皮筋左右/上下缘各两点进 resolveSnapPoints——吸附数学零新增,
|
|
2414
|
+
* 命中修正整矩形平移并入几何(两点正规化、QR 方形与比例钳在修正后原样保持)。
|
|
2415
|
+
* 死区常量屏幕像素口径同 SNAP_THRESHOLD_SCREEN_PX(场景阈值 = 阈值 / zoom,缩放
|
|
2416
|
+
* 无关)。全模块纯函数、无 DOM;会话编排(武装/落库/解除)在会话门面。
|
|
2273
2417
|
*/
|
|
2274
2418
|
|
|
2275
2419
|
/** 画拉死区阈值(css 像素,缩放无关;场景阈值 = 阈值 / zoom):位移不越过即视作
|
|
@@ -2282,11 +2426,20 @@ interface CreateRectResult {
|
|
|
2282
2426
|
}
|
|
2283
2427
|
/**
|
|
2284
2428
|
* 画拉橡皮筋求位:两点正规化(起点场景坐标 + 当前点 → 左上角原点矩形)→
|
|
2285
|
-
* QR 钳 height := width
|
|
2286
|
-
*
|
|
2287
|
-
*
|
|
2288
|
-
|
|
2289
|
-
|
|
2429
|
+
* QR 钳 height := width / ratio 长轴驱动钳(两者互斥:QR 层忽略 ratio,恒方
|
|
2430
|
+
* 语义不动——调用缝只对 ImageLayer 传 ratio)→ 左右/上下缘各两点对轴集合求位
|
|
2431
|
+
* (已有已对齐 delta=0 也回显命中轴的语义,dragTo/resizeTo 同门)→ 修正整矩形
|
|
2432
|
+
* 平移并入。钳先于吸附——QR 的方边与比例钳的派生边才是真实的吸附位点。
|
|
2433
|
+
*
|
|
2434
|
+
* ratio 钳(image-ratio-preset 工单 01,spec 决策 3)长轴驱动:|Δx| ≥ |Δy| 时
|
|
2435
|
+
* 宽驱动(height = round(width × h ÷ w),Math.round 对正数 half-up),否则高
|
|
2436
|
+
* 驱动(width = round(height × w ÷ h));钳制在正规化后,反向拖取绝对值镜像
|
|
2437
|
+
* 天然覆盖。
|
|
2438
|
+
*/
|
|
2439
|
+
declare function createRubberBandRect(type: LayerType, start: Point, current: Point, axes: readonly SnapAxis[], threshold: number, ratio?: {
|
|
2440
|
+
w: number;
|
|
2441
|
+
h: number;
|
|
2442
|
+
} | null): CreateRectResult;
|
|
2290
2443
|
|
|
2291
2444
|
/**
|
|
2292
2445
|
* 滚轮意图分类(工单 05,三态)。纯函数:输入只取事件修饰键快照,
|
|
@@ -3022,4 +3175,4 @@ declare function memoizeTextPolicies(policies?: TextLayoutPolicies, options?: Me
|
|
|
3022
3175
|
*/
|
|
3023
3176
|
declare const PACKAGE_NAME: "@hankchen/canvas-editor";
|
|
3024
3177
|
|
|
3025
|
-
export { ALIGN_CORNER_MARGIN_PX, ALT_DRAG_DEAD_ZONE_SCREEN_PX, ARM_CREATE_LAYER_TYPES, type AlignBoxGeometry, type AlignToCanvasMode, type AlignToCanvasOptions, type ArmCreateShortcutAction, CREATE_DEAD_ZONE_SCREEN_PX, type CanvasEditorState, type CreateGesture, type CreateRectResult, DATE_FORMAT_SUGGESTIONS, DEFAULT_EDITOR_SHORTCUTS, DEFAULT_ZOOM_BOUNDS, type DeletedLayerRef, type DocRecipe, type DragGesture, EDITOR_STATE_SCHEMA_VERSION, EXPRESSION_FUNCTIONS, type EditorChange, type EditorPrefsState, EditorSession, type EditorSessionOptions, type EditorShortcutAction, type EditorShortcutBinding, type EditorShortcutGroup, type EditorShortcutInput, EditorStore, type EditorUi, type ExpressionCallArg, type ExpressionCallErrorKind, type ExpressionCallParse, type ExpressionCallSlotContext, type ExpressionCandidate, type ExpressionCandidateQuery, type ExpressionCandidateResult, type ExpressionContextKind, type ExpressionErrorRange, type ExpressionFormatSuggestion, type ExpressionFragmentDiagnostic, type ExpressionFragmentErrorKind, type ExpressionFunctionMeta, type ExpressionPathHead, type ExpressionPathParse, type ExpressionScan, type ExpressionScanFragment, type ExpressionScanLiteral, type ExpressionScanOpen, type ExpressionScanPart, type ExpressionSchemaChildEntry, type ExpressionSchemaChildView, type ExpressionSchemaDiagnostic, type ExpressionSchemaDiagnosticCode, type ExpressionSchemaNode, type ExpressionSchemaParse, type ExpressionSchemaRejectReason, type ExpressionSyntaxError, type FindSession, type FindTextHit, FontCatalog, type FontCatalogEntry, type FrameScheduler, type Guide, type GuideOrientation, type HistoryStep, type HitTestOptions, type InvalidateTarget, type LayerOutlineNode, type LayerOutlineRole, type LayerPath, MAX_HISTORY_STEPS, type MemoTextPoliciesOptions, type MovedSubtreeRef, NUMBER_FUNCTION_SUGGESTIONS, type NextTextStyle, type OverlayPaintArgs, type OverlayPainter, PACKAGE_NAME, PAN_TO_BOX_MARGIN_PX, PASTE_OFFSET_PX, PHP_TRIM_CHARS, type Point, RESIZE_HANDLES, RESIZE_HANDLE_HIT_PX, RESIZE_MIN_SIZE_PX, type Rect, type ResizeAxes, type ResizeBoxGeometry, type ResizeBoxResult, type ResizeHandle, type ResourceStatus, type ResourceStatusMap, type RowsPathCandidate, type RowsPathCandidateResult, SNAP_THRESHOLD_SCREEN_PX, STYLE_FIELD_KEYS_BY_TYPE, type ShortcutCombo, type Size, type SnapAxis, type SnapAxisSource, type SnapBoxGeometry, type SnapPoints, type SnapResolution, type StyleSnapshot, TEXT_PRESETS, type TextEditLayout, type TextEditingSession, type TextPresetId, type TransactOptions, type UploadFile, type UploadHandler, UploadHandlerMissingError, type UploadImagePlacement, type Viewport, WHEEL_ZOOM_STEP, type WheelInput, type WheelIntent, type ZoomBounds, addRootLayerInDraft, addTableCellInDraft, addTableRowInDraft, addTemplateCellInDraft, alignToCanvasTarget, applyStyleFieldsInDraft, buildLayerOutline, canCopyLayerAt, canonicalizeTableSyncInDraft, captureStyleSnapshot, clampZoom, classifyEditorShortcut, classifyWheel, cloneLayerSubtree, convertTableToRowsInDraft, convertTableToTemplateInDraft, createDefaultLayer, createRubberBandRect, createTemplateTable, defaultNextTextStyle, deleteLayerInDraft, enumerateExpressionCandidates, enumerateRowsPathCandidates, expressionCallSlotAtEnd, expressionDiagnostics, expressionFragmentAtCursor, fitRect, fitViewport, growRowToCellInDraft, handleResizesHeight, handleResizesWidth, hitTest, insertRootLayerAdjacentInDraft, insertRootLayerInDraft, isCallFragment, isImageContentUndrawn, isLayerPath, isLockedPath, isRootLayerPath, isRootPasteableType, isTemplateSubtreePath, layerBoxByPath, memoizeTextPolicies, moveGuard, moveRootLayerInDraft, moveTableCellInDraft, moveTableCellToRowInDraft, moveTableRowInDraft, moveTableRowToTableInDraft, nextZoomByWheel, normalizeExpressionSchemaSource, panBy, panToBox, parseExpressionCall, parseExpressionPath, parseExpressionSchema, pastePosition, pathStartsWith, pathsEqual, phpTrim, pickNextTextStylePatch, prepareRootPaste, readSpecField, remapPathAfterSplice, replaceHitsInDraft, resizableAxesAt, resizeBox, resizeHandleAt, resizeHandlePoint, resizeHandlesAt, resizeSnapPoints, resolveLayer, resolveRowSchema, resolveRowsPathStartSchema, resolveSnap, resolveSnapPoints, resourcePathDiagnostics, rootLayerOf, scanExpressionFragments, scanTextMatches, sceneToScreen, schemaChildEntries, schemaNodeAtPath, screenToScene, selectionParentPath, setCellAutoHeightInDraft, snapAxesFromBoxes, snapThresholdScene, snapViewportToPhysicalPixels, syncContentIntoCellInDraft, syncRowWidthInDraft, uploadDisplayName, visibleRootBoxes, writeSpecField, zoomAtPoint };
|
|
3178
|
+
export { ALIGN_CORNER_MARGIN_PX, ALT_DRAG_DEAD_ZONE_SCREEN_PX, ARM_CREATE_LAYER_TYPES, type AlignBoxGeometry, type AlignToCanvasMode, type AlignToCanvasOptions, type ArmCreateShortcutAction, CREATE_DEAD_ZONE_SCREEN_PX, type CanvasEditorState, type CreateGesture, type CreateRectResult, DATE_FORMAT_SUGGESTIONS, DEFAULT_EDITOR_SHORTCUTS, DEFAULT_ZOOM_BOUNDS, type DeletedLayerRef, type DocRecipe, type DragGesture, EDITOR_STATE_SCHEMA_VERSION, EXPRESSION_FUNCTIONS, type EditorChange, type EditorPrefsState, EditorSession, type EditorSessionOptions, type EditorShortcutAction, type EditorShortcutBinding, type EditorShortcutGroup, type EditorShortcutInput, EditorStore, type EditorUi, type ExpressionCallArg, type ExpressionCallErrorKind, type ExpressionCallParse, type ExpressionCallSlotContext, type ExpressionCandidate, type ExpressionCandidateQuery, type ExpressionCandidateResult, type ExpressionContextKind, type ExpressionErrorRange, type ExpressionFormatSuggestion, type ExpressionFragmentDiagnostic, type ExpressionFragmentErrorKind, type ExpressionFunctionMeta, type ExpressionPathHead, type ExpressionPathParse, type ExpressionScan, type ExpressionScanFragment, type ExpressionScanLiteral, type ExpressionScanOpen, type ExpressionScanPart, type ExpressionSchemaChildEntry, type ExpressionSchemaChildView, type ExpressionSchemaDiagnostic, type ExpressionSchemaDiagnosticCode, type ExpressionSchemaNode, type ExpressionSchemaParse, type ExpressionSchemaRejectReason, type ExpressionSyntaxError, type FindSession, type FindTextHit, FontCatalog, type FontCatalogEntry, type FrameScheduler, type Guide, type GuideOrientation, type HistoryStep, type HitTestOptions, type InvalidateTarget, type LayerOutlineNode, type LayerOutlineRole, type LayerPath, MAX_HISTORY_STEPS, type MemoTextPoliciesOptions, type MovedSubtreeRef, NUMBER_FUNCTION_SUGGESTIONS, type NextTextStyle, type OverlayPaintArgs, type OverlayPainter, PACKAGE_NAME, PAN_TO_BOX_MARGIN_PX, PASTE_OFFSET_PX, PHP_TRIM_CHARS, type Point, type ProportionalDrivingAxis, RATIO_PRESETS, RESIZE_HANDLES, RESIZE_HANDLE_HIT_PX, RESIZE_MIN_SIZE_PX, type RatioPreset, type RatioPresetId, type Rect, type ResizeAxes, type ResizeBoxGeometry, type ResizeBoxResult, type ResizeHandle, type ResourceStatus, type ResourceStatusMap, type RowsPathCandidate, type RowsPathCandidateResult, SNAP_THRESHOLD_SCREEN_PX, STYLE_FIELD_KEYS_BY_TYPE, type ShortcutCombo, type Size, type SnapAxis, type SnapAxisSource, type SnapBoxGeometry, type SnapPoints, type SnapResolution, type StyleSnapshot, TEXT_PRESETS, type TextEditLayout, type TextEditingSession, type TextPresetId, type TransactOptions, type UploadFile, type UploadHandler, UploadHandlerMissingError, type UploadImagePlacement, type Viewport, WHEEL_ZOOM_STEP, type WheelInput, type WheelIntent, type ZoomBounds, addRootLayerInDraft, addTableCellInDraft, addTableRowInDraft, addTemplateCellInDraft, alignToCanvasTarget, applyStyleFieldsInDraft, buildLayerOutline, canCopyLayerAt, canonicalizeTableSyncInDraft, captureStyleSnapshot, clampZoom, classifyEditorShortcut, classifyWheel, cloneLayerSubtree, convertTableToRowsInDraft, convertTableToTemplateInDraft, createDefaultLayer, createRubberBandRect, createTemplateTable, defaultNextLayerRatio, defaultNextTextStyle, defaultSizeForRatio, deleteLayerInDraft, enumerateExpressionCandidates, enumerateRowsPathCandidates, expressionCallSlotAtEnd, expressionDiagnostics, expressionFragmentAtCursor, fitRect, fitViewport, growRowToCellInDraft, handleResizesHeight, handleResizesWidth, hitTest, insertRootLayerAdjacentInDraft, insertRootLayerInDraft, isCallFragment, isImageContentUndrawn, isLayerPath, isLockedPath, isRootLayerPath, isRootPasteableType, isTemplateSubtreePath, layerBoxByPath, memoizeTextPolicies, moveGuard, moveRootLayerInDraft, moveTableCellInDraft, moveTableCellToRowInDraft, moveTableRowInDraft, moveTableRowToTableInDraft, nextZoomByWheel, normalizeExpressionSchemaSource, panBy, panToBox, parseExpressionCall, parseExpressionPath, parseExpressionSchema, pastePosition, pathStartsWith, pathsEqual, phpTrim, pickNextLayerRatio, pickNextTextStylePatch, prepareRootPaste, proportionalDrivingAxis, ratioValue, readSpecField, remapPathAfterSplice, replaceHitsInDraft, resizableAxesAt, resizeBox, resizeBoxProportional, resizeHandleAt, resizeHandlePoint, resizeHandlesAt, resizeProportionalSnapPoints, resizeSnapPoints, resolveLayer, resolveRowSchema, resolveRowsPathStartSchema, resolveSnap, resolveSnapPoints, resourcePathDiagnostics, rootLayerOf, scanExpressionFragments, scanTextMatches, sceneToScreen, schemaChildEntries, schemaNodeAtPath, screenToScene, selectionParentPath, setCellAutoHeightInDraft, snapAxesFromBoxes, snapThresholdScene, snapViewportToPhysicalPixels, syncContentIntoCellInDraft, syncRowWidthInDraft, uploadDisplayName, visibleRootBoxes, writeSpecField, zoomAtPoint };
|