@aglyn/besigner 1.0.0-beta.143
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/LICENSE +201 -0
- package/README.md +7 -0
- package/package.json +48 -0
- package/src/besigner.d.ts +28 -0
- package/src/besigner.js +59 -0
- package/src/besigner.js.map +1 -0
- package/src/index.d.ts +17 -0
- package/src/index.js +18 -0
- package/src/index.js.map +1 -0
- package/src/lib/api/app.api.d.ts +22 -0
- package/src/lib/api/app.api.js +59 -0
- package/src/lib/api/app.api.js.map +1 -0
- package/src/lib/api/besigner.api.d.ts +24 -0
- package/src/lib/api/besigner.api.js +39 -0
- package/src/lib/api/besigner.api.js.map +1 -0
- package/src/lib/clipboard-manager/clipboard-manager.d.ts +89 -0
- package/src/lib/clipboard-manager/clipboard-manager.js +241 -0
- package/src/lib/clipboard-manager/clipboard-manager.js.map +1 -0
- package/src/lib/clipboard-manager/clipboard-mirror.d.ts +52 -0
- package/src/lib/clipboard-manager/clipboard-mirror.js +75 -0
- package/src/lib/clipboard-manager/clipboard-mirror.js.map +1 -0
- package/src/lib/clipboard-manager/index.d.ts +20 -0
- package/src/lib/clipboard-manager/index.js +23 -0
- package/src/lib/clipboard-manager/index.js.map +1 -0
- package/src/lib/clipboard-manager/style-clipboard.d.ts +77 -0
- package/src/lib/clipboard-manager/style-clipboard.js +173 -0
- package/src/lib/clipboard-manager/style-clipboard.js.map +1 -0
- package/src/lib/constants/_internal.d.ts +20 -0
- package/src/lib/constants/_internal.js +19 -0
- package/src/lib/constants/_internal.js.map +1 -0
- package/src/lib/constants/besigner.d.ts +78 -0
- package/src/lib/constants/besigner.js +69 -0
- package/src/lib/constants/besigner.js.map +1 -0
- package/src/lib/controllers/besigner-app.controller.d.ts +33 -0
- package/src/lib/controllers/besigner-app.controller.js +57 -0
- package/src/lib/controllers/besigner-app.controller.js.map +1 -0
- package/src/lib/controllers/besigner-interface.controller.d.ts +44 -0
- package/src/lib/controllers/besigner-interface.controller.js +130 -0
- package/src/lib/controllers/besigner-interface.controller.js.map +1 -0
- package/src/lib/definitions/besigner-app.types.d.ts +41 -0
- package/src/lib/definitions/besigner-app.types.js +18 -0
- package/src/lib/definitions/besigner-app.types.js.map +1 -0
- package/src/lib/definitions/besigner-interface.types.d.ts +106 -0
- package/src/lib/definitions/besigner-interface.types.js +18 -0
- package/src/lib/definitions/besigner-interface.types.js.map +1 -0
- package/src/lib/definitions/emitter.types.d.ts +33 -0
- package/src/lib/definitions/emitter.types.js +18 -0
- package/src/lib/definitions/emitter.types.js.map +1 -0
- package/src/lib/device-preview-width.d.ts +39 -0
- package/src/lib/device-preview-width.js +57 -0
- package/src/lib/device-preview-width.js.map +1 -0
- package/src/lib/dnd-manager/confirm-valid-lineal-relationship.d.ts +54 -0
- package/src/lib/dnd-manager/confirm-valid-lineal-relationship.js +109 -0
- package/src/lib/dnd-manager/confirm-valid-lineal-relationship.js.map +1 -0
- package/src/lib/dnd-manager/dnd-manager.d.ts +75 -0
- package/src/lib/dnd-manager/dnd-manager.js +337 -0
- package/src/lib/dnd-manager/dnd-manager.js.map +1 -0
- package/src/lib/dnd-manager/droppable-region-utils.d.ts +72 -0
- package/src/lib/dnd-manager/droppable-region-utils.js +115 -0
- package/src/lib/dnd-manager/droppable-region-utils.js.map +1 -0
- package/src/lib/dnd-manager/index.d.ts +20 -0
- package/src/lib/dnd-manager/index.js +21 -0
- package/src/lib/dnd-manager/index.js.map +1 -0
- package/src/lib/focus-manager/focus-manager.d.ts +104 -0
- package/src/lib/focus-manager/focus-manager.js +353 -0
- package/src/lib/focus-manager/focus-manager.js.map +1 -0
- package/src/lib/focus-manager/index.d.ts +18 -0
- package/src/lib/focus-manager/index.js +19 -0
- package/src/lib/focus-manager/index.js.map +1 -0
- package/src/lib/is-root-element-id.d.ts +19 -0
- package/src/lib/is-root-element-id.js +22 -0
- package/src/lib/is-root-element-id.js.map +1 -0
- package/src/lib/managers.d.ts +25 -0
- package/src/lib/managers.js +26 -0
- package/src/lib/managers.js.map +1 -0
- package/src/lib/node-move/index.d.ts +17 -0
- package/src/lib/node-move/index.js +18 -0
- package/src/lib/node-move/index.js.map +1 -0
- package/src/lib/node-move/node-move.d.ts +80 -0
- package/src/lib/node-move/node-move.js +134 -0
- package/src/lib/node-move/node-move.js.map +1 -0
- package/src/lib/node-refs/index.d.ts +1 -0
- package/src/lib/node-refs/index.js +3 -0
- package/src/lib/node-refs/index.js.map +1 -0
- package/src/lib/node-refs/node-refs.d.ts +24 -0
- package/src/lib/node-refs/node-refs.js +30 -0
- package/src/lib/node-refs/node-refs.js.map +1 -0
- package/src/lib/pick-manager/index.d.ts +18 -0
- package/src/lib/pick-manager/index.js +20 -0
- package/src/lib/pick-manager/index.js.map +1 -0
- package/src/lib/pick-manager/pick-manager.d.ts +64 -0
- package/src/lib/pick-manager/pick-manager.js +116 -0
- package/src/lib/pick-manager/pick-manager.js.map +1 -0
- package/src/lib/text-entry/index.d.ts +17 -0
- package/src/lib/text-entry/index.js +18 -0
- package/src/lib/text-entry/index.js.map +1 -0
- package/src/lib/text-entry/text-entry.d.ts +71 -0
- package/src/lib/text-entry/text-entry.js +103 -0
- package/src/lib/text-entry/text-entry.js.map +1 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ import { checkLinealOrder, components, LinealDirectiveFlag } from "@aglyn/aglyn";
|
|
17
|
+
import { _isArr } from "@aglyn/shared-util-tools";
|
|
18
|
+
export var InvalidLinealRelationFlag = /*#__PURE__*/ function(InvalidLinealRelationFlag) {
|
|
19
|
+
InvalidLinealRelationFlag[InvalidLinealRelationFlag["DISALLOW"] = 0x01] = "DISALLOW";
|
|
20
|
+
InvalidLinealRelationFlag[InvalidLinealRelationFlag["LIMIT_TO"] = 0x02] = "LIMIT_TO";
|
|
21
|
+
InvalidLinealRelationFlag[InvalidLinealRelationFlag["ITEM"] = 0x04] = "ITEM";
|
|
22
|
+
InvalidLinealRelationFlag[InvalidLinealRelationFlag["PARENT"] = 0x08] = "PARENT";
|
|
23
|
+
InvalidLinealRelationFlag[InvalidLinealRelationFlag["COMPONENT"] = 0x10] = "COMPONENT";
|
|
24
|
+
InvalidLinealRelationFlag[InvalidLinealRelationFlag["BUNDLE"] = 0x20] = "BUNDLE";
|
|
25
|
+
InvalidLinealRelationFlag[InvalidLinealRelationFlag["DISALLOW_COMPONENT"] = 17] = "DISALLOW_COMPONENT";
|
|
26
|
+
InvalidLinealRelationFlag[InvalidLinealRelationFlag["DISALLOW_BUNDLE"] = 33] = "DISALLOW_BUNDLE";
|
|
27
|
+
InvalidLinealRelationFlag[InvalidLinealRelationFlag["LIMIT_TO_COMPONENT"] = 18] = "LIMIT_TO_COMPONENT";
|
|
28
|
+
InvalidLinealRelationFlag[InvalidLinealRelationFlag["LIMIT_TO_BUNDLE"] = 34] = "LIMIT_TO_BUNDLE";
|
|
29
|
+
InvalidLinealRelationFlag[InvalidLinealRelationFlag["DISALLOW_COMPONENT_ITEM"] = 21] = "DISALLOW_COMPONENT_ITEM";
|
|
30
|
+
InvalidLinealRelationFlag[InvalidLinealRelationFlag["DISALLOW_BUNDLE_ITEM"] = 37] = "DISALLOW_BUNDLE_ITEM";
|
|
31
|
+
InvalidLinealRelationFlag[InvalidLinealRelationFlag["LIMIT_TO_COMPONENT_ITEM"] = 22] = "LIMIT_TO_COMPONENT_ITEM";
|
|
32
|
+
InvalidLinealRelationFlag[InvalidLinealRelationFlag["LIMIT_TO_BUNDLE_ITEM"] = 38] = "LIMIT_TO_BUNDLE_ITEM";
|
|
33
|
+
InvalidLinealRelationFlag[InvalidLinealRelationFlag["DISALLOW_COMPONENT_PARENT"] = 25] = "DISALLOW_COMPONENT_PARENT";
|
|
34
|
+
InvalidLinealRelationFlag[InvalidLinealRelationFlag["DISALLOW_BUNDLE_PARENT"] = 41] = "DISALLOW_BUNDLE_PARENT";
|
|
35
|
+
InvalidLinealRelationFlag[InvalidLinealRelationFlag["LIMIT_TO_COMPONENT_PARENT"] = 26] = "LIMIT_TO_COMPONENT_PARENT";
|
|
36
|
+
InvalidLinealRelationFlag[InvalidLinealRelationFlag["LIMIT_TO_BUNDLE_PARENT"] = 42] = "LIMIT_TO_BUNDLE_PARENT";
|
|
37
|
+
return InvalidLinealRelationFlag;
|
|
38
|
+
}({});
|
|
39
|
+
function validateLinealOrder(componentId, pluginId, linealOrder, governor) {
|
|
40
|
+
// The rule itself is shared with the AI node-tree validator (AGL-2905);
|
|
41
|
+
// what stays here is the bitflag vocabulary the drop indicator reads.
|
|
42
|
+
const failed = checkLinealOrder(componentId, pluginId, linealOrder);
|
|
43
|
+
if (failed === 'component') {
|
|
44
|
+
throw 17 | governor;
|
|
45
|
+
}
|
|
46
|
+
if (failed === 'plugin') {
|
|
47
|
+
throw 33 | governor;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function componentLabel(componentId) {
|
|
51
|
+
var _components_getLabel;
|
|
52
|
+
if (!componentId) return undefined;
|
|
53
|
+
return (_components_getLabel = components.getLabel(componentId)) != null ? _components_getLabel : componentId;
|
|
54
|
+
}
|
|
55
|
+
function allowedComponentLabels(linealOrder) {
|
|
56
|
+
if (!linealOrder) return [];
|
|
57
|
+
const [directiveType, directiveDefinition] = linealOrder;
|
|
58
|
+
if (directiveType !== LinealDirectiveFlag.LIMIT_TO) return [];
|
|
59
|
+
const components = _isArr(directiveDefinition) ? directiveDefinition : directiveDefinition == null ? void 0 : directiveDefinition.components;
|
|
60
|
+
return (components != null ? components : []).map((id)=>componentLabel(id)).filter(Boolean);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Human-readable explanation for a failed lineal validation, e.g.
|
|
64
|
+
* "Toolbar Content must be placed inside App Bar". Pair with the reason
|
|
65
|
+
* flag returned by {@link confirmValidLinealRelationship}.
|
|
66
|
+
*/ export function describeInvalidLinealRelationship(item, parent, reason) {
|
|
67
|
+
var _componentLabel, _componentLabel1;
|
|
68
|
+
const itemLabel = (_componentLabel = componentLabel(item.componentId)) != null ? _componentLabel : 'This element';
|
|
69
|
+
const parentLabel = parent.componentId && parent.componentId !== 'div' ? (_componentLabel1 = componentLabel(parent.componentId)) != null ? _componentLabel1 : parent.componentId : 'the document';
|
|
70
|
+
// ITEM governor: the dragged element's own restrictParent failed.
|
|
71
|
+
if (reason & 0x04) {
|
|
72
|
+
const allowed = allowedComponentLabels(item.restrictParent);
|
|
73
|
+
if (allowed.length) {
|
|
74
|
+
return `${itemLabel} must be placed inside ${allowed.join(' or ')}`;
|
|
75
|
+
}
|
|
76
|
+
return `${itemLabel} can't be placed inside ${parentLabel}`;
|
|
77
|
+
}
|
|
78
|
+
// PARENT governor: the target's restrictChildren failed.
|
|
79
|
+
const allowed = allowedComponentLabels(parent.restrictChildren);
|
|
80
|
+
if (allowed.length) {
|
|
81
|
+
return `${parentLabel} only accepts ${allowed.join(', ')}`;
|
|
82
|
+
}
|
|
83
|
+
return `${parentLabel} doesn't accept ${itemLabel}`;
|
|
84
|
+
}
|
|
85
|
+
export function confirmValidLinealRelationship(item, parent) {
|
|
86
|
+
try {
|
|
87
|
+
if (item.restrictParent) {
|
|
88
|
+
validateLinealOrder(parent.componentId, parent.pluginId, item.restrictParent, 0x04);
|
|
89
|
+
}
|
|
90
|
+
if (parent.restrictChildren) {
|
|
91
|
+
validateLinealOrder(item.componentId, item.pluginId, parent.restrictChildren, 0x08);
|
|
92
|
+
}
|
|
93
|
+
} catch (e) {
|
|
94
|
+
console.error(e);
|
|
95
|
+
if (typeof e === 'number') {
|
|
96
|
+
return [
|
|
97
|
+
false,
|
|
98
|
+
e
|
|
99
|
+
];
|
|
100
|
+
}
|
|
101
|
+
throw e;
|
|
102
|
+
}
|
|
103
|
+
return [
|
|
104
|
+
true
|
|
105
|
+
];
|
|
106
|
+
}
|
|
107
|
+
export default confirmValidLinealRelationship;
|
|
108
|
+
|
|
109
|
+
//# sourceMappingURL=confirm-valid-lineal-relationship.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/besigner/core/src/lib/dnd-manager/confirm-valid-lineal-relationship.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2022 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type * as Aglyn from '@aglyn/aglyn'\nimport { checkLinealOrder, components, LinealDirectiveFlag } from '@aglyn/aglyn'\nimport { _isArr } from '@aglyn/shared-util-tools'\n\nexport enum InvalidLinealRelationFlag {\n DISALLOW = 0x01,\n LIMIT_TO = 0x02,\n\n ITEM = 0x04,\n PARENT = 0x08,\n\n COMPONENT = 0x10,\n BUNDLE = 0x20,\n\n DISALLOW_COMPONENT = DISALLOW | COMPONENT,\n DISALLOW_BUNDLE = DISALLOW | BUNDLE,\n LIMIT_TO_COMPONENT = LIMIT_TO | COMPONENT,\n LIMIT_TO_BUNDLE = LIMIT_TO | BUNDLE,\n\n DISALLOW_COMPONENT_ITEM = DISALLOW_COMPONENT | ITEM,\n DISALLOW_BUNDLE_ITEM = DISALLOW_BUNDLE | ITEM,\n LIMIT_TO_COMPONENT_ITEM = LIMIT_TO_COMPONENT | ITEM,\n LIMIT_TO_BUNDLE_ITEM = LIMIT_TO_BUNDLE | ITEM,\n\n DISALLOW_COMPONENT_PARENT = DISALLOW_COMPONENT | PARENT,\n DISALLOW_BUNDLE_PARENT = DISALLOW_BUNDLE | PARENT,\n LIMIT_TO_COMPONENT_PARENT = LIMIT_TO_COMPONENT | PARENT,\n LIMIT_TO_BUNDLE_PARENT = LIMIT_TO_BUNDLE | PARENT,\n}\n\nexport type ConfirmValidLinealRelationshipResponse =\n [isValid: true] | [isValid: false, reason: InvalidLinealRelationFlag]\n\nfunction validateLinealOrder(\n componentId: Aglyn.ComponentId,\n pluginId: Aglyn.PluginId,\n linealOrder: Aglyn.ComponentsLinealOrder,\n governor:\n | typeof InvalidLinealRelationFlag.ITEM\n | typeof InvalidLinealRelationFlag.PARENT,\n) {\n // The rule itself is shared with the AI node-tree validator (AGL-2905);\n // what stays here is the bitflag vocabulary the drop indicator reads.\n const failed = checkLinealOrder(componentId, pluginId, linealOrder)\n if (failed === 'component') {\n throw InvalidLinealRelationFlag.DISALLOW_COMPONENT | governor\n }\n if (failed === 'plugin') {\n throw InvalidLinealRelationFlag.DISALLOW_BUNDLE | governor\n }\n}\n\nexport type LinealItem = {\n componentId?: Aglyn.ComponentId\n pluginId?: Aglyn.PluginId\n restrictParent?: Aglyn.ComponentsLinealOrder\n restrictChildren?: Aglyn.ComponentsLinealOrder\n}\n\nfunction componentLabel(componentId?: Aglyn.ComponentId): string | undefined {\n if (!componentId) return undefined\n return components.getLabel(componentId) ?? componentId\n}\n\nfunction allowedComponentLabels(\n linealOrder?: Aglyn.ComponentsLinealOrder,\n): string[] {\n if (!linealOrder) return []\n const [directiveType, directiveDefinition] = linealOrder\n if (directiveType !== LinealDirectiveFlag.LIMIT_TO) return []\n const components = _isArr(directiveDefinition)\n ? directiveDefinition\n : directiveDefinition?.components\n return (components ?? [])\n .map((id) => componentLabel(id))\n .filter(Boolean) as string[]\n}\n\n/**\n * Human-readable explanation for a failed lineal validation, e.g.\n * \"Toolbar Content must be placed inside App Bar\". Pair with the reason\n * flag returned by {@link confirmValidLinealRelationship}.\n */\nexport function describeInvalidLinealRelationship(\n item: LinealItem,\n parent: LinealItem,\n reason: InvalidLinealRelationFlag,\n): string {\n const itemLabel = componentLabel(item.componentId) ?? 'This element'\n const parentLabel =\n parent.componentId && parent.componentId !== 'div'\n ? (componentLabel(parent.componentId) ?? parent.componentId)\n : 'the document'\n\n // ITEM governor: the dragged element's own restrictParent failed.\n if (reason & InvalidLinealRelationFlag.ITEM) {\n const allowed = allowedComponentLabels(item.restrictParent)\n if (allowed.length) {\n return `${itemLabel} must be placed inside ${allowed.join(' or ')}`\n }\n return `${itemLabel} can't be placed inside ${parentLabel}`\n }\n\n // PARENT governor: the target's restrictChildren failed.\n const allowed = allowedComponentLabels(parent.restrictChildren)\n if (allowed.length) {\n return `${parentLabel} only accepts ${allowed.join(', ')}`\n }\n return `${parentLabel} doesn't accept ${itemLabel}`\n}\n\nexport function confirmValidLinealRelationship(\n item: LinealItem,\n parent: LinealItem,\n): ConfirmValidLinealRelationshipResponse {\n try {\n if (item.restrictParent) {\n validateLinealOrder(\n parent.componentId,\n parent.pluginId,\n item.restrictParent,\n InvalidLinealRelationFlag.ITEM,\n )\n }\n if (parent.restrictChildren) {\n validateLinealOrder(\n item.componentId,\n item.pluginId,\n parent.restrictChildren,\n InvalidLinealRelationFlag.PARENT,\n )\n }\n } catch (e) {\n console.error(e)\n if (typeof e === 'number') {\n return [false, e]\n }\n throw e\n }\n\n return [true]\n}\nexport default confirmValidLinealRelationship\n"],"names":["checkLinealOrder","components","LinealDirectiveFlag","_isArr","InvalidLinealRelationFlag","validateLinealOrder","componentId","pluginId","linealOrder","governor","failed","componentLabel","undefined","getLabel","allowedComponentLabels","directiveType","directiveDefinition","LIMIT_TO","map","id","filter","Boolean","describeInvalidLinealRelationship","item","parent","reason","itemLabel","parentLabel","allowed","restrictParent","length","join","restrictChildren","confirmValidLinealRelationship","e","console","error"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAGD,SAASA,gBAAgB,EAAEC,UAAU,EAAEC,mBAAmB,QAAQ,eAAc;AAChF,SAASC,MAAM,QAAQ,2BAA0B;AAEjD,OAAO,IAAA,AAAKC,mDAAAA;sEACC;sEACA;kEAEJ;oEACE;uEAEG;oEACH;;;;;;;;;;;;;WARCA;MAwBX;AAKD,SAASC,oBACPC,WAA8B,EAC9BC,QAAwB,EACxBC,WAAwC,EACxCC,QAE2C;IAE3C,wEAAwE;IACxE,sEAAsE;IACtE,MAAMC,SAASV,iBAAiBM,aAAaC,UAAUC;IACvD,IAAIE,WAAW,aAAa;QAC1B,MAAMN,KAA+CK;IACvD;IACA,IAAIC,WAAW,UAAU;QACvB,MAAMN,KAA4CK;IACpD;AACF;AASA,SAASE,eAAeL,WAA+B;QAE9CL;IADP,IAAI,CAACK,aAAa,OAAOM;IACzB,QAAOX,uBAAAA,WAAWY,QAAQ,CAACP,wBAApBL,uBAAoCK;AAC7C;AAEA,SAASQ,uBACPN,WAAyC;IAEzC,IAAI,CAACA,aAAa,OAAO,EAAE;IAC3B,MAAM,CAACO,eAAeC,oBAAoB,GAAGR;IAC7C,IAAIO,kBAAkBb,oBAAoBe,QAAQ,EAAE,OAAO,EAAE;IAC7D,MAAMhB,aAAaE,OAAOa,uBACtBA,sBACAA,uCAAAA,oBAAqBf,UAAU;IACnC,OAAO,CAACA,qBAAAA,aAAc,EAAE,EACrBiB,GAAG,CAAC,CAACC,KAAOR,eAAeQ,KAC3BC,MAAM,CAACC;AACZ;AAEA;;;;CAIC,GACD,OAAO,SAASC,kCACdC,IAAgB,EAChBC,MAAkB,EAClBC,MAAiC;QAEfd,iBAGXA;IAHP,MAAMe,aAAYf,kBAAAA,eAAeY,KAAKjB,WAAW,aAA/BK,kBAAoC;IACtD,MAAMgB,cACJH,O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
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import type * as Aglyn from '@aglyn/aglyn';
|
|
18
|
+
import { type ConfirmValidLinealRelationshipResponse } from './confirm-valid-lineal-relationship';
|
|
19
|
+
export declare enum DragType {
|
|
20
|
+
CANVAS = "canvas",
|
|
21
|
+
PRESET = "preset",
|
|
22
|
+
TREE = "tree"
|
|
23
|
+
}
|
|
24
|
+
export declare enum DropAreaType {
|
|
25
|
+
BEFORE = 1,
|
|
26
|
+
INSIDE = 2,
|
|
27
|
+
AFTER = 3
|
|
28
|
+
}
|
|
29
|
+
export declare enum DropRegion {
|
|
30
|
+
CHILDREN = "children",
|
|
31
|
+
TOP = "top",
|
|
32
|
+
RIGHT = "right",
|
|
33
|
+
BOTTOM = "bottom",
|
|
34
|
+
LEFT = "left"
|
|
35
|
+
}
|
|
36
|
+
export type DraggableNode = Aglyn.NodeSchema<any> | Aglyn.PresetSchema<any>;
|
|
37
|
+
export declare class DndManager {
|
|
38
|
+
drag?: DraggableNode;
|
|
39
|
+
drop?: DraggableNode;
|
|
40
|
+
dropRegion?: DropRegion | null;
|
|
41
|
+
get intoArea(): DropAreaType;
|
|
42
|
+
get computedDrop(): DraggableNode;
|
|
43
|
+
get hasDragTarget(): boolean;
|
|
44
|
+
get hasDropTarget(): boolean;
|
|
45
|
+
get dragBreadcrumbs(): Aglyn.NodeBreadcrumbPath | false;
|
|
46
|
+
get dropBreadcrumbs(): Aglyn.NodeBreadcrumbPath | false;
|
|
47
|
+
get dropIsInsideDrag(): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Multi-drag (AGL-13): when the dragged node is part of the current
|
|
50
|
+
* multi-selection, every draggable selected node moves; otherwise just
|
|
51
|
+
* the dragged node. Presets never join a selection.
|
|
52
|
+
*/
|
|
53
|
+
get dragNodes(): DraggableNode[];
|
|
54
|
+
/** Item/parent descriptors for the pending drop, or null without targets. */
|
|
55
|
+
private get dropRelationshipActors();
|
|
56
|
+
get linealValidation(): ConfirmValidLinealRelationshipResponse;
|
|
57
|
+
get isValidLinealRelationship(): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Human-readable reason the pending drop would be rejected, or null when
|
|
60
|
+
* the drop is valid (or there is nothing to validate). Read this before
|
|
61
|
+
* onDragEnd — completing the drag clears the dnd state.
|
|
62
|
+
*/
|
|
63
|
+
describeDropRejection(): string | null;
|
|
64
|
+
constructor();
|
|
65
|
+
isDraggingNode(node: DraggableNode): boolean;
|
|
66
|
+
isDraggingDropNode(node: DraggableNode): boolean;
|
|
67
|
+
isDraggingOverDropNode(node: DraggableNode): boolean;
|
|
68
|
+
canDragNode(node: DraggableNode): boolean;
|
|
69
|
+
clearDndStatus(): this;
|
|
70
|
+
setDragNode(node: DraggableNode): this;
|
|
71
|
+
setDropNode(node: DraggableNode): this;
|
|
72
|
+
setDropRegion(region: DropRegion): this;
|
|
73
|
+
onDragEnd(): void;
|
|
74
|
+
}
|
|
75
|
+
export default DndManager;
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ import { canvas, components, isFeatureEnabled, NodeType } from "@aglyn/aglyn";
|
|
17
|
+
import { confirmValidLinealRelationship, describeInvalidLinealRelationship } from "./confirm-valid-lineal-relationship.js";
|
|
18
|
+
import { makeAutoObservable } from "mobx";
|
|
19
|
+
import { getSelected, isNodeSelected } from "../focus-manager/focus-manager.js";
|
|
20
|
+
export var DragType = /*#__PURE__*/ function(DragType) {
|
|
21
|
+
DragType["CANVAS"] = "canvas";
|
|
22
|
+
DragType["PRESET"] = "preset";
|
|
23
|
+
DragType["TREE"] = "tree";
|
|
24
|
+
return DragType;
|
|
25
|
+
}({});
|
|
26
|
+
export var DropAreaType = /*#__PURE__*/ function(DropAreaType) {
|
|
27
|
+
DropAreaType[DropAreaType["BEFORE"] = 0x1] = "BEFORE";
|
|
28
|
+
DropAreaType[DropAreaType["INSIDE"] = 0x2] = "INSIDE";
|
|
29
|
+
DropAreaType[DropAreaType["AFTER"] = 0x3] = "AFTER";
|
|
30
|
+
return DropAreaType;
|
|
31
|
+
}({});
|
|
32
|
+
export var DropRegion = /*#__PURE__*/ function(DropRegion) {
|
|
33
|
+
DropRegion["CHILDREN"] = "children";
|
|
34
|
+
DropRegion["TOP"] = "top";
|
|
35
|
+
DropRegion["RIGHT"] = "right";
|
|
36
|
+
DropRegion["BOTTOM"] = "bottom";
|
|
37
|
+
DropRegion["LEFT"] = "left";
|
|
38
|
+
return DropRegion;
|
|
39
|
+
}({});
|
|
40
|
+
export class DndManager {
|
|
41
|
+
get intoArea() {
|
|
42
|
+
switch(this.dropRegion){
|
|
43
|
+
case "top":
|
|
44
|
+
case "left":
|
|
45
|
+
return 0x1;
|
|
46
|
+
case "right":
|
|
47
|
+
case "bottom":
|
|
48
|
+
return 0x3;
|
|
49
|
+
}
|
|
50
|
+
return 0x2;
|
|
51
|
+
}
|
|
52
|
+
get computedDrop() {
|
|
53
|
+
if (!this.drop) return this.drop;
|
|
54
|
+
if (canvas.isRootNode(this.drop)) return this.drop;
|
|
55
|
+
if (!this.dropRegion) return this.drop;
|
|
56
|
+
if (this.dropRegion === "children") {
|
|
57
|
+
// A leaf (self-closing / text-editable) has no slot for node children,
|
|
58
|
+
// so a center/CHILDREN drop resolves against its PARENT and lands as a
|
|
59
|
+
// sibling — mirroring the Insert menu's leaf handling (AGL-575). This
|
|
60
|
+
// also makes the lineal check validate against the real parent instead
|
|
61
|
+
// of the leaf, which (declaring no restrictChildren) would wrongly pass.
|
|
62
|
+
const node = canvas.getNode(this.drop.$id);
|
|
63
|
+
if (node && !canvas.nodeAcceptsChildren(node)) return node.parent;
|
|
64
|
+
return this.drop;
|
|
65
|
+
}
|
|
66
|
+
return canvas.getNode(this.drop.$id).parent;
|
|
67
|
+
}
|
|
68
|
+
get hasDragTarget() {
|
|
69
|
+
return Boolean(this.drag);
|
|
70
|
+
}
|
|
71
|
+
get hasDropTarget() {
|
|
72
|
+
return Boolean(this.drop);
|
|
73
|
+
}
|
|
74
|
+
get dragBreadcrumbs() {
|
|
75
|
+
var _this_drag;
|
|
76
|
+
if (!this.hasDragTarget) return false;
|
|
77
|
+
return (_this_drag = this.drag) == null ? void 0 : _this_drag.breadcrumbPath;
|
|
78
|
+
}
|
|
79
|
+
get dropBreadcrumbs() {
|
|
80
|
+
var _this_drop;
|
|
81
|
+
if (!this.hasDropTarget) return false;
|
|
82
|
+
return (_this_drop = this.drop) == null ? void 0 : _this_drop.breadcrumbPath;
|
|
83
|
+
}
|
|
84
|
+
get dropIsInsideDrag() {
|
|
85
|
+
var _this_computedDrop_breadcrumbPath, _this_computedDrop;
|
|
86
|
+
return Boolean((_this_computedDrop = this.computedDrop) == null ? void 0 : (_this_computedDrop_breadcrumbPath = _this_computedDrop.breadcrumbPath) == null ? void 0 : _this_computedDrop_breadcrumbPath.some((i)=>{
|
|
87
|
+
var _this_drag;
|
|
88
|
+
return i === ((_this_drag = this.drag) == null ? void 0 : _this_drag.$id);
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Multi-drag (AGL-13): when the dragged node is part of the current
|
|
93
|
+
* multi-selection, every draggable selected node moves; otherwise just
|
|
94
|
+
* the dragged node. Presets never join a selection.
|
|
95
|
+
*/ get dragNodes() {
|
|
96
|
+
if (this.drag && this.drag.type === NodeType.NODE && isNodeSelected(this.drag)) {
|
|
97
|
+
const selected = getSelected().filter((node)=>this.canDragNode(node));
|
|
98
|
+
if (selected.length > 1) {
|
|
99
|
+
// Document order (not selection order) so relative positions
|
|
100
|
+
// survive the move: compare breadcrumb paths by sibling index.
|
|
101
|
+
const orderKey = (node)=>{
|
|
102
|
+
var _node_breadcrumbPath;
|
|
103
|
+
return ((_node_breadcrumbPath = node.breadcrumbPath) != null ? _node_breadcrumbPath : []).map((id)=>{
|
|
104
|
+
try {
|
|
105
|
+
return canvas.getNodeIndex(canvas.getNode(id));
|
|
106
|
+
} catch (unused) {
|
|
107
|
+
return 0;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
return [
|
|
112
|
+
...selected
|
|
113
|
+
].sort((a, b)=>{
|
|
114
|
+
const left = orderKey(a);
|
|
115
|
+
const right = orderKey(b);
|
|
116
|
+
for(let i = 0; i < Math.max(left.length, right.length); i += 1){
|
|
117
|
+
var _left_i, _right_i;
|
|
118
|
+
const diff = ((_left_i = left[i]) != null ? _left_i : -1) - ((_right_i = right[i]) != null ? _right_i : -1);
|
|
119
|
+
if (diff !== 0) return diff;
|
|
120
|
+
}
|
|
121
|
+
return 0;
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
if (selected.length === 1) return selected;
|
|
125
|
+
}
|
|
126
|
+
return this.drag ? [
|
|
127
|
+
this.drag
|
|
128
|
+
] : [];
|
|
129
|
+
}
|
|
130
|
+
/** Item/parent descriptors for the pending drop, or null without targets. */ get dropRelationshipActors() {
|
|
131
|
+
var _this_computedDrop, _this_computedDrop1, _this_computedDrop_componentSchema, _this_computedDrop2, _this_computedDrop_componentSchema1, _this_computedDrop3, _this_drag, _this_drag1, _this_drag2, _this_drag_componentSchema, _this_drag3, _this_drag_componentSchema1, _this_drag4;
|
|
132
|
+
if (!this.hasDragTarget || !this.hasDropTarget) return null;
|
|
133
|
+
const parent = {
|
|
134
|
+
pluginId: (_this_computedDrop = this.computedDrop) == null ? void 0 : _this_computedDrop.pluginId,
|
|
135
|
+
componentId: (_this_computedDrop1 = this.computedDrop) == null ? void 0 : _this_computedDrop1.componentId,
|
|
136
|
+
restrictChildren: (_this_computedDrop2 = this.computedDrop) == null ? void 0 : (_this_computedDrop_componentSchema = _this_computedDrop2.componentSchema) == null ? void 0 : _this_computedDrop_componentSchema.restrictChildren,
|
|
137
|
+
restrictParent: (_this_computedDrop3 = this.computedDrop) == null ? void 0 : (_this_computedDrop_componentSchema1 = _this_computedDrop3.componentSchema) == null ? void 0 : _this_computedDrop_componentSchema1.restrictParent
|
|
138
|
+
};
|
|
139
|
+
if (((_this_drag = this.drag) == null ? void 0 : _this_drag.type) === NodeType.PRESET) {
|
|
140
|
+
var _preset_data;
|
|
141
|
+
const preset = this.drag;
|
|
142
|
+
const itemNode = preset.data;
|
|
143
|
+
const itemSchema = components.getSchema(itemNode == null ? void 0 : itemNode.componentId);
|
|
144
|
+
return {
|
|
145
|
+
item: {
|
|
146
|
+
pluginId: (_preset_data = preset.data) == null ? void 0 : _preset_data.pluginId,
|
|
147
|
+
componentId: itemNode == null ? void 0 : itemNode.componentId,
|
|
148
|
+
restrictChildren: itemSchema == null ? void 0 : itemSchema.restrictChildren,
|
|
149
|
+
restrictParent: itemSchema == null ? void 0 : itemSchema.restrictParent
|
|
150
|
+
},
|
|
151
|
+
parent
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
item: {
|
|
156
|
+
pluginId: (_this_drag1 = this.drag) == null ? void 0 : _this_drag1.pluginId,
|
|
157
|
+
componentId: (_this_drag2 = this.drag) == null ? void 0 : _this_drag2.componentId,
|
|
158
|
+
restrictChildren: (_this_drag3 = this.drag) == null ? void 0 : (_this_drag_componentSchema = _this_drag3.componentSchema) == null ? void 0 : _this_drag_componentSchema.restrictChildren,
|
|
159
|
+
restrictParent: (_this_drag4 = this.drag) == null ? void 0 : (_this_drag_componentSchema1 = _this_drag4.componentSchema) == null ? void 0 : _this_drag_componentSchema1.restrictParent
|
|
160
|
+
},
|
|
161
|
+
parent
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
get linealValidation() {
|
|
165
|
+
const actors = this.dropRelationshipActors;
|
|
166
|
+
if (!actors) return [
|
|
167
|
+
false,
|
|
168
|
+
0
|
|
169
|
+
];
|
|
170
|
+
return confirmValidLinealRelationship(actors.item, actors.parent);
|
|
171
|
+
}
|
|
172
|
+
get isValidLinealRelationship() {
|
|
173
|
+
return this.linealValidation[0];
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Human-readable reason the pending drop would be rejected, or null when
|
|
177
|
+
* the drop is valid (or there is nothing to validate). Read this before
|
|
178
|
+
* onDragEnd — completing the drag clears the dnd state.
|
|
179
|
+
*/ describeDropRejection() {
|
|
180
|
+
const actors = this.dropRelationshipActors;
|
|
181
|
+
if (!actors) return null;
|
|
182
|
+
if (this.dropIsInsideDrag) {
|
|
183
|
+
return "An element can't be moved inside itself";
|
|
184
|
+
}
|
|
185
|
+
// Says out loud what `onDragEnd` refuses silently: the resolved parent
|
|
186
|
+
// has no slot a child could render into (AGL-1405).
|
|
187
|
+
const into = this.computedDrop;
|
|
188
|
+
if (into && !canvas.nodeAcceptsChildren(into)) {
|
|
189
|
+
return `${into.labelShort || 'That element'} can't hold other elements`;
|
|
190
|
+
}
|
|
191
|
+
const [valid, reason] = confirmValidLinealRelationship(actors.item, actors.parent);
|
|
192
|
+
if (valid) return null;
|
|
193
|
+
return describeInvalidLinealRelationship(actors.item, actors.parent, reason);
|
|
194
|
+
}
|
|
195
|
+
isDraggingNode(node) {
|
|
196
|
+
var _this_drag;
|
|
197
|
+
if (!node) return false;
|
|
198
|
+
return (node == null ? void 0 : node.$id) === ((_this_drag = this.drag) == null ? void 0 : _this_drag.$id);
|
|
199
|
+
}
|
|
200
|
+
isDraggingDropNode(node) {
|
|
201
|
+
var _this_drop;
|
|
202
|
+
if (!node) return false;
|
|
203
|
+
return (node == null ? void 0 : node.$id) === ((_this_drop = this.drop) == null ? void 0 : _this_drop.$id);
|
|
204
|
+
}
|
|
205
|
+
isDraggingOverDropNode(node) {
|
|
206
|
+
if (!node) return false;
|
|
207
|
+
const breadcrumbs = this.dropBreadcrumbs;
|
|
208
|
+
return Array.isArray(breadcrumbs) && breadcrumbs.indexOf(node == null ? void 0 : node.$id) >= 0;
|
|
209
|
+
}
|
|
210
|
+
canDragNode(node) {
|
|
211
|
+
if (!node) throw new Error('Invalid node');
|
|
212
|
+
switch(true){
|
|
213
|
+
case canvas.isRootNode(node):
|
|
214
|
+
return false;
|
|
215
|
+
case (node == null ? void 0 : node.type) === NodeType.PRESET:
|
|
216
|
+
return true;
|
|
217
|
+
case (node == null ? void 0 : node.type) === NodeType.NODE:
|
|
218
|
+
var _node_componentSchema_flags, _node_componentSchema;
|
|
219
|
+
return isFeatureEnabled(node == null ? void 0 : (_node_componentSchema = node.componentSchema) == null ? void 0 : (_node_componentSchema_flags = _node_componentSchema.flags) == null ? void 0 : _node_componentSchema_flags.dragging);
|
|
220
|
+
default:
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
clearDndStatus() {
|
|
225
|
+
this.drag = null;
|
|
226
|
+
this.drop = null;
|
|
227
|
+
this.dropRegion = null;
|
|
228
|
+
return this;
|
|
229
|
+
}
|
|
230
|
+
setDragNode(node) {
|
|
231
|
+
this.drag = node || null;
|
|
232
|
+
return this;
|
|
233
|
+
}
|
|
234
|
+
setDropNode(node) {
|
|
235
|
+
this.drop = node || null;
|
|
236
|
+
return this;
|
|
237
|
+
}
|
|
238
|
+
setDropRegion(region) {
|
|
239
|
+
this.dropRegion = region || null;
|
|
240
|
+
return this;
|
|
241
|
+
}
|
|
242
|
+
onDragEnd() {
|
|
243
|
+
if (!this.drop || !this.drag) return;
|
|
244
|
+
if (this.dropIsInsideDrag) return;
|
|
245
|
+
if (!this.isValidLinealRelationship) return;
|
|
246
|
+
const dragNode = this.drag;
|
|
247
|
+
const dropNode = this.drop;
|
|
248
|
+
const region = this.dropRegion;
|
|
249
|
+
const before = region === "top" || region === "left";
|
|
250
|
+
const after = region === "right" || region === "bottom";
|
|
251
|
+
let position = NaN;
|
|
252
|
+
let parent;
|
|
253
|
+
if (before || after) {
|
|
254
|
+
parent = canvas.getNode(dropNode.parentId);
|
|
255
|
+
position = canvas.getNodeIndex(dropNode);
|
|
256
|
+
if (after) position = position + 1;
|
|
257
|
+
} else {
|
|
258
|
+
const dropTarget = canvas.getNode(dropNode.$id);
|
|
259
|
+
// Leaf redirect (AGL-575 parallel): a self-closing / text-editable
|
|
260
|
+
// target has no children slot, so a center drop becomes a sibling right
|
|
261
|
+
// after it rather than a nested child. Non-leaf containers still nest.
|
|
262
|
+
if (dropTarget && dropNode.parentId && !canvas.nodeAcceptsChildren(dropTarget)) {
|
|
263
|
+
const leafIndex = canvas.getNodeIndex(dropTarget);
|
|
264
|
+
parent = canvas.getNode(dropNode.parentId);
|
|
265
|
+
if (leafIndex > -1) position = leafIndex + 1;
|
|
266
|
+
} else {
|
|
267
|
+
parent = dropTarget;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
// The redirect above only rescues a drop aimed AT a leaf. An edge drop
|
|
271
|
+
// resolves to the drop node's existing parent, and that parent may itself
|
|
272
|
+
// be unable to hold children — a node already trapped under a `markdown`
|
|
273
|
+
// block (AGL-1388) has exactly that shape, so dropping a sibling next to
|
|
274
|
+
// it would deepen the same hole. `reparentNode` refuses this outright
|
|
275
|
+
// now (AGL-1405); catch it here so a drag ends quietly instead of
|
|
276
|
+
// throwing out of the pointer handler.
|
|
277
|
+
if (!parent || !canvas.nodeAcceptsChildren(parent)) {
|
|
278
|
+
this.clearDndStatus();
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
if (dragNode.type === NodeType.PRESET) {
|
|
282
|
+
canvas.addNodeFromPreset(dragNode, parent, position);
|
|
283
|
+
// Besigner.focus.setSelectedNode(newNode)
|
|
284
|
+
} else {
|
|
285
|
+
// Multi-drag (AGL-13): move the whole selection when the dragged
|
|
286
|
+
// node is selected. Per-node guards mirror the single-node checks —
|
|
287
|
+
// nodes that contain the drop target or fail the lineal rules are
|
|
288
|
+
// skipped rather than failing the whole move. Sequential inserts
|
|
289
|
+
// with an advancing position preserve document order (CANVAS and
|
|
290
|
+
// TREE drags both land here).
|
|
291
|
+
const parentSchema = components.getSchema(parent == null ? void 0 : parent.componentId);
|
|
292
|
+
for (const node of this.dragNodes){
|
|
293
|
+
var _this_computedDrop_breadcrumbPath, _this_computedDrop, _node_componentSchema, _node_componentSchema1;
|
|
294
|
+
if (node.type !== NodeType.NODE) continue;
|
|
295
|
+
const containsDrop = Boolean((_this_computedDrop = this.computedDrop) == null ? void 0 : (_this_computedDrop_breadcrumbPath = _this_computedDrop.breadcrumbPath) == null ? void 0 : _this_computedDrop_breadcrumbPath.some((id)=>id === node.$id));
|
|
296
|
+
if (containsDrop) continue;
|
|
297
|
+
const [valid] = confirmValidLinealRelationship({
|
|
298
|
+
pluginId: node.pluginId,
|
|
299
|
+
componentId: node.componentId,
|
|
300
|
+
restrictChildren: node == null ? void 0 : (_node_componentSchema = node.componentSchema) == null ? void 0 : _node_componentSchema.restrictChildren,
|
|
301
|
+
restrictParent: node == null ? void 0 : (_node_componentSchema1 = node.componentSchema) == null ? void 0 : _node_componentSchema1.restrictParent
|
|
302
|
+
}, {
|
|
303
|
+
pluginId: parent == null ? void 0 : parent.pluginId,
|
|
304
|
+
componentId: parent == null ? void 0 : parent.componentId,
|
|
305
|
+
restrictChildren: parentSchema == null ? void 0 : parentSchema.restrictChildren,
|
|
306
|
+
restrictParent: parentSchema == null ? void 0 : parentSchema.restrictParent
|
|
307
|
+
});
|
|
308
|
+
if (!valid) continue;
|
|
309
|
+
// An edge drop names a GAP in the sibling list as it stands now —
|
|
310
|
+
// "before whatever is at index 2". `reparentNode` indexes the list it
|
|
311
|
+
// is left with, after this node has been spliced out of it. Those
|
|
312
|
+
// agree for a drop into a different parent; among the node's OWN
|
|
313
|
+
// siblings every slot past it shifts down by one, so without this the
|
|
314
|
+
// drag lands one place late — and dropping a node just above itself
|
|
315
|
+
// resolves to the slot it is already in, which is what made the
|
|
316
|
+
// hierarchy drag look inert (AGL-1405).
|
|
317
|
+
let at = position;
|
|
318
|
+
if (!Number.isNaN(at) && node.parentId === (parent == null ? void 0 : parent.$id)) {
|
|
319
|
+
const from = canvas.getNodeIndex(node);
|
|
320
|
+
if (from > -1 && from < at) at -= 1;
|
|
321
|
+
}
|
|
322
|
+
canvas.reparentNode(node, parent, at);
|
|
323
|
+
if (!Number.isNaN(position)) position += 1;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
this.clearDndStatus();
|
|
327
|
+
}
|
|
328
|
+
constructor(){
|
|
329
|
+
this.drag = null;
|
|
330
|
+
this.drop = null;
|
|
331
|
+
this.dropRegion = null;
|
|
332
|
+
makeAutoObservable(this);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
export default DndManager;
|
|
336
|
+
|
|
337
|
+
//# sourceMappingURL=dnd-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/besigner/core/src/lib/dnd-manager/dnd-manager.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2023 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type * as Aglyn from '@aglyn/aglyn'\nimport { canvas, components, isFeatureEnabled, NodeType } from '@aglyn/aglyn'\nimport {\n confirmValidLinealRelationship,\n type ConfirmValidLinealRelationshipResponse,\n describeInvalidLinealRelationship,\n type InvalidLinealRelationFlag,\n type LinealItem,\n} from './confirm-valid-lineal-relationship'\nimport { makeAutoObservable } from 'mobx'\nimport { getSelected, isNodeSelected } from '../focus-manager/focus-manager'\n\nexport enum DragType {\n CANVAS = 'canvas',\n PRESET = 'preset',\n TREE = 'tree',\n}\n\nexport enum DropAreaType {\n BEFORE = 0x1,\n INSIDE = 0x2,\n AFTER = 0x3,\n}\n\nexport enum DropRegion {\n CHILDREN = 'children',\n TOP = 'top',\n RIGHT = 'right',\n BOTTOM = 'bottom',\n LEFT = 'left',\n}\n\nexport type DraggableNode = Aglyn.NodeSchema<any> | Aglyn.PresetSchema<any>\n\nexport class DndManager {\n drag?: DraggableNode = null\n drop?: DraggableNode = null\n dropRegion?: DropRegion | null = null\n public get intoArea(): DropAreaType {\n switch (this.dropRegion) {\n case DropRegion.TOP:\n case DropRegion.LEFT:\n return DropAreaType.BEFORE\n case DropRegion.RIGHT:\n case DropRegion.BOTTOM:\n return DropAreaType.AFTER\n }\n\n return DropAreaType.INSIDE\n }\n\n public get computedDrop() {\n if (!this.drop) return this.drop\n if (canvas.isRootNode(this.drop)) return this.drop\n if (!this.dropRegion) return this.drop\n if (this.dropRegion === DropRegion.CHILDREN) {\n // A leaf (self-closing / text-editable) has no slot for node children,\n // so a center/CHILDREN drop resolves against its PARENT and lands as a\n // sibling — mirroring the Insert menu's leaf handling (AGL-575). This\n // also makes the lineal check validate against the real parent instead\n // of the leaf, which (declaring no restrictChildren) would wrongly pass.\n const node = canvas.getNode(this.drop.$id)\n if (node && !canvas.nodeAcceptsChildren(node)) return node.parent\n return this.drop\n }\n return canvas.getNode(this.drop.$id).parent\n }\n\n public get hasDragTarget(): boolean {\n return Boolean(this.drag)\n }\n public get hasDropTarget(): boolean {\n return Boolean(this.drop)\n }\n public get dragBreadcrumbs(): Aglyn.NodeBreadcrumbPath | false {\n if (!this.hasDragTarget) return false\n return this.drag?.breadcrumbPath\n }\n public get dropBreadcrumbs(): Aglyn.NodeBreadcrumbPath | false {\n if (!this.hasDropTarget) return false\n return this.drop?.breadcrumbPath\n }\n public get dropIsInsideDrag() {\n return Boolean(\n this.computedDrop?.breadcrumbPath?.some((i) => i === this.drag?.$id),\n )\n }\n /**\n * Multi-drag (AGL-13): when the dragged node is part of the current\n * multi-selection, every draggable selected node moves; otherwise just\n * the dragged node. Presets never join a selection.\n */\n public get dragNodes(): DraggableNode[] {\n if (\n this.drag &&\n this.drag.type === NodeType.NODE &&\n isNodeSelected(this.drag as Aglyn.NodeSchema<any>)\n ) {\n const selected = getSelected().filter((node) => this.canDragNode(node))\n if (selected.length > 1) {\n // Document order (not selection order) so relative positions\n // survive the move: compare breadcrumb paths by sibling index.\n const orderKey = (node: Aglyn.NodeSchema<any>): number[] =>\n (node.breadcrumbPath ?? []).map((id) => {\n try {\n return canvas.getNodeIndex(canvas.getNode(id))\n } catch {\n return 0\n }\n })\n return [...selected].sort((a, b) => {\n const left = orderKey(a)\n const right = orderKey(b)\n for (let i = 0; i < Math.max(left.length, right.length); i += 1) {\n const diff = (left[i] ?? -1) - (right[i] ?? -1)\n if (diff !== 0) return diff\n }\n return 0\n })\n }\n if (selected.length === 1) return selected\n }\n return this.drag ? [this.drag] : []\n }\n /** Item/parent descriptors for the pending drop, or null without targets. */\n private get dropRelationshipActors(): {\n item: LinealItem\n parent: LinealItem\n } | null {\n if (!this.hasDragTarget || !this.hasDropTarget) return null\n const parent: LinealItem = {\n pluginId: this.computedDrop?.pluginId,\n componentId: this.computedDrop?.componentId,\n restrictChildren: this.computedDrop?.componentSchema?.restrictChildren,\n restrictParent: this.computedDrop?.componentSchema?.restrictParent,\n }\n\n if (this.drag?.type === NodeType.PRESET) {\n const preset = this.drag as Aglyn.PresetSchema<any>\n const itemNode = preset.data\n const itemSchema = components.getSchema(itemNode?.componentId)\n return {\n item: {\n pluginId: preset.data?.pluginId,\n componentId: itemNode?.componentId,\n restrictChildren: itemSchema?.restrictChildren,\n restrictParent: itemSchema?.restrictParent,\n },\n parent,\n }\n }\n return {\n item: {\n pluginId: this.drag?.pluginId,\n componentId: this.drag?.componentId,\n restrictChildren: this.drag?.componentSchema?.restrictChildren,\n restrictParent: this.drag?.componentSchema?.restrictParent,\n },\n parent,\n }\n }\n\n public get linealValidation(): ConfirmValidLinealRelationshipResponse {\n const actors = this.dropRelationshipActors\n if (!actors) return [false, 0 as InvalidLinealRelationFlag]\n return confirmValidLinealRelationship(actors.item, actors.parent)\n }\n\n public get isValidLinealRelationship(): boolean {\n return this.linealValidation[0]\n }\n\n /**\n * Human-readable reason the pending drop would be rejected, or null when\n * the drop is valid (or there is nothing to validate). Read this before\n * onDragEnd — completing the drag clears the dnd state.\n */\n public describeDropRejection(): string | null {\n const actors = this.dropRelationshipActors\n if (!actors) return null\n if (this.dropIsInsideDrag) {\n return \"An element can't be moved inside itself\"\n }\n // Says out loud what `onDragEnd` refuses silently: the resolved parent\n // has no slot a child could render into (AGL-1405).\n const into = this.computedDrop as Aglyn.NodeSchema<any>\n if (into && !canvas.nodeAcceptsChildren(into)) {\n return `${into.labelShort || 'That element'} can't hold other elements`\n }\n const [valid, reason] = confirmValidLinealRelationship(\n actors.item,\n actors.parent,\n )\n if (valid) return null\n return describeInvalidLinealRelationship(actors.item, actors.parent, reason)\n }\n\n constructor() {\n makeAutoObservable(this)\n }\n\n public isDraggingNode(node: DraggableNode): boolean {\n if (!node) return false\n return node?.$id === this.drag?.$id\n }\n public isDraggingDropNode(node: DraggableNode): boolean {\n if (!node) return false\n return node?.$id === this.drop?.$id\n }\n public isDraggingOverDropNode(node: DraggableNode): boolean {\n if (!node) return false\n const breadcrumbs = this.dropBreadcrumbs\n return Array.isArray(breadcrumbs) && breadcrumbs.indexOf(node?.$id) >= 0\n }\n canDragNode(node: DraggableNode): boolean {\n if (!node) throw new Error('Invalid node')\n switch (true) {\n case canvas.isRootNode(node):\n return false\n case node?.type === NodeType.PRESET:\n return true\n case node?.type === NodeType.NODE:\n return isFeatureEnabled(\n (node as Aglyn.NodeSchema<any>)?.componentSchema?.flags?.dragging,\n )\n default:\n return false\n }\n }\n\n public clearDndStatus() {\n this.drag = null\n this.drop = null\n this.dropRegion = null\n return this\n }\n\n public setDragNode(node: DraggableNode) {\n this.drag = node || null\n return this\n }\n public setDropNode(node: DraggableNode) {\n this.drop = node || null\n return this\n }\n public setDropRegion(region: DropRegion) {\n this.dropRegion = region || null\n return this\n }\n public onDragEnd() {\n if (!this.drop || !this.drag) return\n if (this.dropIsInsideDrag) return\n if (!this.isValidLinealRelationship) return\n\n const dragNode = this.drag\n const dropNode = this.drop\n const region = this.dropRegion\n const before = region === DropRegion.TOP || region === DropRegion.LEFT\n const after = region === DropRegion.RIGHT || region === DropRegion.BOTTOM\n let position = NaN\n let parent\n\n if (before || after) {\n parent = canvas.getNode(dropNode.parentId)\n position = canvas.getNodeIndex(dropNode)\n if (after) position = position + 1\n } else {\n const dropTarget = canvas.getNode(dropNode.$id)\n // Leaf redirect (AGL-575 parallel): a self-closing / text-editable\n // target has no children slot, so a center drop becomes a sibling right\n // after it rather than a nested child. Non-leaf containers still nest.\n if (\n dropTarget &&\n dropNode.parentId &&\n !canvas.nodeAcceptsChildren(dropTarget)\n ) {\n const leafIndex = canvas.getNodeIndex(dropTarget)\n parent = canvas.getNode(dropNode.parentId)\n if (leafIndex > -1) position = leafIndex + 1\n } else {\n parent = dropTarget\n }\n }\n\n // The redirect above only rescues a drop aimed AT a leaf. An edge drop\n // resolves to the drop node's existing parent, and that parent may itself\n // be unable to hold children — a node already trapped under a `markdown`\n // block (AGL-1388) has exactly that shape, so dropping a sibling next to\n // it would deepen the same hole. `reparentNode` refuses this outright\n // now (AGL-1405); catch it here so a drag ends quietly instead of\n // throwing out of the pointer handler.\n if (!parent || !canvas.nodeAcceptsChildren(parent)) {\n this.clearDndStatus()\n return\n }\n\n if (dragNode.type === NodeType.PRESET) {\n canvas.addNodeFromPreset(dragNode as Aglyn.PresetSchema<any>, parent, position)\n // Besigner.focus.setSelectedNode(newNode)\n } else {\n // Multi-drag (AGL-13): move the whole selection when the dragged\n // node is selected. Per-node guards mirror the single-node checks —\n // nodes that contain the drop target or fail the lineal rules are\n // skipped rather than failing the whole move. Sequential inserts\n // with an advancing position preserve document order (CANVAS and\n // TREE drags both land here).\n const parentSchema = components.getSchema(parent?.componentId)\n for (const node of this.dragNodes) {\n if (node.type !== NodeType.NODE) continue\n const containsDrop = Boolean(\n this.computedDrop?.breadcrumbPath?.some((id) => id === node.$id),\n )\n if (containsDrop) continue\n const [valid] = confirmValidLinealRelationship(\n {\n pluginId: node.pluginId,\n componentId: node.componentId,\n restrictChildren: (node as Aglyn.NodeSchema<any>)\n ?.componentSchema?.restrictChildren,\n restrictParent: (node as Aglyn.NodeSchema<any>)?.componentSchema\n ?.restrictParent,\n },\n {\n pluginId: parent?.pluginId,\n componentId: parent?.componentId,\n restrictChildren: parentSchema?.restrictChildren,\n restrictParent: parentSchema?.restrictParent,\n },\n )\n if (!valid) continue\n\n // An edge drop names a GAP in the sibling list as it stands now —\n // \"before whatever is at index 2\". `reparentNode` indexes the list it\n // is left with, after this node has been spliced out of it. Those\n // agree for a drop into a different parent; among the node's OWN\n // siblings every slot past it shifts down by one, so without this the\n // drag lands one place late — and dropping a node just above itself\n // resolves to the slot it is already in, which is what made the\n // hierarchy drag look inert (AGL-1405).\n let at = position\n if (!Number.isNaN(at) && node.parentId === parent?.$id) {\n const from = canvas.getNodeIndex(node)\n if (from > -1 && from < at) at -= 1\n }\n canvas.reparentNode(node, parent, at)\n if (!Number.isNaN(position)) position += 1\n }\n }\n\n this.clearDndStatus()\n }\n}\n\nexport default DndManager\n"],"names":["canvas","components","isFeatureEnabled","NodeType","confirmValidLinealRelationship","describeInvalidLinealRelationship","makeAutoObservable","getSelected","isNodeSelected","DragType","DropAreaType","DropRegion","DndManager","intoArea","dropRegion","computedDrop","drop","isRootNode","node","getNode","$id","nodeAcceptsChildren","parent","hasDragTarget","Boolean","drag","hasDropTarget","dragBreadcrumbs","breadcrumbPath","dropBreadcrumbs","dropIsInsideDrag","some","i","dragNodes","type","NODE","selected","filter","canDragNode","length","orderKey","map","id","getNodeIndex","sort","a","b","left","right","Math","max","diff","dropRelationshipActors","pluginId","componentId","restrictChildren","componentSchema","restrictParent","PRESET","preset","itemNode","data","itemSchema","getSchema","item","linealValidation","actors","isValidLinealRelationship","describeDropRejection","into","labelShort","valid","reason","isDraggingNode","isDraggingDropNode","isDraggingOverDropNode","breadcrumbs","Array","isArray","indexOf","Error","flags","dragging","clearDndStatus","setDragNode","setDropNode","setDropRegion","region","onDragEnd","dragNode","dropNode","before","after","position","NaN","parentId","dropTarget","leafIndex","addNodeFromPreset","parentSchema","containsDrop","at","Number","isNaN","from","reparentNode"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAGD,SAASA,MAAM,EAAEC,UAAU,EAAEC,gBAAgB,EAAEC,QAAQ,QAAQ,eAAc;AAC7E,SACEC,8BAA8B,EAE9BC,iCAAiC,QAG5B,yCAAqC;AAC5C,SAASC,kBAAkB,QAAQ,OAAM;AACzC,SAASC,WAAW,EAAEC,cAAc,QAAQ,oCAAgC;AAE5E,OAAO,IAAA,AAAKC,kCAAAA;;;;WAAAA;MAIX;AAED,OAAO,IAAA,AAAKC,sCAAAA;0CACD;0CACA;yCACD;WAHEA;MAIX;AAED,OAAO,IAAA,AAAKC,oCAAAA;;;;;;WAAAA;MAMX;AAID,OAAO,MAAMC;IAIX,IAAWC,WAAyB;QAClC,OAAQ,IAAI,CAACC,UAAU;YACrB;YACA;gBACE,OA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