@hankchen/canvas-editor 0.5.0 → 0.7.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 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;
@@ -484,13 +509,62 @@ interface NextTextStyle {
484
509
  }
485
510
  /** 文本预设档位(CONTEXT「文本预设」词条):heading 40 / subheading 28 / body 16 */
486
511
  type TextPresetId = 'heading' | 'subheading' | 'body';
512
+ /** 文本预设档位条目(评审整改 F2 查档返回面,RatioPreset 同形):具名 id + 档位字号 */
513
+ interface TextPreset {
514
+ readonly id: TextPresetId;
515
+ readonly fontSize: number;
516
+ }
487
517
  /** 文本预设常量(spec 决策 4):v1 只定字号——字体缺口由新层样式槽补 */
488
- declare const TEXT_PRESETS: readonly {
489
- id: TextPresetId;
490
- fontSize: number;
491
- }[];
518
+ declare const TEXT_PRESETS: readonly TextPreset[];
492
519
  /** 新层样式槽初值:自工厂 TextLayer 形态派生(工厂缺省是单一事实源,槽跟着走) */
493
520
  declare function defaultNextTextStyle(): NextTextStyle;
521
+ /**
522
+ * 建层比例档位(spec 决策 1/2):'free' = 自由钳(工厂行为兜底),其余五个具名
523
+ * 有理数比。v1 固定清单、无自定义输入。清单随建层比例槽退役保持不动
524
+ * (canvas-web-preset-submenu 工单 01,ADR 0021):free 仍是「自由」枚举值与
525
+ * Shift 语义引用,具名档由武装预设载荷(armedCreatePreset)一次性携带消费。
526
+ */
527
+ type RatioPresetId = 'free' | '1:1' | '4:3' | '3:4' | '16:9' | '9:16';
528
+ /** 比例预设档位:具名 id + 有理数宽高比(free 档 ratio = null,即不钳) */
529
+ interface RatioPreset {
530
+ readonly id: RatioPresetId;
531
+ readonly ratio: Readonly<{
532
+ w: number;
533
+ h: number;
534
+ }> | null;
535
+ }
536
+ /** 比例预设常量六档(顺序即面板平铺序:自由在前,其余按惯例短比在前) */
537
+ declare const RATIO_PRESETS: readonly RatioPreset[];
538
+ /** 档位 → 钳制用有理数比:'free' → null(不钳),具名档 → {w, h} 副本 */
539
+ declare function ratioValue(id: RatioPresetId): {
540
+ w: number;
541
+ h: number;
542
+ } | null;
543
+ /**
544
+ * 层型预设档位查档(canvas-web-preset-submenu 评审整改 F2):武装/画拉会话载荷的
545
+ * 档位 id 按层型分流到对应清单单点查找——TextLayer 查 TEXT_PRESETS、ImageLayer 查
546
+ * RATIO_PRESETS,其余层型(无预设语义)与交叉类型(文本层带比例档/图片层带文本
547
+ * 档)在对方清单查无此档,返回 undefined(「未知 id = 不落载荷、武装照常」评审
548
+ * 口径的查表面)。session 建层管线的档位查找(armLayerCreate / endCreate)经此
549
+ * 消费,档比复制语义复用 ratioValue;presetId 收 string——store 载荷是 string
550
+ * 形态(ui 分支不翻译型),查档天然宽容(未知 id 查无)。重载让层型字面量收窄
551
+ * 返回面:TextLayer 只得文本档、ImageLayer 只得比例档。
552
+ */
553
+ declare function findPresetEntry(type: LayerType, presetId: string): TextPreset | RatioPreset | undefined;
554
+ declare function findPresetEntry(type: 'TextLayer', presetId: string): TextPreset | undefined;
555
+ declare function findPresetEntry(type: 'ImageLayer', presetId: string): RatioPreset | undefined;
556
+ /**
557
+ * 死区点击缺省盒的比例派生(spec 决策 3):长边 200 定短边——短边 = round(长边
558
+ * × 短比)(Math.round 对正数 half-up:16:9 → 200×113)。自由档不进本函数
559
+ * (调用方以 ratioValue 为 null 分流到工厂缺省 200×150)。
560
+ */
561
+ declare function defaultSizeForRatio(ratio: {
562
+ w: number;
563
+ h: number;
564
+ }): {
565
+ width: number;
566
+ height: number;
567
+ };
494
568
  /**
495
569
  * 新层样式字段的宽容读逐字段收口(text-defaults 工单 01;评审合流——捕获与
496
570
  * prefs 恢复共用同一谓词,不再双写):合法字段进合并集,缺字/类型不符忽略
@@ -514,10 +588,16 @@ declare function createDefaultLayer(type: LayerType, textDefaults?: Partial<Next
514
588
  * 高按解码归一为 0、宽 := 表宽关 autoWidth)+ 满宽 60 高缺省格带缺省文本内容
515
589
  * (内容宽度同步、零高度耦合,ADR 0006)。rowsPath 由调用方必填(解码
516
590
  * rows_path_missing 硬约束,创建表单校验前置);缺省格 60 高保证空态预览行可见
517
- * 可点(合成高 = 最高格,03 票 E1 机制)。
591
+ * 可点(合成高 = 最高格,03 票 E1 机制)。shape(template-table-drag-create 工单
592
+ * 01):画拉建层的手势矩形尺寸参数化——表壳宽高照落,行模板/格/内容宽 := 表宽
593
+ * 的既有耦合自然生效;缺省 400×120 不变。
518
594
  */
519
595
  declare function createTemplateTable(options: {
520
596
  rowsPath: string;
597
+ shape?: {
598
+ width: number;
599
+ height: number;
600
+ };
521
601
  }): TableLayer;
522
602
  /**
523
603
  * 「insert-before 原始序号 to」移动的公共守卫与落点折算:from/to 须为安全整数、
@@ -817,6 +897,21 @@ interface ResizeGesture {
817
897
  interface CreateGesture {
818
898
  /** 本次画拉的层型(beginLayerCreate 时从 armedCreate 捕获,会话内定死) */
819
899
  type: LayerType;
900
+ /**
901
+ * 模板表风味的行路径载荷(canvas-web-template-table-drag-create 工单 01):
902
+ * beginLayerCreate 时从 ui.armedCreateRowsPath 捕获(会话内定死),非空串 =
903
+ * 模板表风味(endCreate 分派 createTemplateTable);undefined = 普通武装
904
+ * (G 快捷键 V1 空表语义原样)。
905
+ */
906
+ templateRowsPath?: string;
907
+ /**
908
+ * 建层预设载荷(canvas-web-preset-submenu 工单 01,ADR 0021):beginLayerCreate
909
+ * 时从 ui.armedCreatePreset 捕获(templateRowsPath 同门,会话内定死)——文本层
910
+ * 载荷命中 TEXT_PRESETS = 档位字号直接生效(不经新层样式槽);图片层载荷命中
911
+ * RATIO_PRESETS = 比例钳橡皮筋与死区缺省盒(Shift 瞬时反转源 = 本生效档)。
912
+ * undefined = 普通武装(文本按槽、图片恒自由)。
913
+ */
914
+ preset?: string;
820
915
  /** 起点场景坐标(两点正规化与死区判定基准) */
821
916
  startScene: Point;
822
917
  /** 当前指针场景坐标 */
@@ -879,6 +974,25 @@ interface EditorUi {
879
974
  * 解除。无粘性工具态(spec 决策 2);openDocument 重置。
880
975
  */
881
976
  armedCreate: LayerType | null;
977
+ /**
978
+ * 武装 token 的模板表风味载荷(canvas-web-template-table-drag-create 工单 01):
979
+ * 行路径表单确认即武装(spec 决策 3)——armedCreate === 'TableLayer' 且本载荷
980
+ * 非空串 = 模板表风味(endCreate 按风味分派 createTemplateTable);空串 = 普通
981
+ * 表武装(G 快捷键语义不受染指)。rowsPath 是 ui 瞬态载荷——不进 graph、
982
+ * 不进 wire(红线 3 延伸),beginLayerCreate 捕获进建层会话;openDocument 重置。
983
+ */
984
+ armedCreateRowsPath: string;
985
+ /**
986
+ * 武装 token 的预设载荷(canvas-web-preset-submenu 工单 01,ADR 0021):预设
987
+ * 随武装一次性携带、不再写任何偏好槽——armedCreate === 'TextLayer' 且本载荷
988
+ * 命中 TEXT_PRESETS = 文本预设风味(endCreate 按档位字号直接生效,不经新层
989
+ * 样式槽);armedCreate === 'ImageLayer' 且本载荷命中 RATIO_PRESETS = 比例
990
+ * 预设风味(createTo 钳橡皮筋、endCreate 死区缺省盒)。空串 = 普通武装
991
+ * (文本按新层样式槽、图片恒自由),与 armedCreateRowsPath 同款空值语义。
992
+ * ui 瞬态载荷——不进 graph、不进 wire、不进 prefs(红线 3 延伸),
993
+ * beginLayerCreate 捕获进建层会话;openDocument 重置。
994
+ */
995
+ armedCreatePreset: string;
882
996
  /** 进行中的画拉建层橡皮筋会话(拖拽期纯视觉,文档零变更);null = 无 */
883
997
  create: CreateGesture | null;
884
998
  /** 进行中的文本编辑会话;null = 非编辑态 */
@@ -900,6 +1014,8 @@ interface EditorUi {
900
1014
  * 族字段的权威写(updateSpec 捕获)更新槽,建层(endCreate/addRootLayer)
901
1015
  * 以槽值覆盖工厂缺省。与锚点折叠同款的面板偏好——openDocument 换文档不重
902
1016
  * 置,永不进历史;随工程数据 prefs 桶跨会话持久(宿主通道,内核零 localStorage)。
1017
+ * 文本预设档不写槽(canvas-web-preset-submenu 工单 01,ADR 0021:预设随武装
1018
+ * 载荷一次性携带,槽只保留属性面板信号一种语义)。
903
1019
  */
904
1020
  nextTextStyle: NextTextStyle;
905
1021
  /**
@@ -1029,8 +1145,14 @@ declare class EditorStore {
1029
1145
  setDrag(gesture: DragGesture | null): void;
1030
1146
  /** 缩放会话开始/结束(null,工单 07);会话对象住 ui 分支,文档只收缩放事务 */
1031
1147
  setResize(gesture: ResizeGesture | null): void;
1032
- /** 建层武装置/解除(null,drag-create 工单 01);标量值等短路(重复武装同型不通知) */
1033
- setArmedCreate(type: LayerType | null): void;
1148
+ /**
1149
+ * 建层武装置/解除(null,drag-create 工单 01);标量值等短路(重复武装同型
1150
+ * 不通知)。rowsPath(template-table-drag-create 工单 01):模板表风味载荷
1151
+ * 与层型一体写;preset(canvas-web-preset-submenu 工单 01):预设载荷与层型
1152
+ * 一体写——同层型同载荷才短路(重复武装同型换载荷要更新),解除(null)
1153
+ * 一律清载荷(rowsPath 与 preset 双清)。
1154
+ */
1155
+ setArmedCreate(type: LayerType | null, rowsPath?: string, preset?: string): void;
1034
1156
  /** 画拉橡皮筋会话开始/更新/结束(null);会话对象住 ui 分支,落库在 endCreate 单事务 */
1035
1157
  setCreate(gesture: CreateGesture | null): void;
1036
1158
  /** 文本编辑会话开始/结束(null);会话住 ui 分支,文本经 commitTextEdit 一次性落文档 */
@@ -1040,8 +1162,9 @@ declare class EditorStore {
1040
1162
  /** 锚点折叠区开合:布尔值等短路(重复点击同一态不重绘) */
1041
1163
  setAnchorExpanded(open: boolean): void;
1042
1164
  /**
1043
- * 新层样式槽逐字段合并(text-defaults 工单 01:捕获/预设/prefs 恢复的统一
1044
- * 写入口):patch 并入现值,五字段值等短路(重复写同值零通知),不进历史。
1165
+ * 新层样式槽逐字段合并(text-defaults 工单 01:捕获/prefs 恢复的统一写入口;
1166
+ * canvas-web-preset-submenu 工单 01 起预设不再写槽):patch 并入现值,五字段
1167
+ * 值等短路(重复写同值零通知),不进历史。
1045
1168
  */
1046
1169
  setNextTextStyle(patch: Partial<NextTextStyle>): void;
1047
1170
  /**
@@ -1162,7 +1285,12 @@ declare function classifyEditorShortcut(input: EditorShortcutInput, bindings?: r
1162
1285
  * 仍是内核唯一保存物。
1163
1286
  */
1164
1287
 
1165
- /** 快照格式版本:随格式演化单调递增;v1 = 1(宽容读贯彻,restore 不分支此值) */
1288
+ /**
1289
+ * 快照格式版本:随格式演化单调递增;v1 = 1(宽容读贯彻,restore 不分支此值)。
1290
+ * prefs 桶的 nextLayerRatio 键已随 canvas-web-preset-submenu 工单 01(ADR 0021)
1291
+ * 退役:停写停读、版本不升——旧快照的该键由调用方按宽容读惯例整体忽略(键在
1292
+ * 载荷里多余但无害),加法演进同门前例(text-defaults 工单 01)。
1293
+ */
1166
1294
  declare const EDITOR_STATE_SCHEMA_VERSION = 1;
1167
1295
  /** 帧作用域切片:当前打开画布的编辑器状态(工程数据快照的 frames[帧名] 值) */
1168
1296
  interface CanvasEditorState {
@@ -1583,8 +1711,17 @@ declare class EditorSession {
1583
1711
  *
1584
1712
  * 拖不动写不动的同门守卫:无会话、目标层被结构编辑移除(悬空路径)整体
1585
1713
  * 空转(不发事务、不发布命中轴)。
1714
+ *
1715
+ * Shift 等比(image-ratio-preset 工单 01,spec 决策 5):仅 ImageLayer 生效
1716
+ * (其余层型 shift 空转走现状——自适应与尺寸耦合面不被触碰),且须双轴皆在
1717
+ * 可缩放面(格内容等强同步面派生轴写不出去,不进等比模式)、起始盒零维空转
1718
+ * (无比例可参照,回落自由)。参照手势起始盒实际宽高比;驱动轴 = 角柄取位
1719
+ * 移较大轴、边中柄取被拖轴;派生维 = round(驱动维 × 短比)(钳后驱动维跟随,
1720
+ * 最小钳位随动);对缘/对角固定照旧;吸附只在驱动轴移动缘候选(派生轴是算
1721
+ * 术产物不独立吸附,钳先于吸附同门)。等比模式双轴都落声明值(派生轴写算
1722
+ * 术积并清 auto 标志),canonicalize 以驱动轴键收口。
1586
1723
  */
1587
- resizeTo(sceneX: number, sceneY: number): void;
1724
+ resizeTo(sceneX: number, sceneY: number, shift?: boolean): void;
1588
1725
  /**
1589
1726
  * 结束缩放:闭合合并事务(下一步历史定格),会话态与命中轴回显清空。
1590
1727
  * 无会话空转(幂等,pointercancel 与 pointerup 双路同达)。
@@ -1593,16 +1730,30 @@ declare class EditorSession {
1593
1730
  /**
1594
1731
  * 武装建层(面板新增项/层型快捷键的统一入口,CONTEXT「武装」词条):置 ui
1595
1732
  * 分支待命层型,下一次画布按下即开画拉;建层提交或 Esc 即解除——一次性
1596
- * 待命态,无粘性工具(spec 决策 2)。重复武装同型值等短路零通知。
1733
+ * 待命态,无粘性工具(spec 决策 2)。重复武装同型同载荷值等短路零通知。
1597
1734
  *
1598
- * preset(text-defaults 工单 01,CONTEXT「文本预设」词条):文本预设 = 写
1599
- * 新层样式槽的快捷方式——命中档位先把档位值并入槽(v1 只 fontSize),再
1600
- * 武装;仅 TextLayer 生效;未知 id = 跳过写槽、武装照常(评审口径统一:
1601
- * 「空转」只指写槽,武装层型本身仍合法)。
1602
- */
1603
- armLayerCreate(type: LayerType, preset?: TextPresetId): void;
1604
- /** 解除建层武装(取消入口):仅清待命态,零副作用。 */
1735
+ * preset(canvas-web-preset-submenu 工单 01,ADR 0021):层型相关预设随武装
1736
+ * 载荷一次性携带、**不再写任何偏好槽**——命中档位把档位 id 写进
1737
+ * ui.armedCreatePreset(endCreate 落库一次性消费,取消路零残留);未知 id =
1738
+ * 不落载荷、武装照常(评审口径统一:「空转」只指载荷,武装层型本身仍合法)。
1739
+ * - TextLayer + 文本预设档:载荷命中 TEXT_PRESETS(endCreate 档位字号直接
1740
+ * 生效,不经新层样式槽——普通武装文本按槽的语义不受染指);
1741
+ * - ImageLayer + 比例预设档:载荷命中 RATIO_PRESETS('free' 档载荷行为等价
1742
+ * 自由;QR 恒方是层型硬钳、无比例语义,spec 豁免面);
1743
+ * - 交叉类型(文本层带比例档/图片层带文本档)各在对方清单查无此档、不落载荷。
1744
+ */
1745
+ armLayerCreate(type: LayerType, preset?: TextPresetId | RatioPresetId): void;
1746
+ /** 解除建层武装(取消入口):仅清待命态(含模板表风味与预设载荷),零副作用。 */
1605
1747
  cancelArmLayerCreate(): void;
1748
+ /**
1749
+ * 武装模板表建层(canvas-web-template-table-drag-create 工单 01,spec 决策 3):
1750
+ * 行路径表单确认即武装——rowsPath 随武装进 ui 瞬态载荷(armedCreate 仍为
1751
+ * 'TableLayer'、不新增 LayerType、不进 graph),下一次画拉或死区点击落模板表。
1752
+ * 空串 no-op(内核防御,表单层已拦);重复武装同 rowsPath 值等短路,换
1753
+ * rowsPath 更新载荷。TableLayer 的 G 武装语义(V1 普通表,armLayerCreate 走
1754
+ * 空载荷)不受染指。
1755
+ */
1756
+ armTemplateTableCreate(rowsPath: string): void;
1606
1757
  /**
1607
1758
  * 开始画拉会话:须已武装(未武装空转防御——画布手势态机的分派前置,此守卫
1608
1759
  * 兜其余调用来源),与拖动/缩放会话互斥(手势起点一次性定死,beginDrag/
@@ -1613,30 +1764,50 @@ declare class EditorSession {
1613
1764
  beginLayerCreate(sceneX: number, sceneY: number): boolean;
1614
1765
  /**
1615
1766
  * 画拉进行中:橡皮筋求位(spatial/create.createRubberBandRect——两点正规化
1616
- * + QR 钳 height := width + 左右/上下缘各两点进 resolveSnapPoints,吸附数学
1617
- * 零新增)写回会话 rect 供 overlay 直读(虚线矩形 + W×H 气泡),命中轴回写
1618
- * ui.snapAxes 走 GuidesOverlay 既有通道回显(dragTo 同门)。吸附排除面为空
1619
- * (snapAxesForGesture(null)——新层尚未入库,全部可见根层供轴,copyMode
1620
- * 首移同门)。零文档事务:修正只进会话几何,落库在 endCreate。
1767
+ * + QR 钳 height := width / 比例钳长轴驱动 + 左右/上下缘各两点进
1768
+ * resolveSnapPoints,吸附数学零新增)写回会话 rect 供 overlay 直读(虚线
1769
+ * 矩形 + W×H 气泡),命中轴回写 ui.snapAxes 走 GuidesOverlay 既有通道回显
1770
+ * (dragTo 同门)。吸附排除面为空(snapAxesForGesture(null)——新层尚未入库,
1771
+ * 全部可见根层供轴,copyMode 首移同门)。零文档事务:修正只进会话几何,
1772
+ * 落库在 endCreate。
1773
+ *
1774
+ * 建层预设档(canvas-web-preset-submenu 工单 01,ADR 0021,取代建层比例槽):
1775
+ * 仅 ImageLayer 按会话载荷档钳制(QR 层不传 ratio、恒方语义不动,两钳互斥;
1776
+ * 其余层型无比例语义);无载荷或 free 档 = 自由钳(普通武装恒自由)。
1777
+ * Shift 瞬时反转源 = 生效档(载荷档或自由):档具名按 Shift = 临时自由、
1778
+ * 生效档自由(含无载荷)按 Shift = 临时钳 1:1,按住生效松开还原(逐帧求位、
1779
+ * 不写载荷不改武装态,Figma 惯例的手势瞬时语义)。
1621
1780
  */
1622
- createTo(sceneX: number, sceneY: number): void;
1781
+ createTo(sceneX: number, sceneY: number, shift?: boolean): void;
1623
1782
  /**
1624
1783
  * 结束画拉:按死区分流落库(一次手势 = 一步历史,undo 整体回退落位 + 尺寸
1625
1784
  * + priority)。先清会话再落文档(commitTextEdit 同门——退出路径级联时幂等):
1626
1785
  * - 死区外:单事务写入「createDefaultLayer 缺省形态 + position 左上角对准
1627
1786
  * 橡皮筋矩形(含吸附修正)+ shape.width/height」并 insertRootLayerInDraft
1628
- * 置顶(priority min−1、push 数组尾);
1787
+ * 置顶(priority min−1、push 数组尾)——尺寸取手势末态钳制结果(含 Shift
1788
+ * 反转末态,钳制源 = 会话预设档,canvas-web-preset-submenu 工单 01);
1629
1789
  * - 死区内(点击兜底,位移按 CREATE_DEAD_ZONE_SCREEN_PX 屏幕 px 随 zoom 折算,
1630
- * ALT_DRAG_DEAD_ZONE_SCREEN_PX 同门):缺省尺寸、左上角对准点击点。
1790
+ * ALT_DRAG_DEAD_ZONE_SCREEN_PX 同门):左上角对准点击点;尺寸按会话预设档
1791
+ * 派生缺省盒(ImageLayer 长边 200 定短边,自由/无载荷 = 工厂 200×150 现状;
1792
+ * 忽略 shift——无位移可供等比约束;其余层型保持工厂缺省)。
1631
1793
  * 落库后自动选中新层并解除武装;返回新层路径(绑定层消费:文本层据此自动
1632
1794
  * 进文本编辑,spec 决策 6)。无会话/无文档空转返回 null。点击兜底不产生
1633
1795
  * 零尺寸层(缺省形态自带可见尺寸)。
1796
+ *
1797
+ * 预设档一次性消费(canvas-web-preset-submenu 工单 01,ADR 0021):文本档
1798
+ * 字号直接生效(不经新层样式槽——字体/行高等槽外字段仍按槽,普通武装语义
1799
+ * 保留);图片档比供死区缺省盒派生。档位随会话捕获,落库后武装与载荷双清
1800
+ * (一次性语义,取消路零残留)。
1801
+ *
1802
+ * 模板表风味(template-table-drag-create 工单 01):会话载荷 templateRowsPath
1803
+ * 非空即分派 createTemplateTable 工厂(死区外 shape = 手势正规化矩形,死区内
1804
+ * 缺省壳 400×120、左上角对准点击点);模板层不自动进文本编辑(文本层专属)。
1634
1805
  */
1635
1806
  endCreate(): LayerPath | null;
1636
1807
  /**
1637
- * 取消画拉(Esc 语义):清橡皮筋会话、命中轴回显与武装态——零文档写入、
1638
- * 零历史步(拖拽期纯视觉因此取消零回退成本,spec 决策 4)。幂等:无会话时
1639
- * 仅解除武装(待命态 Esc 同走此口)。
1808
+ * 取消画拉(Esc 语义):清橡皮筋会话、命中轴回显与武装态(含模板表风味与
1809
+ * 预设载荷)——零文档写入、零历史步(拖拽期纯视觉因此取消零回退成本,spec
1810
+ * 决策 4)。幂等:无会话时仅解除武装(待命态 Esc 同走此口)。
1640
1811
  */
1641
1812
  cancelCreate(): void;
1642
1813
  /**
@@ -1722,14 +1893,18 @@ declare class EditorSession {
1722
1893
  /**
1723
1894
  * 只读偏好(保存 prefs 的读取口):与 store.ui 同源,给宿主一个不用下钻
1724
1895
  * store 的口。读 = getEditorPrefs,写 = applyEditorPrefs,对称成对;帧切片
1725
- * 走 restoreEditorState,两不相混。
1896
+ * 走 restoreEditorState,两不相混。建层比例(nextLayerRatio)已退役不在此
1897
+ * 带出(canvas-web-preset-submenu 工单 01,ADR 0021——预设随武装载荷一次性
1898
+ * 携带,prefs 停写)。
1726
1899
  */
1727
1900
  getEditorPrefs(): EditorPrefsState;
1728
1901
  /**
1729
1902
  * 应用偏好(会话建立时一次性,跨会话恢复 prefs 的写入口):整体替换
1730
1903
  * rulersVisible/anchorExpanded,不进历史;值等写入经 store 短路零通知。
1731
1904
  * 新层样式(text-defaults 工单 01)走宽容读逐字段合并(pickNextTextStylePatch
1732
- * 共享谓词——与捕获同门,缺字/类型不符保留现值)。
1905
+ * 共享谓词——与捕获同门,缺字/类型不符保留现值)。旧快照的 nextLayerRatio
1906
+ * 遗留键宽容忽略(canvas-web-preset-submenu 工单 01:槽退役停读,载荷上多余
1907
+ * 的键无害;schemaVersion 加法演进)。
1733
1908
  */
1734
1909
  applyEditorPrefs(prefs: EditorPrefsState): void;
1735
1910
  /**
@@ -2133,12 +2308,6 @@ declare class EditorSession {
2133
2308
  * 一次调用 = 一步历史。
2134
2309
  */
2135
2310
  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
2311
  /**
2143
2312
  * 模板行加格(spec §3.1):addTemplateCellInDraft 重建路径(末格宽/首格行宽、
2144
2313
  * 零高度耦合),自动选中新格;一次调用 = 一步历史。非模板态 no-op。
@@ -2266,10 +2435,11 @@ declare function hitTest(canvas: Canvas, sceneX: number, sceneY: number, policie
2266
2435
  *
2267
2436
  * 拖拽期两点正规化出橡皮筋矩形(x = min、width = |dx|,y 同,反向拖不翻转);
2268
2437
  * QrCodeLayer 钳 height := width(高随宽从动保持方形,八柄缩放「QR 从动轴不
2269
- * 采纳」同门);橡皮筋左右/上下缘各两点进 resolveSnapPoints——吸附数学零新增,
2270
- * 命中修正整矩形平移并入几何(两点正规化与 QR 方形在修正后原样保持)。死区常量
2271
- * 屏幕像素口径同 SNAP_THRESHOLD_SCREEN_PX(场景阈值 = 阈值 / zoom,缩放无关)。
2272
- * 全模块纯函数、无 DOM;会话编排(武装/落库/解除)在会话门面。
2438
+ * 采纳」同门);可选 ratio(image-ratio-preset 工单 01)长轴驱动钳制橡皮筋到
2439
+ * 目标宽高比;橡皮筋左右/上下缘各两点进 resolveSnapPoints——吸附数学零新增,
2440
+ * 命中修正整矩形平移并入几何(两点正规化、QR 方形与比例钳在修正后原样保持)。
2441
+ * 死区常量屏幕像素口径同 SNAP_THRESHOLD_SCREEN_PX(场景阈值 = 阈值 / zoom,缩放
2442
+ * 无关)。全模块纯函数、无 DOM;会话编排(武装/落库/解除)在会话门面。
2273
2443
  */
2274
2444
 
2275
2445
  /** 画拉死区阈值(css 像素,缩放无关;场景阈值 = 阈值 / zoom):位移不越过即视作
@@ -2282,11 +2452,20 @@ interface CreateRectResult {
2282
2452
  }
2283
2453
  /**
2284
2454
  * 画拉橡皮筋求位:两点正规化(起点场景坐标 + 当前点 → 左上角原点矩形)→
2285
- * QR 钳 height := width → 左右/上下缘各两点对轴集合求位(已有已对齐 delta=0
2286
- * 也回显命中轴的语义,dragTo/resizeTo 同门)→ 修正整矩形平移并入。钳方先于
2287
- * 吸附——QR 的方边(y + width)才是真实的下缘吸附位点。
2288
- */
2289
- declare function createRubberBandRect(type: LayerType, start: Point, current: Point, axes: readonly SnapAxis[], threshold: number): CreateRectResult;
2455
+ * QR 钳 height := width / ratio 长轴驱动钳(两者互斥:QR 层忽略 ratio,恒方
2456
+ * 语义不动——调用缝只对 ImageLayer 传 ratio)→ 左右/上下缘各两点对轴集合求位
2457
+ * (已有已对齐 delta=0 也回显命中轴的语义,dragTo/resizeTo 同门)→ 修正整矩形
2458
+ * 平移并入。钳先于吸附——QR 的方边与比例钳的派生边才是真实的吸附位点。
2459
+ *
2460
+ * ratio 钳(image-ratio-preset 工单 01,spec 决策 3)长轴驱动:|Δx| ≥ |Δy| 时
2461
+ * 宽驱动(height = round(width × h ÷ w),Math.round 对正数 half-up),否则高
2462
+ * 驱动(width = round(height × w ÷ h));钳制在正规化后,反向拖取绝对值镜像
2463
+ * 天然覆盖。
2464
+ */
2465
+ declare function createRubberBandRect(type: LayerType, start: Point, current: Point, axes: readonly SnapAxis[], threshold: number, ratio?: {
2466
+ w: number;
2467
+ h: number;
2468
+ } | null): CreateRectResult;
2290
2469
 
2291
2470
  /**
2292
2471
  * 滚轮意图分类(工单 05,三态)。纯函数:输入只取事件修饰键快照,
@@ -3022,4 +3201,4 @@ declare function memoizeTextPolicies(policies?: TextLayoutPolicies, options?: Me
3022
3201
  */
3023
3202
  declare const PACKAGE_NAME: "@hankchen/canvas-editor";
3024
3203
 
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 };
3204
+ 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 TextPreset, 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, defaultSizeForRatio, deleteLayerInDraft, enumerateExpressionCandidates, enumerateRowsPathCandidates, expressionCallSlotAtEnd, expressionDiagnostics, expressionFragmentAtCursor, findPresetEntry, 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, 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 };