@hankchen/canvas-editor 0.6.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 +91 -65
- package/dist/index.js +74 -72
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -509,16 +509,20 @@ interface NextTextStyle {
|
|
|
509
509
|
}
|
|
510
510
|
/** 文本预设档位(CONTEXT「文本预设」词条):heading 40 / subheading 28 / body 16 */
|
|
511
511
|
type TextPresetId = 'heading' | 'subheading' | 'body';
|
|
512
|
+
/** 文本预设档位条目(评审整改 F2 查档返回面,RatioPreset 同形):具名 id + 档位字号 */
|
|
513
|
+
interface TextPreset {
|
|
514
|
+
readonly id: TextPresetId;
|
|
515
|
+
readonly fontSize: number;
|
|
516
|
+
}
|
|
512
517
|
/** 文本预设常量(spec 决策 4):v1 只定字号——字体缺口由新层样式槽补 */
|
|
513
|
-
declare const TEXT_PRESETS: readonly
|
|
514
|
-
id: TextPresetId;
|
|
515
|
-
fontSize: number;
|
|
516
|
-
}[];
|
|
518
|
+
declare const TEXT_PRESETS: readonly TextPreset[];
|
|
517
519
|
/** 新层样式槽初值:自工厂 TextLayer 形态派生(工厂缺省是单一事实源,槽跟着走) */
|
|
518
520
|
declare function defaultNextTextStyle(): NextTextStyle;
|
|
519
521
|
/**
|
|
520
522
|
* 建层比例档位(spec 决策 1/2):'free' = 自由钳(工厂行为兜底),其余五个具名
|
|
521
|
-
* 有理数比。v1
|
|
523
|
+
* 有理数比。v1 固定清单、无自定义输入。清单随建层比例槽退役保持不动
|
|
524
|
+
* (canvas-web-preset-submenu 工单 01,ADR 0021):free 仍是「自由」枚举值与
|
|
525
|
+
* Shift 语义引用,具名档由武装预设载荷(armedCreatePreset)一次性携带消费。
|
|
522
526
|
*/
|
|
523
527
|
type RatioPresetId = 'free' | '1:1' | '4:3' | '3:4' | '16:9' | '9:16';
|
|
524
528
|
/** 比例预设档位:具名 id + 有理数宽高比(free 档 ratio = null,即不钳) */
|
|
@@ -531,19 +535,24 @@ interface RatioPreset {
|
|
|
531
535
|
}
|
|
532
536
|
/** 比例预设常量六档(顺序即面板平铺序:自由在前,其余按惯例短比在前) */
|
|
533
537
|
declare const RATIO_PRESETS: readonly RatioPreset[];
|
|
534
|
-
/** 建层比例槽初值:自由(工厂画拉行为兜底) */
|
|
535
|
-
declare function defaultNextLayerRatio(): RatioPresetId;
|
|
536
538
|
/** 档位 → 钳制用有理数比:'free' → null(不钳),具名档 → {w, h} 副本 */
|
|
537
539
|
declare function ratioValue(id: RatioPresetId): {
|
|
538
540
|
w: number;
|
|
539
541
|
h: number;
|
|
540
542
|
} | null;
|
|
541
543
|
/**
|
|
542
|
-
*
|
|
543
|
-
*
|
|
544
|
-
*
|
|
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 只得比例档。
|
|
545
552
|
*/
|
|
546
|
-
declare function
|
|
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;
|
|
547
556
|
/**
|
|
548
557
|
* 死区点击缺省盒的比例派生(spec 决策 3):长边 200 定短边——短边 = round(长边
|
|
549
558
|
* × 短比)(Math.round 对正数 half-up:16:9 → 200×113)。自由档不进本函数
|
|
@@ -895,6 +904,14 @@ interface CreateGesture {
|
|
|
895
904
|
* (G 快捷键 V1 空表语义原样)。
|
|
896
905
|
*/
|
|
897
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;
|
|
898
915
|
/** 起点场景坐标(两点正规化与死区判定基准) */
|
|
899
916
|
startScene: Point;
|
|
900
917
|
/** 当前指针场景坐标 */
|
|
@@ -965,6 +982,17 @@ interface EditorUi {
|
|
|
965
982
|
* 不进 wire(红线 3 延伸),beginLayerCreate 捕获进建层会话;openDocument 重置。
|
|
966
983
|
*/
|
|
967
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;
|
|
968
996
|
/** 进行中的画拉建层橡皮筋会话(拖拽期纯视觉,文档零变更);null = 无 */
|
|
969
997
|
create: CreateGesture | null;
|
|
970
998
|
/** 进行中的文本编辑会话;null = 非编辑态 */
|
|
@@ -986,18 +1014,10 @@ interface EditorUi {
|
|
|
986
1014
|
* 族字段的权威写(updateSpec 捕获)更新槽,建层(endCreate/addRootLayer)
|
|
987
1015
|
* 以槽值覆盖工厂缺省。与锚点折叠同款的面板偏好——openDocument 换文档不重
|
|
988
1016
|
* 置,永不进历史;随工程数据 prefs 桶跨会话持久(宿主通道,内核零 localStorage)。
|
|
1017
|
+
* 文本预设档不写槽(canvas-web-preset-submenu 工单 01,ADR 0021:预设随武装
|
|
1018
|
+
* 载荷一次性携带,槽只保留属性面板信号一种语义)。
|
|
989
1019
|
*/
|
|
990
1020
|
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;
|
|
1001
1021
|
/**
|
|
1002
1022
|
* 数据源 schema 声明(content-completion 工单 03/08,D2 宿主随会话注入):
|
|
1003
1023
|
* 编译产物形状树或降级 null(根级结构性拒绝,注入期经
|
|
@@ -1095,7 +1115,7 @@ declare class EditorStore {
|
|
|
1095
1115
|
get canRedo(): boolean;
|
|
1096
1116
|
/** 打开/替换文档:ui 选择/编辑/重命名会话与双向历史一并重置(新文档不继承旧路径/旧事务);
|
|
1097
1117
|
* 参考线/锁定集合/查找会话/建层武装与画拉会话随当次会话清空(对位轴/文档内容防护/
|
|
1098
|
-
*
|
|
1118
|
+
* 查询词/待命层型不跨文档),标尺显隐/锚点折叠/新层样式作为偏好保留 */
|
|
1099
1119
|
openDocument(canvas: Canvas): void;
|
|
1100
1120
|
/**
|
|
1101
1121
|
* 文档事务唯一入口:produceWithPatches 求新树,无变化即空转(不进历史不通知);
|
|
@@ -1128,10 +1148,11 @@ declare class EditorStore {
|
|
|
1128
1148
|
/**
|
|
1129
1149
|
* 建层武装置/解除(null,drag-create 工单 01);标量值等短路(重复武装同型
|
|
1130
1150
|
* 不通知)。rowsPath(template-table-drag-create 工单 01):模板表风味载荷
|
|
1131
|
-
*
|
|
1132
|
-
*
|
|
1151
|
+
* 与层型一体写;preset(canvas-web-preset-submenu 工单 01):预设载荷与层型
|
|
1152
|
+
* 一体写——同层型同载荷才短路(重复武装同型换载荷要更新),解除(null)
|
|
1153
|
+
* 一律清载荷(rowsPath 与 preset 双清)。
|
|
1133
1154
|
*/
|
|
1134
|
-
setArmedCreate(type: LayerType | null, rowsPath?: string): void;
|
|
1155
|
+
setArmedCreate(type: LayerType | null, rowsPath?: string, preset?: string): void;
|
|
1135
1156
|
/** 画拉橡皮筋会话开始/更新/结束(null);会话对象住 ui 分支,落库在 endCreate 单事务 */
|
|
1136
1157
|
setCreate(gesture: CreateGesture | null): void;
|
|
1137
1158
|
/** 文本编辑会话开始/结束(null);会话住 ui 分支,文本经 commitTextEdit 一次性落文档 */
|
|
@@ -1141,15 +1162,11 @@ declare class EditorStore {
|
|
|
1141
1162
|
/** 锚点折叠区开合:布尔值等短路(重复点击同一态不重绘) */
|
|
1142
1163
|
setAnchorExpanded(open: boolean): void;
|
|
1143
1164
|
/**
|
|
1144
|
-
* 新层样式槽逐字段合并(text-defaults 工单 01
|
|
1145
|
-
*
|
|
1165
|
+
* 新层样式槽逐字段合并(text-defaults 工单 01:捕获/prefs 恢复的统一写入口;
|
|
1166
|
+
* canvas-web-preset-submenu 工单 01 起预设不再写槽):patch 并入现值,五字段
|
|
1167
|
+
* 值等短路(重复写同值零通知),不进历史。
|
|
1146
1168
|
*/
|
|
1147
1169
|
setNextTextStyle(patch: Partial<NextTextStyle>): void;
|
|
1148
|
-
/**
|
|
1149
|
-
* 建层比例槽写入(image-ratio-preset 工单 01:比例预设应用 / prefs 恢复的
|
|
1150
|
-
* 统一写入口):值等短路(重复写同档零通知),仅 ui 通知、不进历史。
|
|
1151
|
-
*/
|
|
1152
|
-
setNextLayerRatio(id: RatioPresetId): void;
|
|
1153
1170
|
/**
|
|
1154
1171
|
* 数据源 schema 声明替换(归一产物或降级 null,校验收口在注入缝不在这里):
|
|
1155
1172
|
* 同引用短路(重复注入同一归一产物不惊动订阅方);仅 ui 通知,不参与重绘
|
|
@@ -1268,7 +1285,12 @@ declare function classifyEditorShortcut(input: EditorShortcutInput, bindings?: r
|
|
|
1268
1285
|
* 仍是内核唯一保存物。
|
|
1269
1286
|
*/
|
|
1270
1287
|
|
|
1271
|
-
/**
|
|
1288
|
+
/**
|
|
1289
|
+
* 快照格式版本:随格式演化单调递增;v1 = 1(宽容读贯彻,restore 不分支此值)。
|
|
1290
|
+
* prefs 桶的 nextLayerRatio 键已随 canvas-web-preset-submenu 工单 01(ADR 0021)
|
|
1291
|
+
* 退役:停写停读、版本不升——旧快照的该键由调用方按宽容读惯例整体忽略(键在
|
|
1292
|
+
* 载荷里多余但无害),加法演进同门前例(text-defaults 工单 01)。
|
|
1293
|
+
*/
|
|
1272
1294
|
declare const EDITOR_STATE_SCHEMA_VERSION = 1;
|
|
1273
1295
|
/** 帧作用域切片:当前打开画布的编辑器状态(工程数据快照的 frames[帧名] 值) */
|
|
1274
1296
|
interface CanvasEditorState {
|
|
@@ -1290,12 +1312,6 @@ interface EditorPrefsState {
|
|
|
1290
1312
|
* 由 applyEditorPrefs 宽容读兜底为现值(会话内即工厂缺省)。
|
|
1291
1313
|
*/
|
|
1292
1314
|
nextTextStyle: NextTextStyle;
|
|
1293
|
-
/**
|
|
1294
|
-
* 建层比例槽(image-ratio-preset 工单 01,CONTEXT「建层比例」词条):随 prefs
|
|
1295
|
-
* 桶跨会话持久(per-模板记忆,「自由」即显式重置档)。schemaVersion 不升——
|
|
1296
|
-
* 加法演进,旧快照缺字段或脏值由 applyEditorPrefs 宽容读回落 'free'。
|
|
1297
|
-
*/
|
|
1298
|
-
nextLayerRatio: RatioPresetId;
|
|
1299
1315
|
}
|
|
1300
1316
|
|
|
1301
1317
|
/**
|
|
@@ -1714,19 +1730,20 @@ declare class EditorSession {
|
|
|
1714
1730
|
/**
|
|
1715
1731
|
* 武装建层(面板新增项/层型快捷键的统一入口,CONTEXT「武装」词条):置 ui
|
|
1716
1732
|
* 分支待命层型,下一次画布按下即开画拉;建层提交或 Esc 即解除——一次性
|
|
1717
|
-
* 待命态,无粘性工具(spec 决策 2
|
|
1733
|
+
* 待命态,无粘性工具(spec 决策 2)。重复武装同型同载荷值等短路零通知。
|
|
1718
1734
|
*
|
|
1719
|
-
* preset(
|
|
1720
|
-
*
|
|
1721
|
-
*
|
|
1722
|
-
*
|
|
1723
|
-
* -
|
|
1724
|
-
*
|
|
1725
|
-
* -
|
|
1726
|
-
*
|
|
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
|
+
* - 交叉类型(文本层带比例档/图片层带文本档)各在对方清单查无此档、不落载荷。
|
|
1727
1744
|
*/
|
|
1728
1745
|
armLayerCreate(type: LayerType, preset?: TextPresetId | RatioPresetId): void;
|
|
1729
|
-
/**
|
|
1746
|
+
/** 解除建层武装(取消入口):仅清待命态(含模板表风味与预设载荷),零副作用。 */
|
|
1730
1747
|
cancelArmLayerCreate(): void;
|
|
1731
1748
|
/**
|
|
1732
1749
|
* 武装模板表建层(canvas-web-template-table-drag-create 工单 01,spec 决策 3):
|
|
@@ -1754,10 +1771,12 @@ declare class EditorSession {
|
|
|
1754
1771
|
* 全部可见根层供轴,copyMode 首移同门)。零文档事务:修正只进会话几何,
|
|
1755
1772
|
* 落库在 endCreate。
|
|
1756
1773
|
*
|
|
1757
|
-
*
|
|
1758
|
-
*
|
|
1759
|
-
*
|
|
1760
|
-
*
|
|
1774
|
+
* 建层预设档(canvas-web-preset-submenu 工单 01,ADR 0021,取代建层比例槽):
|
|
1775
|
+
* 仅 ImageLayer 按会话载荷档钳制(QR 层不传 ratio、恒方语义不动,两钳互斥;
|
|
1776
|
+
* 其余层型无比例语义);无载荷或 free 档 = 自由钳(普通武装恒自由)。
|
|
1777
|
+
* Shift 瞬时反转源 = 生效档(载荷档或自由):档具名按 Shift = 临时自由、
|
|
1778
|
+
* 生效档自由(含无载荷)按 Shift = 临时钳 1:1,按住生效松开还原(逐帧求位、
|
|
1779
|
+
* 不写载荷不改武装态,Figma 惯例的手势瞬时语义)。
|
|
1761
1780
|
*/
|
|
1762
1781
|
createTo(sceneX: number, sceneY: number, shift?: boolean): void;
|
|
1763
1782
|
/**
|
|
@@ -1766,24 +1785,29 @@ declare class EditorSession {
|
|
|
1766
1785
|
* - 死区外:单事务写入「createDefaultLayer 缺省形态 + position 左上角对准
|
|
1767
1786
|
* 橡皮筋矩形(含吸附修正)+ shape.width/height」并 insertRootLayerInDraft
|
|
1768
1787
|
* 置顶(priority min−1、push 数组尾)——尺寸取手势末态钳制结果(含 Shift
|
|
1769
|
-
*
|
|
1788
|
+
* 反转末态,钳制源 = 会话预设档,canvas-web-preset-submenu 工单 01);
|
|
1770
1789
|
* - 死区内(点击兜底,位移按 CREATE_DEAD_ZONE_SCREEN_PX 屏幕 px 随 zoom 折算,
|
|
1771
|
-
* ALT_DRAG_DEAD_ZONE_SCREEN_PX
|
|
1772
|
-
*
|
|
1773
|
-
*
|
|
1790
|
+
* ALT_DRAG_DEAD_ZONE_SCREEN_PX 同门):左上角对准点击点;尺寸按会话预设档
|
|
1791
|
+
* 派生缺省盒(ImageLayer 长边 200 定短边,自由/无载荷 = 工厂 200×150 现状;
|
|
1792
|
+
* 忽略 shift——无位移可供等比约束;其余层型保持工厂缺省)。
|
|
1774
1793
|
* 落库后自动选中新层并解除武装;返回新层路径(绑定层消费:文本层据此自动
|
|
1775
1794
|
* 进文本编辑,spec 决策 6)。无会话/无文档空转返回 null。点击兜底不产生
|
|
1776
1795
|
* 零尺寸层(缺省形态自带可见尺寸)。
|
|
1777
1796
|
*
|
|
1797
|
+
* 预设档一次性消费(canvas-web-preset-submenu 工单 01,ADR 0021):文本档
|
|
1798
|
+
* 字号直接生效(不经新层样式槽——字体/行高等槽外字段仍按槽,普通武装语义
|
|
1799
|
+
* 保留);图片档比供死区缺省盒派生。档位随会话捕获,落库后武装与载荷双清
|
|
1800
|
+
* (一次性语义,取消路零残留)。
|
|
1801
|
+
*
|
|
1778
1802
|
* 模板表风味(template-table-drag-create 工单 01):会话载荷 templateRowsPath
|
|
1779
1803
|
* 非空即分派 createTemplateTable 工厂(死区外 shape = 手势正规化矩形,死区内
|
|
1780
1804
|
* 缺省壳 400×120、左上角对准点击点);模板层不自动进文本编辑(文本层专属)。
|
|
1781
1805
|
*/
|
|
1782
1806
|
endCreate(): LayerPath | null;
|
|
1783
1807
|
/**
|
|
1784
|
-
* 取消画拉(Esc
|
|
1785
|
-
*
|
|
1786
|
-
*
|
|
1808
|
+
* 取消画拉(Esc 语义):清橡皮筋会话、命中轴回显与武装态(含模板表风味与
|
|
1809
|
+
* 预设载荷)——零文档写入、零历史步(拖拽期纯视觉因此取消零回退成本,spec
|
|
1810
|
+
* 决策 4)。幂等:无会话时仅解除武装(待命态 Esc 同走此口)。
|
|
1787
1811
|
*/
|
|
1788
1812
|
cancelCreate(): void;
|
|
1789
1813
|
/**
|
|
@@ -1869,16 +1893,18 @@ declare class EditorSession {
|
|
|
1869
1893
|
/**
|
|
1870
1894
|
* 只读偏好(保存 prefs 的读取口):与 store.ui 同源,给宿主一个不用下钻
|
|
1871
1895
|
* store 的口。读 = getEditorPrefs,写 = applyEditorPrefs,对称成对;帧切片
|
|
1872
|
-
* 走 restoreEditorState
|
|
1896
|
+
* 走 restoreEditorState,两不相混。建层比例(nextLayerRatio)已退役不在此
|
|
1897
|
+
* 带出(canvas-web-preset-submenu 工单 01,ADR 0021——预设随武装载荷一次性
|
|
1898
|
+
* 携带,prefs 停写)。
|
|
1873
1899
|
*/
|
|
1874
1900
|
getEditorPrefs(): EditorPrefsState;
|
|
1875
1901
|
/**
|
|
1876
1902
|
* 应用偏好(会话建立时一次性,跨会话恢复 prefs 的写入口):整体替换
|
|
1877
1903
|
* rulersVisible/anchorExpanded,不进历史;值等写入经 store 短路零通知。
|
|
1878
1904
|
* 新层样式(text-defaults 工单 01)走宽容读逐字段合并(pickNextTextStylePatch
|
|
1879
|
-
*
|
|
1880
|
-
* 工单 01
|
|
1881
|
-
*
|
|
1905
|
+
* 共享谓词——与捕获同门,缺字/类型不符保留现值)。旧快照的 nextLayerRatio
|
|
1906
|
+
* 遗留键宽容忽略(canvas-web-preset-submenu 工单 01:槽退役停读,载荷上多余
|
|
1907
|
+
* 的键无害;schemaVersion 加法演进)。
|
|
1882
1908
|
*/
|
|
1883
1909
|
applyEditorPrefs(prefs: EditorPrefsState): void;
|
|
1884
1910
|
/**
|
|
@@ -3175,4 +3201,4 @@ declare function memoizeTextPolicies(policies?: TextLayoutPolicies, options?: Me
|
|
|
3175
3201
|
*/
|
|
3176
3202
|
declare const PACKAGE_NAME: "@hankchen/canvas-editor";
|
|
3177
3203
|
|
|
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,
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -1226,15 +1226,14 @@ var RATIO_PRESETS = [
|
|
|
1226
1226
|
{ id: "16:9", ratio: { w: 16, h: 9 } },
|
|
1227
1227
|
{ id: "9:16", ratio: { w: 9, h: 16 } }
|
|
1228
1228
|
];
|
|
1229
|
-
function defaultNextLayerRatio() {
|
|
1230
|
-
return "free";
|
|
1231
|
-
}
|
|
1232
1229
|
function ratioValue(id) {
|
|
1233
1230
|
const entry = RATIO_PRESETS.find((candidate) => candidate.id === id);
|
|
1234
1231
|
return entry?.ratio ? { ...entry.ratio } : null;
|
|
1235
1232
|
}
|
|
1236
|
-
function
|
|
1237
|
-
return
|
|
1233
|
+
function findPresetEntry(type, presetId) {
|
|
1234
|
+
if (type === "TextLayer") return TEXT_PRESETS.find((candidate) => candidate.id === presetId);
|
|
1235
|
+
if (type === "ImageLayer") return RATIO_PRESETS.find((candidate) => candidate.id === presetId);
|
|
1236
|
+
return void 0;
|
|
1238
1237
|
}
|
|
1239
1238
|
function defaultSizeForRatio(ratio) {
|
|
1240
1239
|
return ratio.w >= ratio.h ? { width: 200, height: Math.round(200 * ratio.h / ratio.w) } : { width: Math.round(200 * ratio.w / ratio.h), height: 200 };
|
|
@@ -1742,12 +1741,12 @@ var EditorStore = class {
|
|
|
1742
1741
|
resize: null,
|
|
1743
1742
|
armedCreate: null,
|
|
1744
1743
|
armedCreateRowsPath: "",
|
|
1744
|
+
armedCreatePreset: "",
|
|
1745
1745
|
create: null,
|
|
1746
1746
|
editing: null,
|
|
1747
1747
|
renaming: null,
|
|
1748
1748
|
anchorExpanded: false,
|
|
1749
1749
|
nextTextStyle: defaultNextTextStyle(),
|
|
1750
|
-
nextLayerRatio: defaultNextLayerRatio(),
|
|
1751
1750
|
dataSourceSchema: null,
|
|
1752
1751
|
guides: [],
|
|
1753
1752
|
rulersVisible: true,
|
|
@@ -1779,7 +1778,7 @@ var EditorStore = class {
|
|
|
1779
1778
|
}
|
|
1780
1779
|
/** 打开/替换文档:ui 选择/编辑/重命名会话与双向历史一并重置(新文档不继承旧路径/旧事务);
|
|
1781
1780
|
* 参考线/锁定集合/查找会话/建层武装与画拉会话随当次会话清空(对位轴/文档内容防护/
|
|
1782
|
-
*
|
|
1781
|
+
* 查询词/待命层型不跨文档),标尺显隐/锚点折叠/新层样式作为偏好保留 */
|
|
1783
1782
|
openDocument(canvas) {
|
|
1784
1783
|
this.docValue = canvas;
|
|
1785
1784
|
this.undoSteps = [];
|
|
@@ -1792,6 +1791,7 @@ var EditorStore = class {
|
|
|
1792
1791
|
resize: null,
|
|
1793
1792
|
armedCreate: null,
|
|
1794
1793
|
armedCreateRowsPath: "",
|
|
1794
|
+
armedCreatePreset: "",
|
|
1795
1795
|
create: null,
|
|
1796
1796
|
editing: null,
|
|
1797
1797
|
renaming: null,
|
|
@@ -1891,12 +1891,20 @@ var EditorStore = class {
|
|
|
1891
1891
|
/**
|
|
1892
1892
|
* 建层武装置/解除(null,drag-create 工单 01);标量值等短路(重复武装同型
|
|
1893
1893
|
* 不通知)。rowsPath(template-table-drag-create 工单 01):模板表风味载荷
|
|
1894
|
-
*
|
|
1895
|
-
*
|
|
1894
|
+
* 与层型一体写;preset(canvas-web-preset-submenu 工单 01):预设载荷与层型
|
|
1895
|
+
* 一体写——同层型同载荷才短路(重复武装同型换载荷要更新),解除(null)
|
|
1896
|
+
* 一律清载荷(rowsPath 与 preset 双清)。
|
|
1896
1897
|
*/
|
|
1897
|
-
setArmedCreate(type, rowsPath = "") {
|
|
1898
|
-
if (this.uiValue.armedCreate === type && this.uiValue.armedCreateRowsPath === rowsPath)
|
|
1899
|
-
|
|
1898
|
+
setArmedCreate(type, rowsPath = "", preset = "") {
|
|
1899
|
+
if (this.uiValue.armedCreate === type && this.uiValue.armedCreateRowsPath === rowsPath && this.uiValue.armedCreatePreset === preset) {
|
|
1900
|
+
return;
|
|
1901
|
+
}
|
|
1902
|
+
this.uiValue = {
|
|
1903
|
+
...this.uiValue,
|
|
1904
|
+
armedCreate: type,
|
|
1905
|
+
armedCreateRowsPath: type === null ? "" : rowsPath,
|
|
1906
|
+
armedCreatePreset: type === null ? "" : preset
|
|
1907
|
+
};
|
|
1900
1908
|
this.notify({ scope: "ui", branch: "armedCreate" });
|
|
1901
1909
|
}
|
|
1902
1910
|
/** 画拉橡皮筋会话开始/更新/结束(null);会话对象住 ui 分支,落库在 endCreate 单事务 */
|
|
@@ -1920,8 +1928,9 @@ var EditorStore = class {
|
|
|
1920
1928
|
this.notify({ scope: "ui", branch: "anchorExpanded" });
|
|
1921
1929
|
}
|
|
1922
1930
|
/**
|
|
1923
|
-
* 新层样式槽逐字段合并(text-defaults 工单 01
|
|
1924
|
-
*
|
|
1931
|
+
* 新层样式槽逐字段合并(text-defaults 工单 01:捕获/prefs 恢复的统一写入口;
|
|
1932
|
+
* canvas-web-preset-submenu 工单 01 起预设不再写槽):patch 并入现值,五字段
|
|
1933
|
+
* 值等短路(重复写同值零通知),不进历史。
|
|
1925
1934
|
*/
|
|
1926
1935
|
setNextTextStyle(patch) {
|
|
1927
1936
|
const next = { ...this.uiValue.nextTextStyle, ...patch };
|
|
@@ -1929,15 +1938,6 @@ var EditorStore = class {
|
|
|
1929
1938
|
this.uiValue = { ...this.uiValue, nextTextStyle: next };
|
|
1930
1939
|
this.notify({ scope: "ui", branch: "nextTextStyle" });
|
|
1931
1940
|
}
|
|
1932
|
-
/**
|
|
1933
|
-
* 建层比例槽写入(image-ratio-preset 工单 01:比例预设应用 / prefs 恢复的
|
|
1934
|
-
* 统一写入口):值等短路(重复写同档零通知),仅 ui 通知、不进历史。
|
|
1935
|
-
*/
|
|
1936
|
-
setNextLayerRatio(id) {
|
|
1937
|
-
if (this.uiValue.nextLayerRatio === id) return;
|
|
1938
|
-
this.uiValue = { ...this.uiValue, nextLayerRatio: id };
|
|
1939
|
-
this.notify({ scope: "ui", branch: "nextLayerRatio" });
|
|
1940
|
-
}
|
|
1941
1941
|
/**
|
|
1942
1942
|
* 数据源 schema 声明替换(归一产物或降级 null,校验收口在注入缝不在这里):
|
|
1943
1943
|
* 同引用短路(重复注入同一归一产物不惊动订阅方);仅 ui 通知,不参与重绘
|
|
@@ -2912,29 +2912,23 @@ var EditorSession = class {
|
|
|
2912
2912
|
/**
|
|
2913
2913
|
* 武装建层(面板新增项/层型快捷键的统一入口,CONTEXT「武装」词条):置 ui
|
|
2914
2914
|
* 分支待命层型,下一次画布按下即开画拉;建层提交或 Esc 即解除——一次性
|
|
2915
|
-
* 待命态,无粘性工具(spec 决策 2
|
|
2915
|
+
* 待命态,无粘性工具(spec 决策 2)。重复武装同型同载荷值等短路零通知。
|
|
2916
2916
|
*
|
|
2917
|
-
* preset(
|
|
2918
|
-
*
|
|
2919
|
-
*
|
|
2920
|
-
*
|
|
2921
|
-
* -
|
|
2922
|
-
*
|
|
2923
|
-
* -
|
|
2924
|
-
*
|
|
2917
|
+
* preset(canvas-web-preset-submenu 工单 01,ADR 0021):层型相关预设随武装
|
|
2918
|
+
* 载荷一次性携带、**不再写任何偏好槽**——命中档位把档位 id 写进
|
|
2919
|
+
* ui.armedCreatePreset(endCreate 落库一次性消费,取消路零残留);未知 id =
|
|
2920
|
+
* 不落载荷、武装照常(评审口径统一:「空转」只指载荷,武装层型本身仍合法)。
|
|
2921
|
+
* - TextLayer + 文本预设档:载荷命中 TEXT_PRESETS(endCreate 档位字号直接
|
|
2922
|
+
* 生效,不经新层样式槽——普通武装文本按槽的语义不受染指);
|
|
2923
|
+
* - ImageLayer + 比例预设档:载荷命中 RATIO_PRESETS('free' 档载荷行为等价
|
|
2924
|
+
* 自由;QR 恒方是层型硬钳、无比例语义,spec 豁免面);
|
|
2925
|
+
* - 交叉类型(文本层带比例档/图片层带文本档)各在对方清单查无此档、不落载荷。
|
|
2925
2926
|
*/
|
|
2926
2927
|
armLayerCreate(type, preset) {
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
if (entry) this.store.setNextTextStyle({ fontSize: entry.fontSize });
|
|
2930
|
-
}
|
|
2931
|
-
if (preset !== void 0 && type === "ImageLayer") {
|
|
2932
|
-
const entry = RATIO_PRESETS.find((candidate) => candidate.id === preset);
|
|
2933
|
-
if (entry) this.store.setNextLayerRatio(entry.id);
|
|
2934
|
-
}
|
|
2935
|
-
this.store.setArmedCreate(type);
|
|
2928
|
+
const entry = preset === void 0 ? void 0 : findPresetEntry(type, preset);
|
|
2929
|
+
this.store.setArmedCreate(type, "", entry !== void 0 ? entry.id : "");
|
|
2936
2930
|
}
|
|
2937
|
-
/**
|
|
2931
|
+
/** 解除建层武装(取消入口):仅清待命态(含模板表风味与预设载荷),零副作用。 */
|
|
2938
2932
|
cancelArmLayerCreate() {
|
|
2939
2933
|
this.store.setArmedCreate(null);
|
|
2940
2934
|
}
|
|
@@ -2963,9 +2957,11 @@ var EditorSession = class {
|
|
|
2963
2957
|
if (!this.store.doc) return false;
|
|
2964
2958
|
const point = { x: sceneX, y: sceneY };
|
|
2965
2959
|
const templateRowsPath = armed === "TableLayer" && this.store.ui.armedCreateRowsPath !== "" ? this.store.ui.armedCreateRowsPath : void 0;
|
|
2960
|
+
const preset = (armed === "TextLayer" || armed === "ImageLayer") && this.store.ui.armedCreatePreset !== "" ? this.store.ui.armedCreatePreset : void 0;
|
|
2966
2961
|
this.store.setCreate({
|
|
2967
2962
|
type: armed,
|
|
2968
2963
|
templateRowsPath,
|
|
2964
|
+
preset,
|
|
2969
2965
|
startScene: point,
|
|
2970
2966
|
currentScene: point,
|
|
2971
2967
|
rect: { x: sceneX, y: sceneY, width: 0, height: 0 }
|
|
@@ -2981,17 +2977,19 @@ var EditorSession = class {
|
|
|
2981
2977
|
* 全部可见根层供轴,copyMode 首移同门)。零文档事务:修正只进会话几何,
|
|
2982
2978
|
* 落库在 endCreate。
|
|
2983
2979
|
*
|
|
2984
|
-
*
|
|
2985
|
-
*
|
|
2986
|
-
*
|
|
2987
|
-
*
|
|
2980
|
+
* 建层预设档(canvas-web-preset-submenu 工单 01,ADR 0021,取代建层比例槽):
|
|
2981
|
+
* 仅 ImageLayer 按会话载荷档钳制(QR 层不传 ratio、恒方语义不动,两钳互斥;
|
|
2982
|
+
* 其余层型无比例语义);无载荷或 free 档 = 自由钳(普通武装恒自由)。
|
|
2983
|
+
* Shift 瞬时反转源 = 生效档(载荷档或自由):档具名按 Shift = 临时自由、
|
|
2984
|
+
* 生效档自由(含无载荷)按 Shift = 临时钳 1:1,按住生效松开还原(逐帧求位、
|
|
2985
|
+
* 不写载荷不改武装态,Figma 惯例的手势瞬时语义)。
|
|
2988
2986
|
*/
|
|
2989
2987
|
createTo(sceneX, sceneY, shift = false) {
|
|
2990
2988
|
const gesture = this.store.ui.create;
|
|
2991
2989
|
const doc = this.store.doc;
|
|
2992
2990
|
if (!gesture || !doc) return;
|
|
2993
|
-
const
|
|
2994
|
-
const ratio = gesture.type === "ImageLayer" ? shift ?
|
|
2991
|
+
const presetRatio = gesture.type === "ImageLayer" && gesture.preset !== void 0 ? ratioValue(gesture.preset) : null;
|
|
2992
|
+
const ratio = gesture.type === "ImageLayer" ? shift ? presetRatio === null ? { w: 1, h: 1 } : null : presetRatio : null;
|
|
2995
2993
|
const resolution = createRubberBandRect(
|
|
2996
2994
|
gesture.type,
|
|
2997
2995
|
gesture.startScene,
|
|
@@ -3013,15 +3011,20 @@ var EditorSession = class {
|
|
|
3013
3011
|
* - 死区外:单事务写入「createDefaultLayer 缺省形态 + position 左上角对准
|
|
3014
3012
|
* 橡皮筋矩形(含吸附修正)+ shape.width/height」并 insertRootLayerInDraft
|
|
3015
3013
|
* 置顶(priority min−1、push 数组尾)——尺寸取手势末态钳制结果(含 Shift
|
|
3016
|
-
*
|
|
3014
|
+
* 反转末态,钳制源 = 会话预设档,canvas-web-preset-submenu 工单 01);
|
|
3017
3015
|
* - 死区内(点击兜底,位移按 CREATE_DEAD_ZONE_SCREEN_PX 屏幕 px 随 zoom 折算,
|
|
3018
|
-
* ALT_DRAG_DEAD_ZONE_SCREEN_PX
|
|
3019
|
-
*
|
|
3020
|
-
*
|
|
3016
|
+
* ALT_DRAG_DEAD_ZONE_SCREEN_PX 同门):左上角对准点击点;尺寸按会话预设档
|
|
3017
|
+
* 派生缺省盒(ImageLayer 长边 200 定短边,自由/无载荷 = 工厂 200×150 现状;
|
|
3018
|
+
* 忽略 shift——无位移可供等比约束;其余层型保持工厂缺省)。
|
|
3021
3019
|
* 落库后自动选中新层并解除武装;返回新层路径(绑定层消费:文本层据此自动
|
|
3022
3020
|
* 进文本编辑,spec 决策 6)。无会话/无文档空转返回 null。点击兜底不产生
|
|
3023
3021
|
* 零尺寸层(缺省形态自带可见尺寸)。
|
|
3024
3022
|
*
|
|
3023
|
+
* 预设档一次性消费(canvas-web-preset-submenu 工单 01,ADR 0021):文本档
|
|
3024
|
+
* 字号直接生效(不经新层样式槽——字体/行高等槽外字段仍按槽,普通武装语义
|
|
3025
|
+
* 保留);图片档比供死区缺省盒派生。档位随会话捕获,落库后武装与载荷双清
|
|
3026
|
+
* (一次性语义,取消路零残留)。
|
|
3027
|
+
*
|
|
3025
3028
|
* 模板表风味(template-table-drag-create 工单 01):会话载荷 templateRowsPath
|
|
3026
3029
|
* 非空即分派 createTemplateTable 工厂(死区外 shape = 手势正规化矩形,死区内
|
|
3027
3030
|
* 缺省壳 400×120、左上角对准点击点);模板层不自动进文本编辑(文本层专属)。
|
|
@@ -3039,21 +3042,21 @@ var EditorSession = class {
|
|
|
3039
3042
|
const clicked = Math.hypot(dx, dy) <= deadZoneScene;
|
|
3040
3043
|
const index = { v: -1 };
|
|
3041
3044
|
const templateRowsPath = gesture.templateRowsPath;
|
|
3045
|
+
const presetTextEntry = gesture.type === "TextLayer" && gesture.preset !== void 0 ? findPresetEntry(gesture.type, gesture.preset) : void 0;
|
|
3046
|
+
const textDefaults = presetTextEntry ? { ...this.store.ui.nextTextStyle, fontSize: presetTextEntry.fontSize } : this.store.ui.nextTextStyle;
|
|
3047
|
+
const presetRatio = gesture.type === "ImageLayer" && gesture.preset !== void 0 ? ratioValue(gesture.preset) : null;
|
|
3042
3048
|
this.store.transact((draft) => {
|
|
3043
3049
|
const layer = templateRowsPath !== void 0 ? createTemplateTable(
|
|
3044
3050
|
clicked ? { rowsPath: templateRowsPath } : {
|
|
3045
3051
|
rowsPath: templateRowsPath,
|
|
3046
3052
|
shape: { width: gesture.rect.width, height: gesture.rect.height }
|
|
3047
3053
|
}
|
|
3048
|
-
) : createDefaultLayer(gesture.type,
|
|
3054
|
+
) : createDefaultLayer(gesture.type, textDefaults);
|
|
3049
3055
|
if (clicked) {
|
|
3050
|
-
if (gesture.type === "ImageLayer") {
|
|
3051
|
-
const
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
layer.shape.width = size.width;
|
|
3055
|
-
layer.shape.height = size.height;
|
|
3056
|
-
}
|
|
3056
|
+
if (gesture.type === "ImageLayer" && presetRatio) {
|
|
3057
|
+
const size = defaultSizeForRatio(presetRatio);
|
|
3058
|
+
layer.shape.width = size.width;
|
|
3059
|
+
layer.shape.height = size.height;
|
|
3057
3060
|
}
|
|
3058
3061
|
layer.position = { ...layer.position, x: gesture.startScene.x, y: gesture.startScene.y };
|
|
3059
3062
|
} else {
|
|
@@ -3069,9 +3072,9 @@ var EditorSession = class {
|
|
|
3069
3072
|
return path;
|
|
3070
3073
|
}
|
|
3071
3074
|
/**
|
|
3072
|
-
* 取消画拉(Esc
|
|
3073
|
-
*
|
|
3074
|
-
*
|
|
3075
|
+
* 取消画拉(Esc 语义):清橡皮筋会话、命中轴回显与武装态(含模板表风味与
|
|
3076
|
+
* 预设载荷)——零文档写入、零历史步(拖拽期纯视觉因此取消零回退成本,spec
|
|
3077
|
+
* 决策 4)。幂等:无会话时仅解除武装(待命态 Esc 同走此口)。
|
|
3075
3078
|
*/
|
|
3076
3079
|
cancelCreate() {
|
|
3077
3080
|
this.store.setCreate(null);
|
|
@@ -3235,30 +3238,30 @@ var EditorSession = class {
|
|
|
3235
3238
|
/**
|
|
3236
3239
|
* 只读偏好(保存 prefs 的读取口):与 store.ui 同源,给宿主一个不用下钻
|
|
3237
3240
|
* store 的口。读 = getEditorPrefs,写 = applyEditorPrefs,对称成对;帧切片
|
|
3238
|
-
* 走 restoreEditorState
|
|
3241
|
+
* 走 restoreEditorState,两不相混。建层比例(nextLayerRatio)已退役不在此
|
|
3242
|
+
* 带出(canvas-web-preset-submenu 工单 01,ADR 0021——预设随武装载荷一次性
|
|
3243
|
+
* 携带,prefs 停写)。
|
|
3239
3244
|
*/
|
|
3240
3245
|
getEditorPrefs() {
|
|
3241
3246
|
const ui = this.store.ui;
|
|
3242
3247
|
return {
|
|
3243
3248
|
rulersVisible: ui.rulersVisible,
|
|
3244
3249
|
anchorExpanded: ui.anchorExpanded,
|
|
3245
|
-
nextTextStyle: ui.nextTextStyle
|
|
3246
|
-
nextLayerRatio: ui.nextLayerRatio
|
|
3250
|
+
nextTextStyle: ui.nextTextStyle
|
|
3247
3251
|
};
|
|
3248
3252
|
}
|
|
3249
3253
|
/**
|
|
3250
3254
|
* 应用偏好(会话建立时一次性,跨会话恢复 prefs 的写入口):整体替换
|
|
3251
3255
|
* rulersVisible/anchorExpanded,不进历史;值等写入经 store 短路零通知。
|
|
3252
3256
|
* 新层样式(text-defaults 工单 01)走宽容读逐字段合并(pickNextTextStylePatch
|
|
3253
|
-
*
|
|
3254
|
-
* 工单 01
|
|
3255
|
-
*
|
|
3257
|
+
* 共享谓词——与捕获同门,缺字/类型不符保留现值)。旧快照的 nextLayerRatio
|
|
3258
|
+
* 遗留键宽容忽略(canvas-web-preset-submenu 工单 01:槽退役停读,载荷上多余
|
|
3259
|
+
* 的键无害;schemaVersion 加法演进)。
|
|
3256
3260
|
*/
|
|
3257
3261
|
applyEditorPrefs(prefs) {
|
|
3258
3262
|
this.store.setRulersVisible(prefs.rulersVisible);
|
|
3259
3263
|
this.store.setAnchorExpanded(prefs.anchorExpanded);
|
|
3260
3264
|
this.store.setNextTextStyle(pickNextTextStylePatch(prefs.nextTextStyle));
|
|
3261
|
-
this.store.setNextLayerRatio(pickNextLayerRatio(prefs.nextLayerRatio));
|
|
3262
3265
|
}
|
|
3263
3266
|
// ---- 对齐画布(layer-align-snap 工单 01):图层盒整体对齐画布几何 ----
|
|
3264
3267
|
/**
|
|
@@ -4921,7 +4924,6 @@ export {
|
|
|
4921
4924
|
createDefaultLayer,
|
|
4922
4925
|
createRubberBandRect,
|
|
4923
4926
|
createTemplateTable,
|
|
4924
|
-
defaultNextLayerRatio,
|
|
4925
4927
|
defaultNextTextStyle,
|
|
4926
4928
|
defaultSizeForRatio,
|
|
4927
4929
|
deleteLayerInDraft,
|
|
@@ -4930,6 +4932,7 @@ export {
|
|
|
4930
4932
|
expressionCallSlotAtEnd,
|
|
4931
4933
|
expressionDiagnostics,
|
|
4932
4934
|
expressionFragmentAtCursor,
|
|
4935
|
+
findPresetEntry,
|
|
4933
4936
|
fitRect,
|
|
4934
4937
|
fitViewport,
|
|
4935
4938
|
growRowToCellInDraft,
|
|
@@ -4964,7 +4967,6 @@ export {
|
|
|
4964
4967
|
pathStartsWith,
|
|
4965
4968
|
pathsEqual,
|
|
4966
4969
|
phpTrim2 as phpTrim,
|
|
4967
|
-
pickNextLayerRatio,
|
|
4968
4970
|
pickNextTextStylePatch,
|
|
4969
4971
|
prepareRootPaste,
|
|
4970
4972
|
proportionalDrivingAxis,
|