@sequent-org/moodboard 1.4.19 → 1.4.21
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/package.json
CHANGED
|
@@ -9,11 +9,38 @@ function getSelectTool(board) {
|
|
|
9
9
|
|| null;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
||
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
function shouldOpenEditorForObject(objectType) {
|
|
13
|
+
return objectType === 'mindmap'
|
|
14
|
+
|| objectType === 'text'
|
|
15
|
+
|| objectType === 'simple-text'
|
|
16
|
+
|| objectType === 'note'
|
|
17
|
+
|| objectType === 'file';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function focusCreatedObject(board, createdObject) {
|
|
21
|
+
if (!board?.coreMoodboard?.eventBus || !createdObject?.id) return;
|
|
22
|
+
const objectType = createdObject?.type || null;
|
|
23
|
+
const objectPayload = {
|
|
24
|
+
id: createdObject.id,
|
|
25
|
+
type: objectType,
|
|
26
|
+
position: createdObject.position || null,
|
|
27
|
+
properties: createdObject.properties || {},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// Run after object is mounted so selection/HTML overlays can sync first.
|
|
31
|
+
setTimeout(() => {
|
|
32
|
+
board.coreMoodboard.eventBus.emit(Events.Keyboard.ToolSelect, { tool: 'select' });
|
|
33
|
+
const selectTool = getSelectTool(board);
|
|
34
|
+
if (typeof selectTool?.setSelection === 'function') {
|
|
35
|
+
selectTool.setSelection([createdObject.id]);
|
|
36
|
+
}
|
|
37
|
+
if (shouldOpenEditorForObject(objectType)) {
|
|
38
|
+
board.coreMoodboard.eventBus.emit(Events.Tool.ObjectEdit, {
|
|
39
|
+
object: objectPayload,
|
|
40
|
+
create: true,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}, 0);
|
|
17
44
|
}
|
|
18
45
|
|
|
19
46
|
export function bindToolbarEvents(board) {
|
|
@@ -26,63 +53,8 @@ export function bindToolbarEvents(board) {
|
|
|
26
53
|
});
|
|
27
54
|
}
|
|
28
55
|
const createdObject = board.actionHandler.handleToolbarAction(action);
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
const createdMeta = createdObject?.properties?.mindmap || {};
|
|
32
|
-
const isRootMindmap = createdMeta?.role === 'root';
|
|
33
|
-
const mindmapObjects = (board?.coreMoodboard?.state?.state?.objects || [])
|
|
34
|
-
.filter((obj) => obj?.type === 'mindmap');
|
|
35
|
-
const rootCount = mindmapObjects.filter((obj) => (obj?.properties?.mindmap?.role || null) === 'root').length;
|
|
36
|
-
const shouldAutoOpenForRoot = !isRootMindmap || rootCount <= 1;
|
|
37
|
-
const selectTool = getSelectTool(board);
|
|
38
|
-
const hasActiveEditor = Boolean(selectTool?.textEditor?.active);
|
|
39
|
-
const hasEditorDom = hasOpenTextEditorInDom(board);
|
|
40
|
-
const shouldBlockAutoOpen = hasActiveEditor && hasEditorDom;
|
|
41
|
-
if (content.trim().length === 0 && !shouldBlockAutoOpen && shouldAutoOpenForRoot) {
|
|
42
|
-
const doc = board?.workspaceElement?.ownerDocument
|
|
43
|
-
|| (typeof document !== 'undefined' ? document : null);
|
|
44
|
-
const closeSeqAtSchedule = Number(selectTool?._mindmapEditorCloseSeq || 0);
|
|
45
|
-
let cancelledByPointer = false;
|
|
46
|
-
const cancelOnPointerDown = () => {
|
|
47
|
-
cancelledByPointer = true;
|
|
48
|
-
};
|
|
49
|
-
const cancelOnEscape = (event) => {
|
|
50
|
-
if (event?.key === 'Escape') {
|
|
51
|
-
cancelledByPointer = true;
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
if (doc && typeof doc.addEventListener === 'function') {
|
|
55
|
-
doc.addEventListener('pointerdown', cancelOnPointerDown, true);
|
|
56
|
-
doc.addEventListener('keydown', cancelOnEscape, true);
|
|
57
|
-
}
|
|
58
|
-
setTimeout(() => {
|
|
59
|
-
if (doc && typeof doc.removeEventListener === 'function') {
|
|
60
|
-
doc.removeEventListener('pointerdown', cancelOnPointerDown, true);
|
|
61
|
-
doc.removeEventListener('keydown', cancelOnEscape, true);
|
|
62
|
-
}
|
|
63
|
-
if (cancelledByPointer) return;
|
|
64
|
-
const latestSelectTool = getSelectTool(board);
|
|
65
|
-
const latestCloseSeq = Number(latestSelectTool?._mindmapEditorCloseSeq || 0);
|
|
66
|
-
if (latestCloseSeq !== closeSeqAtSchedule) return;
|
|
67
|
-
|
|
68
|
-
const nextSelectTool = getSelectTool(board);
|
|
69
|
-
const nextHasActiveEditor = Boolean(nextSelectTool?.textEditor?.active);
|
|
70
|
-
const nextHasEditorDom = hasOpenTextEditorInDom(board);
|
|
71
|
-
if (nextHasActiveEditor || nextHasEditorDom) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
board.coreMoodboard.eventBus.emit(Events.Keyboard.ToolSelect, { tool: 'select' });
|
|
75
|
-
board.coreMoodboard.eventBus.emit(Events.Tool.ObjectEdit, {
|
|
76
|
-
object: {
|
|
77
|
-
id: createdObject.id,
|
|
78
|
-
type: 'mindmap',
|
|
79
|
-
position: createdObject.position || null,
|
|
80
|
-
properties: createdObject.properties || {},
|
|
81
|
-
},
|
|
82
|
-
create: true,
|
|
83
|
-
});
|
|
84
|
-
}, 0);
|
|
85
|
-
}
|
|
56
|
+
if (createdObject?.id) {
|
|
57
|
+
focusCreatedObject(board, createdObject);
|
|
86
58
|
}
|
|
87
59
|
});
|
|
88
60
|
|
|
@@ -510,7 +510,9 @@ export function openMindmapEditor(object, create = false) {
|
|
|
510
510
|
const sideButton = (typeof target.closest === 'function')
|
|
511
511
|
? target.closest('.mb-mindmap-side-btn')
|
|
512
512
|
: null;
|
|
513
|
-
|
|
513
|
+
// Allow all mindmap "+" buttons to complete their click flow
|
|
514
|
+
// without collapsing current selection in capture phase.
|
|
515
|
+
if (sideButton) return;
|
|
514
516
|
finalize(true);
|
|
515
517
|
if (typeof this.clearSelection === 'function') {
|
|
516
518
|
this.clearSelection();
|
|
@@ -209,7 +209,10 @@ function relayoutMindmapBranchLevel({ core, eventBus, parentId, side }) {
|
|
|
209
209
|
if (!(targetX === currentX && targetY === currentY)) {
|
|
210
210
|
core.updateObjectPositionDirect(node.id, { x: targetX, y: targetY }, { snap: false });
|
|
211
211
|
eventBus.emit(Events.Object.TransformUpdated, { objectId: node.id });
|
|
212
|
-
eventBus.emit(Events.Tool.DragUpdate, {
|
|
212
|
+
eventBus.emit(Events.Tool.DragUpdate, {
|
|
213
|
+
object: node.id,
|
|
214
|
+
position: { x: targetX, y: targetY },
|
|
215
|
+
});
|
|
213
216
|
movedPositions.set(node.id, { x: targetX, y: targetY });
|
|
214
217
|
|
|
215
218
|
const dx = Math.round(targetX - currentX);
|
|
@@ -233,7 +236,10 @@ function relayoutMindmapBranchLevel({ core, eventBus, parentId, side }) {
|
|
|
233
236
|
};
|
|
234
237
|
core.updateObjectPositionDirect(descId, nextPos, { snap: false });
|
|
235
238
|
eventBus.emit(Events.Object.TransformUpdated, { objectId: descId });
|
|
236
|
-
eventBus.emit(Events.Tool.DragUpdate, {
|
|
239
|
+
eventBus.emit(Events.Tool.DragUpdate, {
|
|
240
|
+
object: descId,
|
|
241
|
+
position: nextPos,
|
|
242
|
+
});
|
|
237
243
|
movedPositions.set(descId, nextPos);
|
|
238
244
|
});
|
|
239
245
|
}
|
|
@@ -965,7 +971,10 @@ export class HandlesDomRenderer {
|
|
|
965
971
|
const nextPos = { x: Math.round(Number(snap.x) + dx), y: Math.round(Number(snap.y) + dy) };
|
|
966
972
|
core.updateObjectPositionDirect(nodeId, nextPos, { snap: false });
|
|
967
973
|
eventBus.emit(Events.Object.TransformUpdated, { objectId: nodeId });
|
|
968
|
-
eventBus.emit(Events.Tool.DragUpdate, {
|
|
974
|
+
eventBus.emit(Events.Tool.DragUpdate, {
|
|
975
|
+
object: nodeId,
|
|
976
|
+
position: nextPos,
|
|
977
|
+
});
|
|
969
978
|
});
|
|
970
979
|
translatedScopeByCompound.set(compoundId, moveScopeIds);
|
|
971
980
|
logMindmapCompoundDebug('layout:drag-end-translate-scope', {
|
|
@@ -994,7 +1003,10 @@ export class HandlesDomRenderer {
|
|
|
994
1003
|
const nextPos = { x: Math.round(snap.x), y: Math.round(snap.y) };
|
|
995
1004
|
core.updateObjectPositionDirect(nodeId, nextPos, { snap: false });
|
|
996
1005
|
eventBus.emit(Events.Object.TransformUpdated, { objectId: nodeId });
|
|
997
|
-
eventBus.emit(Events.Tool.DragUpdate, {
|
|
1006
|
+
eventBus.emit(Events.Tool.DragUpdate, {
|
|
1007
|
+
object: nodeId,
|
|
1008
|
+
position: nextPos,
|
|
1009
|
+
});
|
|
998
1010
|
});
|
|
999
1011
|
logMindmapCompoundDebug('layout:drag-end-restore-compound', {
|
|
1000
1012
|
compoundId,
|