@hankchen/canvas-editor 0.7.1 → 0.8.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 +46 -4
- package/dist/index.js +72 -15
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LayerBox, Canvas, TextLayoutPolicies, Layer, LayerType, TableLayer, RenderBackend, Padding, HorizontalAlign, VerticalAlign, Anchor, TableRowLayer, TableCellLayer, TableRowTemplateLayer } from '@hankchen/canvas';
|
|
2
|
-
export { ANCHORS, Anchor, Border, BorderSide, Canvas, HORIZONTAL_ALIGNS, HorizontalAlign, LAYER_TYPES, Layer, LayerBox, LayerType, Padding, TableCellLayer, TableLayer, TableRowLayer, TextLayer, VERTICAL_ALIGNS, VerticalAlign } from '@hankchen/canvas';
|
|
1
|
+
import { LayerBox, Canvas, TextLayoutPolicies, Layer, LayerType, TableLayer, RenderBackend, Padding, HorizontalAlign, VerticalAlign, CanvasBackground, Anchor, TableRowLayer, TableCellLayer, TableRowTemplateLayer } from '@hankchen/canvas';
|
|
2
|
+
export { ANCHORS, Anchor, Border, BorderSide, Canvas, CanvasBackground, HORIZONTAL_ALIGNS, HorizontalAlign, LAYER_TYPES, Layer, LayerBox, LayerType, Padding, TableCellLayer, TableLayer, TableRowLayer, TextLayer, VERTICAL_ALIGNS, VerticalAlign } from '@hankchen/canvas';
|
|
3
3
|
import { Draft, Patch } from 'immer';
|
|
4
4
|
export { canvasFontCssFamily } from '@hankchen/canvas-browser-renderer';
|
|
5
5
|
|
|
@@ -2090,8 +2090,15 @@ declare class EditorSession {
|
|
|
2090
2090
|
* commitTextEdit 先清会话再落库,天然不复入接管。
|
|
2091
2091
|
*/
|
|
2092
2092
|
private takeoverDraftIfNeeded;
|
|
2093
|
-
/**
|
|
2093
|
+
/**
|
|
2094
|
+
* 更新画布级字段(未选中图层时面板的写入口):width/height 数值;background
|
|
2095
|
+
* 整对象一步事务(canvas-background 工单 04)——面板各分量提交折算回整对象,
|
|
2096
|
+
* 归一经 normalizeCanvasBackground(空串分量归 null、两分量皆空 = 清背景 null,
|
|
2097
|
+
* 镜像解码语义;条件写键归 encode);结构相同的整对象空转(immer 引义换新
|
|
2098
|
+
* 不产生历史步,数值键的零变更语义同门)。
|
|
2099
|
+
*/
|
|
2094
2100
|
updateCanvasProp(key: 'width' | 'height', value: number, options?: TransactOptions): void;
|
|
2101
|
+
updateCanvasProp(key: 'background', value: CanvasBackground | null, options?: TransactOptions): void;
|
|
2095
2102
|
/**
|
|
2096
2103
|
* 注入数据源 schema 声明(载荷形态,D1 钉定:声明即 compile(canvas, dataset)
|
|
2097
2104
|
* 收到的 data 载荷形状,根上下文候选 = 载荷顶层键)。声明经
|
|
@@ -3144,6 +3151,16 @@ declare function enumerateExpressionCandidates(schema: ExpressionSchemaNode | nu
|
|
|
3144
3151
|
* 给根 schema 表根起点,故独立落件不改 expressionContext);任一层解析不出
|
|
3145
3152
|
* (rowsPath 无 items 声明/漂移/途经非表)→ null 降级无候选。
|
|
3146
3153
|
*
|
|
3154
|
+
* 点选器剪枝枚举件(rows-path-picker 工单 01,spec D5/D3):级联点选器每层的
|
|
3155
|
+
* 候选条目——在补全枚举语义上加剪枝谓词 leadsToArray,候选面收敛至「通往行数组
|
|
3156
|
+
* 的路径」:标量子段不出现;对象子段仅当子树内沿 properties 链至少含一个可达
|
|
3157
|
+
* 数组才出现;数组子段 = 终点条目(isArray 标记),不透传 items(数组套数组的
|
|
3158
|
+
* 内层不可达)。无 partial 概念(纯点选无输入期),前缀 = 已积累点路径、逐段
|
|
3159
|
+
* 全量已消费、尾段取子层;空层/漂移/畸形前缀一律返回空数组(空态呈现归 vue
|
|
3160
|
+
* 面)。起点判别不在此重复造:调用方经 resolveRowsPathStartSchema 得起点后再
|
|
3161
|
+
* 进本件。元信息同表达式补全先例(D8):description/title 两字段分离透传,展示
|
|
3162
|
+
* 回落 description ?? title 归呈现层。
|
|
3163
|
+
*
|
|
3147
3164
|
* 全模块纯函数、零 DOM;层内依赖仅 expressionSchema / expressionCandidates
|
|
3148
3165
|
* (候选类型面)/ layerPath。
|
|
3149
3166
|
*/
|
|
@@ -3166,6 +3183,31 @@ interface RowsPathCandidateResult {
|
|
|
3166
3183
|
* 阻);枚举落点为对象层 → 该层全量合法子项。
|
|
3167
3184
|
*/
|
|
3168
3185
|
declare function enumerateRowsPathCandidates(startSchema: ExpressionSchemaNode | null, input: string): RowsPathCandidateResult | null;
|
|
3186
|
+
/**
|
|
3187
|
+
* 一条 rowsPath 点选器条目(rows-path-picker 工单 01):级联一层的可点项。
|
|
3188
|
+
* 与 RowsPathCandidate 的分叉:无 partial/徽标面,换显式数组终点标记——点选器
|
|
3189
|
+
* 按 isArray 分流「点选提交 / 只可下钻」,不再经「带尾点探一层」推断。
|
|
3190
|
+
*/
|
|
3191
|
+
interface RowsPathPickerEntry {
|
|
3192
|
+
/** 提交/下钻的完整点路径(起点相对;点选器 v-model 面就是它) */
|
|
3193
|
+
path: string;
|
|
3194
|
+
/** 本段名(无元信息时的显示回落) */
|
|
3195
|
+
segment: string;
|
|
3196
|
+
/** 显示名注解(D8 两字段分离透传;展示回落 description ?? title 归呈现层) */
|
|
3197
|
+
title?: string;
|
|
3198
|
+
/** 说明(未声明为 undefined) */
|
|
3199
|
+
description?: string;
|
|
3200
|
+
/** 数组终点标记:true = 行数组终点(点选即提交);false = 对象中间站(只可下钻) */
|
|
3201
|
+
isArray: boolean;
|
|
3202
|
+
}
|
|
3203
|
+
/**
|
|
3204
|
+
* 枚举点选器某层的候选条目(rows-path-picker 工单 01):prefix 为已积累点路径,
|
|
3205
|
+
* 逐段全量已消费、尾段取子层('' = 起点层);下钻域规则走 descendToLayer,每层
|
|
3206
|
+
* 条目经 leadsToArray 剪枝至「通往行数组的路径」。起点 schema null / 前缀漂移
|
|
3207
|
+
* (段缺失/标量落点)/ 畸形(双点/尾点/头点)/ 数组落点(数组不展开)→ 空数组,
|
|
3208
|
+
* 全程不抛错——空态呈现归 vue 面(spec D6)。
|
|
3209
|
+
*/
|
|
3210
|
+
declare function enumerateRowsPathPickerEntries(startSchema: ExpressionSchemaNode | null, prefix: string): readonly RowsPathPickerEntry[];
|
|
3169
3211
|
/**
|
|
3170
3212
|
* rowsPath 编辑起点的三分流判别(D3):无 template 祖先 → 载荷根 schema(根层
|
|
3171
3213
|
* 表;建表表单恒根起点同款);有 template 祖先 → 沿选中路径每个 template 段行
|
|
@@ -3221,4 +3263,4 @@ declare function memoizeTextPolicies(policies?: TextLayoutPolicies, options?: Me
|
|
|
3221
3263
|
*/
|
|
3222
3264
|
declare const PACKAGE_NAME: "@hankchen/canvas-editor";
|
|
3223
3265
|
|
|
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 };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -2317,6 +2317,17 @@ var ALT_DRAG_DEAD_ZONE_SCREEN_PX = 4;
|
|
|
2317
2317
|
var NUDGE_STEP_PX = 1;
|
|
2318
2318
|
var NUDGE_COARSE_STEP_PX = 10;
|
|
2319
2319
|
var nudgeMergeKey = (path) => `nudge:${path.join(":")}`;
|
|
2320
|
+
function normalizeCanvasBackground(value) {
|
|
2321
|
+
if (value === null) return null;
|
|
2322
|
+
const trim = (raw) => typeof raw === "string" && raw.trim() !== "" ? raw : null;
|
|
2323
|
+
const color = trim(value.color);
|
|
2324
|
+
const image = trim(value.image);
|
|
2325
|
+
return color === null && image === null ? null : { color, image };
|
|
2326
|
+
}
|
|
2327
|
+
function sameCanvasBackground(a, b) {
|
|
2328
|
+
if (a === null || b === null) return a === b;
|
|
2329
|
+
return a.color === b.color && a.image === b.image;
|
|
2330
|
+
}
|
|
2320
2331
|
function clampFindCursor(cursor, count) {
|
|
2321
2332
|
if (count <= 0) return 0;
|
|
2322
2333
|
return Math.min(Math.max(cursor, 0), count - 1);
|
|
@@ -3660,9 +3671,15 @@ var EditorSession = class {
|
|
|
3660
3671
|
if (!paths.some((path) => pathsEqual(path, editing.path))) return;
|
|
3661
3672
|
this.store.setEditing({ ...editing, draftSeq: (editing.draftSeq ?? 0) + 1 });
|
|
3662
3673
|
}
|
|
3663
|
-
/** 更新画布级字段(未选中图层时面板的宽/高写入口);键由类型收窄为 width/height */
|
|
3664
3674
|
updateCanvasProp(key, value, options = {}) {
|
|
3665
3675
|
this.store.transact((draft) => {
|
|
3676
|
+
if (key === "background") {
|
|
3677
|
+
const next = normalizeCanvasBackground(value);
|
|
3678
|
+
const current = draft.background ?? null;
|
|
3679
|
+
if (sameCanvasBackground(current, next)) return;
|
|
3680
|
+
draft.background = next;
|
|
3681
|
+
return;
|
|
3682
|
+
}
|
|
3666
3683
|
draft[key] = value;
|
|
3667
3684
|
}, options);
|
|
3668
3685
|
}
|
|
@@ -4761,13 +4778,29 @@ function isArrayNode(node) {
|
|
|
4761
4778
|
function isScalarNode(node) {
|
|
4762
4779
|
return !isArrayNode(node) && node.properties === void 0;
|
|
4763
4780
|
}
|
|
4781
|
+
function joinSegment(prefix, key) {
|
|
4782
|
+
return prefix === "" ? key : `${prefix}.${key}`;
|
|
4783
|
+
}
|
|
4784
|
+
function withMeta(target, node) {
|
|
4785
|
+
if (node.description !== void 0) target.description = node.description;
|
|
4786
|
+
if (node.title !== void 0) target.title = node.title;
|
|
4787
|
+
return target;
|
|
4788
|
+
}
|
|
4789
|
+
function descendToLayer(start, segments) {
|
|
4790
|
+
let base = start;
|
|
4791
|
+
for (const segment of segments) {
|
|
4792
|
+
if (isArrayNode(base)) return null;
|
|
4793
|
+
const child = schemaNodeAtPath(base, [segment]);
|
|
4794
|
+
if (child === null) return null;
|
|
4795
|
+
base = child;
|
|
4796
|
+
}
|
|
4797
|
+
return isArrayNode(base) || isScalarNode(base) ? null : base;
|
|
4798
|
+
}
|
|
4764
4799
|
function childCandidate2(key, node, prefix) {
|
|
4765
|
-
const candidate =
|
|
4766
|
-
path: prefix
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
if (node.description !== void 0) candidate.description = node.description;
|
|
4770
|
-
if (node.title !== void 0) candidate.title = node.title;
|
|
4800
|
+
const candidate = withMeta(
|
|
4801
|
+
{ path: joinSegment(prefix, key), segment: key },
|
|
4802
|
+
node
|
|
4803
|
+
);
|
|
4771
4804
|
if (isArrayNode(node)) candidate.type = "array";
|
|
4772
4805
|
return candidate;
|
|
4773
4806
|
}
|
|
@@ -4786,17 +4819,40 @@ function enumerateRowsPathCandidates(startSchema, input) {
|
|
|
4786
4819
|
const segments = input.split(".");
|
|
4787
4820
|
const partial = input.endsWith(".") ? "" : segments[segments.length - 1];
|
|
4788
4821
|
const completed = segments.slice(0, -1);
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
if (isArrayNode(base)) return null;
|
|
4792
|
-
const child = schemaNodeAtPath(base, [segment]);
|
|
4793
|
-
if (child === null) return null;
|
|
4794
|
-
base = child;
|
|
4795
|
-
}
|
|
4796
|
-
if (isArrayNode(base) || isScalarNode(base)) return null;
|
|
4822
|
+
const base = descendToLayer(startSchema, completed);
|
|
4823
|
+
if (base === null) return null;
|
|
4797
4824
|
const view = levelCandidates(base, completed.join("."));
|
|
4798
4825
|
return { partial, candidates: view };
|
|
4799
4826
|
}
|
|
4827
|
+
function leadsToArray(node) {
|
|
4828
|
+
if (isArrayNode(node)) return true;
|
|
4829
|
+
if (node.properties === void 0) return false;
|
|
4830
|
+
for (const child of node.properties.values()) {
|
|
4831
|
+
if (leadsToArray(child)) return true;
|
|
4832
|
+
}
|
|
4833
|
+
return false;
|
|
4834
|
+
}
|
|
4835
|
+
function pickerEntry(key, node, prefix) {
|
|
4836
|
+
return withMeta(
|
|
4837
|
+
{ path: joinSegment(prefix, key), segment: key, isArray: isArrayNode(node) },
|
|
4838
|
+
node
|
|
4839
|
+
);
|
|
4840
|
+
}
|
|
4841
|
+
function enumerateRowsPathPickerEntries(startSchema, prefix) {
|
|
4842
|
+
if (startSchema === null) return [];
|
|
4843
|
+
const segments = prefix === "" ? [] : prefix.split(".");
|
|
4844
|
+
if (segments.includes("")) return [];
|
|
4845
|
+
const base = descendToLayer(startSchema, segments);
|
|
4846
|
+
if (base === null) return [];
|
|
4847
|
+
const entries = [];
|
|
4848
|
+
if (base.properties !== void 0) {
|
|
4849
|
+
for (const [key, child] of base.properties) {
|
|
4850
|
+
if (!leadsToArray(child)) continue;
|
|
4851
|
+
entries.push(pickerEntry(key, child, prefix));
|
|
4852
|
+
}
|
|
4853
|
+
}
|
|
4854
|
+
return entries;
|
|
4855
|
+
}
|
|
4800
4856
|
function resolveRowsPathStartSchema(doc, path, rootSchema) {
|
|
4801
4857
|
if (rootSchema === null) return null;
|
|
4802
4858
|
if (doc === null || path === null) return rootSchema;
|
|
@@ -4949,6 +5005,7 @@ export {
|
|
|
4949
5005
|
deleteLayerInDraft,
|
|
4950
5006
|
enumerateExpressionCandidates,
|
|
4951
5007
|
enumerateRowsPathCandidates,
|
|
5008
|
+
enumerateRowsPathPickerEntries,
|
|
4952
5009
|
expressionCallSlotAtEnd,
|
|
4953
5010
|
expressionDiagnostics,
|
|
4954
5011
|
expressionFragmentAtCursor,
|