@ptengine/inline-editor 0.1.2 → 0.1.3
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/CHANGELOG.md +10 -0
- package/dist/kernel/ai/aiInlineApply.js +22 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.3
|
|
4
|
+
|
|
5
|
+
**变更**
|
|
6
|
+
- 整页作用域(没选中元素)里 AI 的 `MOVE_ELEMENT`:`targetSelector` 除了被移动元素的祖先,现在也可以是**整页货架里的任意一行**
|
|
7
|
+
—— 「把 FAQ 整块挪到另一个区块后面」这类调换区块顺序的改动终于能落地(此前一律 `INVALID_MOVE_TARGET`)。
|
|
8
|
+
仍然拒绝:不在货架上的(编出来的)target、被移动元素自己、在被移动元素里面的行(防环,靠建货架时记的祖先链判)、
|
|
9
|
+
AI 插入的行(没有祖先链,判不了环)、命中不唯一的 target。`detail` 分别写明是哪一种。
|
|
10
|
+
- AI 插入的元素(`[ai-inserted]` 行)现在可以被挪到货架行旁边:落点异常时直接挪走,不必再插一份。
|
|
11
|
+
- 选中元素时(元素作用域 / 授权票)规则不变:只认祖先。
|
|
12
|
+
|
|
3
13
|
## 0.1.2
|
|
4
14
|
|
|
5
15
|
全部是新增:扩展不支持契约 v11 `feature:node-fields`(取树不回 `facts`)时,货架行与原来逐字一致。
|
|
@@ -68,6 +68,18 @@ function parseHttpUrl(raw) {
|
|
|
68
68
|
}
|
|
69
69
|
return parsed.protocol === 'http:' || parsed.protocol === 'https:' ? parsed : null;
|
|
70
70
|
}
|
|
71
|
+
function pageMoveTargetProblem(selector, target, scope) {
|
|
72
|
+
if (target === selector)
|
|
73
|
+
return `target is the moved element: ${target}`;
|
|
74
|
+
if (!(scope.descendants?.() ?? []).includes(target))
|
|
75
|
+
return `not on the page shelf: ${target}`;
|
|
76
|
+
const chain = scope.ancestorsOf?.(target);
|
|
77
|
+
if (!chain)
|
|
78
|
+
return `target position unknown (AI-inserted): ${target}`;
|
|
79
|
+
if (chain.includes(selector))
|
|
80
|
+
return `target is inside the moved element: ${target}`;
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
71
83
|
export async function applyAiChanges(changes, deps) {
|
|
72
84
|
const applied = [];
|
|
73
85
|
const rejected = [];
|
|
@@ -320,13 +332,16 @@ export async function applyAiChanges(changes, deps) {
|
|
|
320
332
|
}
|
|
321
333
|
const target = change.targetSelector ?? '';
|
|
322
334
|
const moveAncestors = deps.scope.ancestorsOf?.(selector) ?? deps.scope.ancestors;
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
335
|
+
const pageScope = !grantHit && !!deps.scope.ancestorsOf;
|
|
336
|
+
const targetProblem = !target
|
|
337
|
+
? 'not an ancestor: (empty)'
|
|
338
|
+
: moveAncestors.includes(target)
|
|
339
|
+
? null
|
|
340
|
+
: pageScope
|
|
341
|
+
? pageMoveTargetProblem(selector, target, deps.scope)
|
|
342
|
+
: `not an ancestor: ${target}`;
|
|
343
|
+
if (targetProblem) {
|
|
344
|
+
rejected.push({ index, selector, reason: 'INVALID_MOVE_TARGET', detail: targetProblem });
|
|
330
345
|
continue;
|
|
331
346
|
}
|
|
332
347
|
let targetHit;
|