@hankchen/canvas-editor 0.8.0 → 0.9.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 +55 -1
- package/dist/index.js +79 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1471,6 +1471,11 @@ interface TextEditLayout {
|
|
|
1471
1471
|
* 越过死区才插入副本,死区内抬手退化为普通点选。
|
|
1472
1472
|
*/
|
|
1473
1473
|
declare const ALT_DRAG_DEAD_ZONE_SCREEN_PX = 4;
|
|
1474
|
+
/**
|
|
1475
|
+
* 底图转换不可行的原因(canvas-background 工单 05,右键菜单置灰 title 分轨;
|
|
1476
|
+
* null = 可转换)。locked 只由会话查询口产出(ui 分支态,纯函数管不着)。
|
|
1477
|
+
*/
|
|
1478
|
+
type BaseImageConversionBlock = 'not-head-root' | 'not-image' | 'not-covering' | 'hidden' | 'expression-marked' | 'no-image-src' | 'locked';
|
|
1474
1479
|
interface EditorSessionOptions {
|
|
1475
1480
|
scheduleFrame: FrameScheduler;
|
|
1476
1481
|
/** 缩放范围(可配置,缺省 5%–800%) */
|
|
@@ -2099,6 +2104,29 @@ declare class EditorSession {
|
|
|
2099
2104
|
*/
|
|
2100
2105
|
updateCanvasProp(key: 'width' | 'height', value: number, options?: TransactOptions): void;
|
|
2101
2106
|
updateCanvasProp(key: 'background', value: CanvasBackground | null, options?: TransactOptions): void;
|
|
2107
|
+
/**
|
|
2108
|
+
* 底图转换查询(canvas-background 工单 05,右键菜单门态唯一权威):路径处
|
|
2109
|
+
* 图层距「转为画布背景」的阻塞原因,null = 可转换。文档面条件见
|
|
2110
|
+
* baseImageConversionBlockInDoc(豁免同门),此处叠加锁定子树(删除面同门
|
|
2111
|
+
* ——转换含删层,锁定层不出路)。无文档/无路径归 not-head-root。
|
|
2112
|
+
*/
|
|
2113
|
+
baseImageConversionBlock(path: LayerPath | null): BaseImageConversionBlock | null;
|
|
2114
|
+
/**
|
|
2115
|
+
* 底图右键命中解析(canvas-background 工单 05,豁免的命中缝):命中豁免使
|
|
2116
|
+
* 头根覆盖图片层的自身盒退出正常命中面,右键菜单却要能选中它(「转为画布
|
|
2117
|
+
* 背景」的入口前提)——宿主在命中未中时按此兜底解析转换候选,选择落地由
|
|
2118
|
+
* 宿主决定(纯查询零副作用)。预览视图上解析(hitTest 同门)并映射回文档
|
|
2119
|
+
* 身份;左键点选路径不经过这里,豁免行为零改动。
|
|
2120
|
+
*/
|
|
2121
|
+
baseImageAt(sceneX: number, sceneY: number): LayerPath | null;
|
|
2122
|
+
/**
|
|
2123
|
+
* 转为画布背景(canvas-background 工单 05,存量底图出路):选中头根图片层
|
|
2124
|
+
* 的图片引用写入画布背景 image 分量 + 删除该图层,单事务一步历史、整体撤销
|
|
2125
|
+
* (背景与图层都还原)。条件经 baseImageConversionBlock 同一门(违例静默
|
|
2126
|
+
* 空转,无历史步);既有背景色保留(只写 image 分量——先色后图语义不破,
|
|
2127
|
+
* 已有背景图被垫底层的引用接管,同一门下二者本就是同一视觉位)。
|
|
2128
|
+
*/
|
|
2129
|
+
convertSelectionToBackground(): boolean;
|
|
2102
2130
|
/**
|
|
2103
2131
|
* 注入数据源 schema 声明(载荷形态,D1 钉定:声明即 compile(canvas, dataset)
|
|
2104
2132
|
* 收到的 data 载荷形状,根上下文候选 = 载荷顶层键)。声明经
|
|
@@ -2448,6 +2476,15 @@ interface HitTestOptions {
|
|
|
2448
2476
|
*/
|
|
2449
2477
|
readonly lockedPaths?: readonly LayerPath[];
|
|
2450
2478
|
}
|
|
2479
|
+
/**
|
|
2480
|
+
* 全幅判定:底层自身盒 ⊇ 画布矩形(负溢出照算),与视口/缩放无关。
|
|
2481
|
+
* spec「渲染与交互」2026-09-27 拍板的底图豁免(Fabric backgroundImage 不入命中图、
|
|
2482
|
+
* Konva listening(false) 同构):只作用于数组头根层——「数组按 priority 降序、
|
|
2483
|
+
* 头先画垫底」的叠放不变量决定了它是唯一的视觉垫底层。
|
|
2484
|
+
* 双消费者(canvas-background 工单 05):命中豁免与「转为画布背景」转换门同门——
|
|
2485
|
+
* 判定一处收口,两处语义永不漂移。
|
|
2486
|
+
*/
|
|
2487
|
+
declare function coversCanvas(box: LayerBox, canvasWidth: number, canvasHeight: number): boolean;
|
|
2451
2488
|
/**
|
|
2452
2489
|
* 场景坐标命中:返回视觉最上被中图层的路径(未中返回 null)。
|
|
2453
2490
|
* 隐藏根层(layer-panel-ux 工单 10)与锁定根层(canvas-web-layer-lock 工单 01)
|
|
@@ -2455,6 +2492,23 @@ interface HitTestOptions {
|
|
|
2455
2492
|
* 被锁定即不可点选,命中穿透其下方的层。
|
|
2456
2493
|
*/
|
|
2457
2494
|
declare function hitTest(canvas: Canvas, sceneX: number, sceneY: number, policies?: TextLayoutPolicies, options?: HitTestOptions): LayerPath | null;
|
|
2495
|
+
/**
|
|
2496
|
+
* 头根层盒解析(底图判定共用来料):数组头缺失返回 null。命中豁免与「转为画布
|
|
2497
|
+
* 背景」转换门共用此唯一进料(同层、同参盒解析),两处几何语义永不漂移
|
|
2498
|
+
* (canvas-background 工单 05)。
|
|
2499
|
+
*/
|
|
2500
|
+
declare function headRootBox(canvas: Canvas, policies?: TextLayoutPolicies): {
|
|
2501
|
+
layer: Layer;
|
|
2502
|
+
box: LayerBox;
|
|
2503
|
+
} | null;
|
|
2504
|
+
/**
|
|
2505
|
+
* 底图右键命中解析(canvas-background 工单 05):豁免使头根覆盖图片层的自身盒
|
|
2506
|
+
* 退出正常命中面,右键菜单却要能选中它(「转为画布背景」的入口缝)——命中未中
|
|
2507
|
+
* 时按此解析兜底。只解析转换候选:数组头 + 图片层 + 覆盖画布(coversCanvas
|
|
2508
|
+
* 同门)+ 可见 + 未锁定;表达式标记与无图引用照常解析(菜单要能选中它置灰说明)。
|
|
2509
|
+
* 纯查询零副作用——选择落地由调用方决定。
|
|
2510
|
+
*/
|
|
2511
|
+
declare function baseImageCandidateAt(canvas: Canvas, sceneX: number, sceneY: number, policies?: TextLayoutPolicies, options?: HitTestOptions): LayerPath | null;
|
|
2458
2512
|
|
|
2459
2513
|
/**
|
|
2460
2514
|
* 画拉建层橡皮筋求位几何(drag-create 工单 01,术语见根 CONTEXT.md「画拉建层」
|
|
@@ -3263,4 +3317,4 @@ declare function memoizeTextPolicies(policies?: TextLayoutPolicies, options?: Me
|
|
|
3263
3317
|
*/
|
|
3264
3318
|
declare const PACKAGE_NAME: "@hankchen/canvas-editor";
|
|
3265
3319
|
|
|
3266
|
-
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 DataSourceSchemaRejection, 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, type RowsPathPickerEntry, 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, enumerateRowsPathPickerEntries, 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 };
|
|
3320
|
+
export { ALIGN_CORNER_MARGIN_PX, ALT_DRAG_DEAD_ZONE_SCREEN_PX, ARM_CREATE_LAYER_TYPES, type AlignBoxGeometry, type AlignToCanvasMode, type AlignToCanvasOptions, type ArmCreateShortcutAction, type BaseImageConversionBlock, CREATE_DEAD_ZONE_SCREEN_PX, type CanvasEditorState, type CreateGesture, type CreateRectResult, DATE_FORMAT_SUGGESTIONS, DEFAULT_EDITOR_SHORTCUTS, DEFAULT_ZOOM_BOUNDS, type DataSourceSchemaRejection, 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, type RowsPathPickerEntry, 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, baseImageCandidateAt, buildLayerOutline, canCopyLayerAt, canonicalizeTableSyncInDraft, captureStyleSnapshot, clampZoom, classifyEditorShortcut, classifyWheel, cloneLayerSubtree, convertTableToRowsInDraft, convertTableToTemplateInDraft, coversCanvas, createDefaultLayer, createRubberBandRect, createTemplateTable, defaultNextTextStyle, defaultSizeForRatio, deleteLayerInDraft, enumerateExpressionCandidates, enumerateRowsPathCandidates, enumerateRowsPathPickerEntries, expressionCallSlotAtEnd, expressionDiagnostics, expressionFragmentAtCursor, findPresetEntry, fitRect, fitViewport, growRowToCellInDraft, handleResizesHeight, handleResizesWidth, headRootBox, 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
|
@@ -306,6 +306,19 @@ function hitTest(canvas, sceneX, sceneY, policies, options) {
|
|
|
306
306
|
}
|
|
307
307
|
return null;
|
|
308
308
|
}
|
|
309
|
+
function headRootBox(canvas, policies) {
|
|
310
|
+
const layer = canvas.layers[0];
|
|
311
|
+
if (!layer) return null;
|
|
312
|
+
return { layer, box: resolveLayerBox2(layer, 0, 0, canvas.width, canvas.height, policies) };
|
|
313
|
+
}
|
|
314
|
+
function baseImageCandidateAt(canvas, sceneX, sceneY, policies, options) {
|
|
315
|
+
const head = headRootBox(canvas, policies);
|
|
316
|
+
if (head === null || head.layer.type !== "ImageLayer" || head.layer.visible === false) return null;
|
|
317
|
+
const lockedPaths = options?.lockedPaths;
|
|
318
|
+
if (lockedPaths !== void 0 && isLockedPath(["layers", 0], lockedPaths)) return null;
|
|
319
|
+
if (!coversCanvas(head.box, canvas.width, canvas.height)) return null;
|
|
320
|
+
return contains(head.box, sceneX, sceneY) ? ["layers", 0] : null;
|
|
321
|
+
}
|
|
309
322
|
|
|
310
323
|
// src/spatial/snap.ts
|
|
311
324
|
import { resolveLayerBox as resolveLayerBox3 } from "@hankchen/canvas";
|
|
@@ -2328,6 +2341,18 @@ function sameCanvasBackground(a, b) {
|
|
|
2328
2341
|
if (a === null || b === null) return a === b;
|
|
2329
2342
|
return a.color === b.color && a.image === b.image;
|
|
2330
2343
|
}
|
|
2344
|
+
function baseImageConversionBlockInDoc(doc, path, policies) {
|
|
2345
|
+
if (path.length !== 2 || path[0] !== "layers" || path[1] !== 0) return "not-head-root";
|
|
2346
|
+
const head = headRootBox(doc, policies);
|
|
2347
|
+
if (head === null) return "not-head-root";
|
|
2348
|
+
if (head.layer.type !== "ImageLayer") return "not-image";
|
|
2349
|
+
if (!coversCanvas(head.box, doc.width, doc.height)) return "not-covering";
|
|
2350
|
+
const layer = head.layer;
|
|
2351
|
+
if (layer.visible === false) return "hidden";
|
|
2352
|
+
if (layer.expression !== null) return "expression-marked";
|
|
2353
|
+
if (layer.src === null || layer.src.trim() === "") return "no-image-src";
|
|
2354
|
+
return null;
|
|
2355
|
+
}
|
|
2331
2356
|
function clampFindCursor(cursor, count) {
|
|
2332
2357
|
if (count <= 0) return 0;
|
|
2333
2358
|
return Math.min(Math.max(cursor, 0), count - 1);
|
|
@@ -3683,6 +3708,57 @@ var EditorSession = class {
|
|
|
3683
3708
|
draft[key] = value;
|
|
3684
3709
|
}, options);
|
|
3685
3710
|
}
|
|
3711
|
+
/**
|
|
3712
|
+
* 底图转换查询(canvas-background 工单 05,右键菜单门态唯一权威):路径处
|
|
3713
|
+
* 图层距「转为画布背景」的阻塞原因,null = 可转换。文档面条件见
|
|
3714
|
+
* baseImageConversionBlockInDoc(豁免同门),此处叠加锁定子树(删除面同门
|
|
3715
|
+
* ——转换含删层,锁定层不出路)。无文档/无路径归 not-head-root。
|
|
3716
|
+
*/
|
|
3717
|
+
baseImageConversionBlock(path) {
|
|
3718
|
+
const doc = this.store.doc;
|
|
3719
|
+
if (!doc || path === null) return "not-head-root";
|
|
3720
|
+
const block = baseImageConversionBlockInDoc(doc, path, this.textPolicies);
|
|
3721
|
+
if (block !== null) return block;
|
|
3722
|
+
return this.isLocked(path) ? "locked" : null;
|
|
3723
|
+
}
|
|
3724
|
+
/**
|
|
3725
|
+
* 底图右键命中解析(canvas-background 工单 05,豁免的命中缝):命中豁免使
|
|
3726
|
+
* 头根覆盖图片层的自身盒退出正常命中面,右键菜单却要能选中它(「转为画布
|
|
3727
|
+
* 背景」的入口前提)——宿主在命中未中时按此兜底解析转换候选,选择落地由
|
|
3728
|
+
* 宿主决定(纯查询零副作用)。预览视图上解析(hitTest 同门)并映射回文档
|
|
3729
|
+
* 身份;左键点选路径不经过这里,豁免行为零改动。
|
|
3730
|
+
*/
|
|
3731
|
+
baseImageAt(sceneX, sceneY) {
|
|
3732
|
+
const view = this.previewCanvas;
|
|
3733
|
+
if (!view) return null;
|
|
3734
|
+
const hit = baseImageCandidateAt(view, sceneX, sceneY, this.textPolicies, {
|
|
3735
|
+
lockedPaths: this.store.ui.lockedPaths
|
|
3736
|
+
});
|
|
3737
|
+
if (hit === null) return null;
|
|
3738
|
+
const docPath = viewPathToDocPath(view, hit);
|
|
3739
|
+
return docPath ? docPath : null;
|
|
3740
|
+
}
|
|
3741
|
+
/**
|
|
3742
|
+
* 转为画布背景(canvas-background 工单 05,存量底图出路):选中头根图片层
|
|
3743
|
+
* 的图片引用写入画布背景 image 分量 + 删除该图层,单事务一步历史、整体撤销
|
|
3744
|
+
* (背景与图层都还原)。条件经 baseImageConversionBlock 同一门(违例静默
|
|
3745
|
+
* 空转,无历史步);既有背景色保留(只写 image 分量——先色后图语义不破,
|
|
3746
|
+
* 已有背景图被垫底层的引用接管,同一门下二者本就是同一视觉位)。
|
|
3747
|
+
*/
|
|
3748
|
+
convertSelectionToBackground() {
|
|
3749
|
+
const doc = this.store.doc;
|
|
3750
|
+
const path = this.store.ui.selection;
|
|
3751
|
+
if (!doc || path === null) return false;
|
|
3752
|
+
if (this.baseImageConversionBlock(path) !== null) return false;
|
|
3753
|
+
const src = resolveLayer(doc, path).src;
|
|
3754
|
+
this.store.transact((draft) => {
|
|
3755
|
+
const current = normalizeCanvasBackground(draft.background ?? null);
|
|
3756
|
+
draft.background = { color: current?.color ?? null, image: src };
|
|
3757
|
+
deleteLayerInDraft(draft, path);
|
|
3758
|
+
});
|
|
3759
|
+
this.remapPathSlices([], "layers", 0, 0);
|
|
3760
|
+
return true;
|
|
3761
|
+
}
|
|
3686
3762
|
// ---- 数据源 schema 声明(content-completion 工单 03/08):D2 宿主随会话注入 ----
|
|
3687
3763
|
/**
|
|
3688
3764
|
* 注入数据源 schema 声明(载荷形态,D1 钉定:声明即 compile(canvas, dataset)
|
|
@@ -4986,6 +5062,7 @@ export {
|
|
|
4986
5062
|
addTemplateCellInDraft,
|
|
4987
5063
|
alignToCanvasTarget,
|
|
4988
5064
|
applyStyleFieldsInDraft,
|
|
5065
|
+
baseImageCandidateAt,
|
|
4989
5066
|
buildLayerOutline,
|
|
4990
5067
|
canCopyLayerAt,
|
|
4991
5068
|
canonicalizeTableSyncInDraft,
|
|
@@ -4997,6 +5074,7 @@ export {
|
|
|
4997
5074
|
cloneLayerSubtree,
|
|
4998
5075
|
convertTableToRowsInDraft,
|
|
4999
5076
|
convertTableToTemplateInDraft,
|
|
5077
|
+
coversCanvas,
|
|
5000
5078
|
createDefaultLayer,
|
|
5001
5079
|
createRubberBandRect,
|
|
5002
5080
|
createTemplateTable,
|
|
@@ -5015,6 +5093,7 @@ export {
|
|
|
5015
5093
|
growRowToCellInDraft,
|
|
5016
5094
|
handleResizesHeight,
|
|
5017
5095
|
handleResizesWidth,
|
|
5096
|
+
headRootBox,
|
|
5018
5097
|
hitTest,
|
|
5019
5098
|
insertRootLayerAdjacentInDraft,
|
|
5020
5099
|
insertRootLayerInDraft,
|