@hankchen/canvas-editor 0.7.0 → 0.7.1
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 +25 -5
- package/dist/index.js +45 -25
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -958,6 +958,12 @@ interface FindSession {
|
|
|
958
958
|
replacement: string;
|
|
959
959
|
cursor: number;
|
|
960
960
|
}
|
|
961
|
+
/** 数据源声明拒绝详情(声明被拒呈现面,死端态整改 2b):reason 为声明期拒绝码、
|
|
962
|
+
* detail 为教学性明细(直取 parseExpressionSchema 拒绝面) */
|
|
963
|
+
interface DataSourceSchemaRejection {
|
|
964
|
+
reason: ExpressionSchemaRejectReason;
|
|
965
|
+
detail: string;
|
|
966
|
+
}
|
|
961
967
|
interface EditorUi {
|
|
962
968
|
viewport: Viewport;
|
|
963
969
|
/** 当前选中图层路径(数组路径,patch path 前缀);null = 无选择 */
|
|
@@ -1027,6 +1033,14 @@ interface EditorUi {
|
|
|
1027
1033
|
* 文档不重置(声明随会话,重注入/清除走同一入口)。
|
|
1028
1034
|
*/
|
|
1029
1035
|
dataSourceSchema: ExpressionSchemaNode | null;
|
|
1036
|
+
/**
|
|
1037
|
+
* 数据源声明拒绝详情(声明被拒呈现面,死端态整改 2b):仅被拒注入在场——
|
|
1038
|
+
* reason/detail 直取 parseExpressionSchema 拒绝面(reserved_root_key /
|
|
1039
|
+
* invalid_schema / open_map_unsupported),宿主读数与绑定面据此区分「未注入」
|
|
1040
|
+
* 与「注入被拒」。只住会话态随 dataSourceSchema 同步置换:合法注入与清除
|
|
1041
|
+
* 归 null;不进 graph、不落 localStorage、不进 wire。
|
|
1042
|
+
*/
|
|
1043
|
+
dataSourceSchemaRejection: DataSourceSchemaRejection | null;
|
|
1030
1044
|
/**
|
|
1031
1045
|
* 参考线(ruler-guides-snap 工单 01,ADR 0012):使用者从标尺拖出的会话级
|
|
1032
1046
|
* 对位轴(水平/垂直、场景坐标)。零契约面——不进历史、不写 graph、保存零
|
|
@@ -1169,10 +1183,11 @@ declare class EditorStore {
|
|
|
1169
1183
|
setNextTextStyle(patch: Partial<NextTextStyle>): void;
|
|
1170
1184
|
/**
|
|
1171
1185
|
* 数据源 schema 声明替换(归一产物或降级 null,校验收口在注入缝不在这里):
|
|
1172
|
-
*
|
|
1186
|
+
* 声明与拒绝详情成对置换(rejection 仅被拒注入在场,2b 呈现面),同引用且
|
|
1187
|
+
* 同拒绝态短路(重复注入同一归一产物不惊动订阅方);仅 ui 通知,不参与重绘
|
|
1173
1188
|
* 脏标(onStoreChange 对该分支短路)。
|
|
1174
1189
|
*/
|
|
1175
|
-
setDataSourceSchema(schema: ExpressionSchemaNode | null): void;
|
|
1190
|
+
setDataSourceSchema(schema: ExpressionSchemaNode | null, rejection?: DataSourceSchemaRejection | null): void;
|
|
1176
1191
|
/** 参考线列表替换(增删动作在会话门面收口);仅 ui 通知,不参与历史 */
|
|
1177
1192
|
setGuides(guides: readonly Guide[]): void;
|
|
1178
1193
|
/** 标尺显隐:布尔值等短路(重复置同态不重绘) */
|
|
@@ -2048,8 +2063,11 @@ declare class EditorSession {
|
|
|
2048
2063
|
updateDataExpression(path: LayerPath, expression: string | null, options?: TransactOptions): void;
|
|
2049
2064
|
/**
|
|
2050
2065
|
* 数据字段取值方式切换(静态 ⇆ 表达式,工单 02 自面板收编内核):表达式现态
|
|
2051
|
-
* → 字面接管(updateData,值保持现镜像);静态现态 →
|
|
2052
|
-
*
|
|
2066
|
+
* → 字面接管(updateData,值保持现镜像);静态现态 → 打标,初值分内容面——
|
|
2067
|
+
* 文本层镜像原文(字面可含合法插值混排),资源层(Image/Qr)只镜像**已合法
|
|
2068
|
+
* 的单引用字面**(静态 ⇆ 表达式往返无损),违例字面(URL/拼接文案)落
|
|
2069
|
+
* 「未选择」空态不镜像——切换自身不得制造必违例初值(死端态整改条目 4;旧
|
|
2070
|
+
* 值可经撤销一步找回)。各为独立一步历史(无 mergeKey)。三内容层分派各取值
|
|
2053
2071
|
* 字段,表/行/格/悬空路径空转。
|
|
2054
2072
|
*
|
|
2055
2073
|
* 活标志防御路由(ADR 0019):路径即编辑中的层时只翻会话活标志(零文档变更
|
|
@@ -2057,6 +2075,8 @@ declare class EditorSession {
|
|
|
2057
2075
|
* 草稿;面板锁定段/pill 显式调用与宿主旁路调用都安全收敛到同一语义。
|
|
2058
2076
|
*/
|
|
2059
2077
|
toggleDataMode(path: LayerPath): void;
|
|
2078
|
+
/** 资源面切换初值:字面已是合法单引用(含空串为「未选择」)才镜像,违例落空态 */
|
|
2079
|
+
private resourceToggleInitial;
|
|
2060
2080
|
/**
|
|
2061
2081
|
* 内容写事务的统一形(会话内容独占工单 02):transact 落库 + 命中编辑层的
|
|
2062
2082
|
* 草稿接管收口——updateData/updateDataExpression/replaceOne/replaceAll 四个
|
|
@@ -3201,4 +3221,4 @@ declare function memoizeTextPolicies(policies?: TextLayoutPolicies, options?: Me
|
|
|
3201
3221
|
*/
|
|
3202
3222
|
declare const PACKAGE_NAME: "@hankchen/canvas-editor";
|
|
3203
3223
|
|
|
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 };
|
|
3224
|
+
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, 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
|
@@ -1004,6 +1004,20 @@ function expressionFragmentAtCursor(scan, cursor) {
|
|
|
1004
1004
|
return null;
|
|
1005
1005
|
}
|
|
1006
1006
|
|
|
1007
|
+
// src/shared/resourcePath.ts
|
|
1008
|
+
function wholeTemplateDiagnostic(template, kind) {
|
|
1009
|
+
return { kind, start: 0, end: template.length, at: { start: 0, end: template.length } };
|
|
1010
|
+
}
|
|
1011
|
+
function resourcePathDiagnostics(template) {
|
|
1012
|
+
const anchored = template.endsWith("\n") ? template.slice(0, -1) : template;
|
|
1013
|
+
const matched = /^\{\{([^{}]*)\}\}$/.exec(anchored);
|
|
1014
|
+
if (matched === null) return [wholeTemplateDiagnostic(template, "resource_not_single_ref")];
|
|
1015
|
+
const path = phpTrim2(matched[1] ?? "");
|
|
1016
|
+
if (path === "") return [wholeTemplateDiagnostic(template, "empty_fragment")];
|
|
1017
|
+
if (path.includes("(")) return [wholeTemplateDiagnostic(template, "resource_function_call")];
|
|
1018
|
+
return [];
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1007
1021
|
// src/editing/alignCanvas.ts
|
|
1008
1022
|
var ALIGN_CORNER_MARGIN_PX = 40;
|
|
1009
1023
|
function alignToCanvasTarget(mode, box, canvasWidth, canvasHeight, margin) {
|
|
@@ -1748,6 +1762,7 @@ var EditorStore = class {
|
|
|
1748
1762
|
anchorExpanded: false,
|
|
1749
1763
|
nextTextStyle: defaultNextTextStyle(),
|
|
1750
1764
|
dataSourceSchema: null,
|
|
1765
|
+
dataSourceSchemaRejection: null,
|
|
1751
1766
|
guides: [],
|
|
1752
1767
|
rulersVisible: true,
|
|
1753
1768
|
snapAxes: [],
|
|
@@ -1940,12 +1955,13 @@ var EditorStore = class {
|
|
|
1940
1955
|
}
|
|
1941
1956
|
/**
|
|
1942
1957
|
* 数据源 schema 声明替换(归一产物或降级 null,校验收口在注入缝不在这里):
|
|
1943
|
-
*
|
|
1958
|
+
* 声明与拒绝详情成对置换(rejection 仅被拒注入在场,2b 呈现面),同引用且
|
|
1959
|
+
* 同拒绝态短路(重复注入同一归一产物不惊动订阅方);仅 ui 通知,不参与重绘
|
|
1944
1960
|
* 脏标(onStoreChange 对该分支短路)。
|
|
1945
1961
|
*/
|
|
1946
|
-
setDataSourceSchema(schema) {
|
|
1947
|
-
if (this.uiValue.dataSourceSchema === schema) return;
|
|
1948
|
-
this.uiValue = { ...this.uiValue, dataSourceSchema: schema };
|
|
1962
|
+
setDataSourceSchema(schema, rejection = null) {
|
|
1963
|
+
if (this.uiValue.dataSourceSchema === schema && this.uiValue.dataSourceSchemaRejection === rejection) return;
|
|
1964
|
+
this.uiValue = { ...this.uiValue, dataSourceSchema: schema, dataSourceSchemaRejection: rejection };
|
|
1949
1965
|
this.notify({ scope: "ui", branch: "dataSourceSchema" });
|
|
1950
1966
|
}
|
|
1951
1967
|
/** 参考线列表替换(增删动作在会话门面收口);仅 ui 通知,不参与历史 */
|
|
@@ -3582,8 +3598,11 @@ var EditorSession = class {
|
|
|
3582
3598
|
}
|
|
3583
3599
|
/**
|
|
3584
3600
|
* 数据字段取值方式切换(静态 ⇆ 表达式,工单 02 自面板收编内核):表达式现态
|
|
3585
|
-
* → 字面接管(updateData,值保持现镜像);静态现态 →
|
|
3586
|
-
*
|
|
3601
|
+
* → 字面接管(updateData,值保持现镜像);静态现态 → 打标,初值分内容面——
|
|
3602
|
+
* 文本层镜像原文(字面可含合法插值混排),资源层(Image/Qr)只镜像**已合法
|
|
3603
|
+
* 的单引用字面**(静态 ⇆ 表达式往返无损),违例字面(URL/拼接文案)落
|
|
3604
|
+
* 「未选择」空态不镜像——切换自身不得制造必违例初值(死端态整改条目 4;旧
|
|
3605
|
+
* 值可经撤销一步找回)。各为独立一步历史(无 mergeKey)。三内容层分派各取值
|
|
3587
3606
|
* 字段,表/行/格/悬空路径空转。
|
|
3588
3607
|
*
|
|
3589
3608
|
* 活标志防御路由(ADR 0019):路径即编辑中的层时只翻会话活标志(零文档变更
|
|
@@ -3605,16 +3624,20 @@ var EditorSession = class {
|
|
|
3605
3624
|
return;
|
|
3606
3625
|
case "ImageLayer":
|
|
3607
3626
|
if (layer.expression !== null) this.updateData(path, layer.src ?? "");
|
|
3608
|
-
else this.updateDataExpression(path, layer.src ?? "");
|
|
3627
|
+
else this.updateDataExpression(path, this.resourceToggleInitial(layer.src ?? ""));
|
|
3609
3628
|
return;
|
|
3610
3629
|
case "QrCodeLayer":
|
|
3611
3630
|
if (layer.expression !== null) this.updateData(path, layer.value);
|
|
3612
|
-
else this.updateDataExpression(path, layer.value);
|
|
3631
|
+
else this.updateDataExpression(path, this.resourceToggleInitial(layer.value));
|
|
3613
3632
|
return;
|
|
3614
3633
|
default:
|
|
3615
3634
|
return;
|
|
3616
3635
|
}
|
|
3617
3636
|
}
|
|
3637
|
+
/** 资源面切换初值:字面已是合法单引用(含空串为「未选择」)才镜像,违例落空态 */
|
|
3638
|
+
resourceToggleInitial(literal) {
|
|
3639
|
+
return resourcePathDiagnostics(literal).length === 0 ? literal : "";
|
|
3640
|
+
}
|
|
3618
3641
|
/**
|
|
3619
3642
|
* 内容写事务的统一形(会话内容独占工单 02):transact 落库 + 命中编辑层的
|
|
3620
3643
|
* 草稿接管收口——updateData/updateDataExpression/replaceOne/replaceAll 四个
|
|
@@ -3658,9 +3681,20 @@ var EditorSession = class {
|
|
|
3658
3681
|
* 换文档不重置,重注入/清除走同一入口。签名与「注入即整体替换」语义不变(D6)。
|
|
3659
3682
|
*/
|
|
3660
3683
|
setDataSourceSchema(raw) {
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3684
|
+
if (raw === null || raw === void 0) {
|
|
3685
|
+
this.store.setDataSourceSchema(null);
|
|
3686
|
+
return;
|
|
3687
|
+
}
|
|
3688
|
+
const schema = normalizeExpressionSchemaSource(raw);
|
|
3689
|
+
if (schema === null) {
|
|
3690
|
+
const parsed = parseExpressionSchema(raw);
|
|
3691
|
+
this.store.setDataSourceSchema(
|
|
3692
|
+
null,
|
|
3693
|
+
parsed.ok ? null : { reason: parsed.reason, detail: parsed.detail }
|
|
3694
|
+
);
|
|
3695
|
+
return;
|
|
3696
|
+
}
|
|
3697
|
+
this.store.setDataSourceSchema(schema);
|
|
3664
3698
|
}
|
|
3665
3699
|
// ---- 上传(工单 13):本机资源 → 可物化引用,实现经 uploadHandler 注入 ----
|
|
3666
3700
|
/** 上传可用性:未注入 uploadHandler 时为 false(宿主据此隐藏/禁用上传入口) */
|
|
@@ -4526,20 +4560,6 @@ function expressionDiagnostics(template) {
|
|
|
4526
4560
|
return found;
|
|
4527
4561
|
}
|
|
4528
4562
|
|
|
4529
|
-
// src/shared/resourcePath.ts
|
|
4530
|
-
function wholeTemplateDiagnostic(template, kind) {
|
|
4531
|
-
return { kind, start: 0, end: template.length, at: { start: 0, end: template.length } };
|
|
4532
|
-
}
|
|
4533
|
-
function resourcePathDiagnostics(template) {
|
|
4534
|
-
const anchored = template.endsWith("\n") ? template.slice(0, -1) : template;
|
|
4535
|
-
const matched = /^\{\{([^{}]*)\}\}$/.exec(anchored);
|
|
4536
|
-
if (matched === null) return [wholeTemplateDiagnostic(template, "resource_not_single_ref")];
|
|
4537
|
-
const path = phpTrim2(matched[1] ?? "");
|
|
4538
|
-
if (path === "") return [wholeTemplateDiagnostic(template, "empty_fragment")];
|
|
4539
|
-
if (path.includes("(")) return [wholeTemplateDiagnostic(template, "resource_function_call")];
|
|
4540
|
-
return [];
|
|
4541
|
-
}
|
|
4542
|
-
|
|
4543
4563
|
// src/shared/expressionFunctions.ts
|
|
4544
4564
|
var EXPRESSION_FUNCTIONS = [
|
|
4545
4565
|
{ name: "date", signature: "date(path[, format])", summary: "\u65E5\u671F\u683C\u5F0F\u5316\uFF08moment \u98CE\u683C token\uFF0C\u9884\u8BBE date/datetime\uFF09" },
|