@flowgram.ai/free-container-plugin 0.1.25 → 0.1.27
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/esm/index.js +326 -77
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +28 -12
- package/dist/index.d.ts +28 -12
- package/dist/index.js +332 -81
- package/dist/index.js.map +1 -1
- package/package.json +11 -10
package/dist/index.js
CHANGED
|
@@ -43,8 +43,10 @@ __export(src_exports, {
|
|
|
43
43
|
SubCanvasBackground: () => SubCanvasBackground,
|
|
44
44
|
SubCanvasBorder: () => SubCanvasBorder,
|
|
45
45
|
SubCanvasRender: () => SubCanvasRender,
|
|
46
|
+
SubCanvasTips: () => SubCanvasTips,
|
|
46
47
|
createContainerNodePlugin: () => createContainerNodePlugin,
|
|
47
|
-
useNodeSize: () => useNodeSize
|
|
48
|
+
useNodeSize: () => useNodeSize,
|
|
49
|
+
useSyncNodeRenderSize: () => useSyncNodeRenderSize
|
|
48
50
|
});
|
|
49
51
|
module.exports = __toCommonJS(src_exports);
|
|
50
52
|
|
|
@@ -80,23 +82,12 @@ var NodeIntoContainerService = class {
|
|
|
80
82
|
this.initState();
|
|
81
83
|
this.toDispose.dispose();
|
|
82
84
|
}
|
|
83
|
-
/** 移除节点连线 */
|
|
84
|
-
async removeNodeLines(node) {
|
|
85
|
-
const lines = this.linesManager.getAllLines();
|
|
86
|
-
lines.forEach((line) => {
|
|
87
|
-
if (line.from.id !== node.id && line.to?.id !== node.id) {
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
line.dispose();
|
|
91
|
-
});
|
|
92
|
-
await this.nextFrame();
|
|
93
|
-
}
|
|
94
85
|
/** 将节点移出容器 */
|
|
95
86
|
async moveOutContainer(params) {
|
|
96
87
|
const { node } = params;
|
|
97
88
|
const parentNode = node.parent;
|
|
98
89
|
const containerNode = parentNode?.parent;
|
|
99
|
-
const nodeJSON =
|
|
90
|
+
const nodeJSON = this.document.toNodeJSON(node);
|
|
100
91
|
if (!parentNode || !containerNode || !this.isContainer(parentNode) || !nodeJSON.meta?.position) {
|
|
101
92
|
return;
|
|
102
93
|
}
|
|
@@ -134,6 +125,20 @@ var NodeIntoContainerService = class {
|
|
|
134
125
|
}
|
|
135
126
|
return true;
|
|
136
127
|
}
|
|
128
|
+
/** 移除节点所有非法连线 */
|
|
129
|
+
async clearInvalidLines(params) {
|
|
130
|
+
const { dragNode, sourceParent } = params;
|
|
131
|
+
if (!dragNode) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (dragNode.parent === sourceParent) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if (dragNode.parent?.flowNodeType === import_document.FlowNodeBaseType.GROUP || sourceParent?.flowNodeType === import_document.FlowNodeBaseType.GROUP) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
await this.removeNodeLines(dragNode);
|
|
141
|
+
}
|
|
137
142
|
/** 初始化状态 */
|
|
138
143
|
initState() {
|
|
139
144
|
this.state = {
|
|
@@ -176,7 +181,10 @@ var NodeIntoContainerService = class {
|
|
|
176
181
|
throttledDraggingNode.cancel();
|
|
177
182
|
draggingNode(event);
|
|
178
183
|
await this.dropNodeToContainer();
|
|
179
|
-
await this.clearInvalidLines(
|
|
184
|
+
await this.clearInvalidLines({
|
|
185
|
+
dragNode: this.state.dragNode,
|
|
186
|
+
sourceParent: this.state.sourceParent
|
|
187
|
+
});
|
|
180
188
|
this.setDropNode(void 0);
|
|
181
189
|
this.initState();
|
|
182
190
|
this.historyService.endTransaction();
|
|
@@ -198,18 +206,11 @@ var NodeIntoContainerService = class {
|
|
|
198
206
|
await this.nextFrame();
|
|
199
207
|
this.dragService.startDragSelectedNodes(event.triggerEvent);
|
|
200
208
|
}
|
|
201
|
-
/**
|
|
202
|
-
async
|
|
203
|
-
const { dragNode, sourceParent } = this.state;
|
|
204
|
-
if (!dragNode) {
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
if (dragNode.parent === sourceParent) {
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
209
|
+
/** 移除节点连线 */
|
|
210
|
+
async removeNodeLines(node) {
|
|
210
211
|
const lines = this.linesManager.getAllLines();
|
|
211
212
|
lines.forEach((line) => {
|
|
212
|
-
if (line.from.id !==
|
|
213
|
+
if (line.from.id !== node.id && line.to?.id !== node.id) {
|
|
213
214
|
return;
|
|
214
215
|
}
|
|
215
216
|
line.dispose();
|
|
@@ -262,13 +263,16 @@ var NodeIntoContainerService = class {
|
|
|
262
263
|
}
|
|
263
264
|
/** 获取容器节点transforms */
|
|
264
265
|
getContainerTransforms() {
|
|
265
|
-
return this.document.
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
return entity.getNodeMeta().selectable && entity.originParent.getNodeMeta().selectable;
|
|
266
|
+
return this.document.getAllNodes().filter((node) => {
|
|
267
|
+
if (node.originParent) {
|
|
268
|
+
return node.getNodeMeta().selectable && node.originParent.getNodeMeta().selectable;
|
|
269
269
|
}
|
|
270
|
-
return
|
|
271
|
-
}).filter((
|
|
270
|
+
return node.getNodeMeta().selectable;
|
|
271
|
+
}).filter((node) => this.isContainer(node)).sort((a, b) => {
|
|
272
|
+
const aIndex = a.renderData.stackIndex;
|
|
273
|
+
const bIndex = b.renderData.stackIndex;
|
|
274
|
+
return bIndex - aIndex;
|
|
275
|
+
}).map((node) => node.transform);
|
|
272
276
|
}
|
|
273
277
|
/** 放置节点到容器 */
|
|
274
278
|
async dropNodeToContainer() {
|
|
@@ -283,44 +287,66 @@ var NodeIntoContainerService = class {
|
|
|
283
287
|
}
|
|
284
288
|
/** 拖拽节点 */
|
|
285
289
|
draggingNode(nodeDragEvent) {
|
|
286
|
-
const { dragNode, isDraggingNode, transforms } = this.state;
|
|
287
|
-
if (!isDraggingNode || !dragNode ||
|
|
290
|
+
const { dragNode, isDraggingNode, transforms = [] } = this.state;
|
|
291
|
+
if (!isDraggingNode || !dragNode || !transforms?.length) {
|
|
288
292
|
return this.setDropNode(void 0);
|
|
289
293
|
}
|
|
290
294
|
const mousePos = this.playgroundConfig.getPosFromMouseEvent(nodeDragEvent.dragEvent);
|
|
295
|
+
const availableTransforms = transforms.filter(
|
|
296
|
+
(transform) => transform.entity.id !== dragNode.id
|
|
297
|
+
);
|
|
291
298
|
const collisionTransform = this.getCollisionTransform({
|
|
292
299
|
targetPoint: mousePos,
|
|
293
|
-
transforms:
|
|
300
|
+
transforms: availableTransforms
|
|
294
301
|
});
|
|
295
302
|
const dropNode = collisionTransform?.entity;
|
|
296
|
-
|
|
303
|
+
const canDrop = this.canDropToContainer({
|
|
304
|
+
dragNode,
|
|
305
|
+
dropNode
|
|
306
|
+
});
|
|
307
|
+
if (!canDrop) {
|
|
297
308
|
return this.setDropNode(void 0);
|
|
298
309
|
}
|
|
310
|
+
return this.setDropNode(dropNode);
|
|
311
|
+
}
|
|
312
|
+
/** 判断能否将节点拖入容器 */
|
|
313
|
+
canDropToContainer(params) {
|
|
314
|
+
const { dragNode, dropNode } = params;
|
|
315
|
+
const isDropContainer = dropNode?.getNodeMeta().isContainer;
|
|
316
|
+
if (!dropNode || !isDropContainer || this.isParent(dragNode, dropNode)) {
|
|
317
|
+
return false;
|
|
318
|
+
}
|
|
319
|
+
if (dragNode.flowNodeType === import_document.FlowNodeBaseType.GROUP && dropNode.flowNodeType !== import_document.FlowNodeBaseType.GROUP) {
|
|
320
|
+
return false;
|
|
321
|
+
}
|
|
299
322
|
const canDrop = this.dragService.canDropToNode({
|
|
300
323
|
dragNodeType: dragNode.flowNodeType,
|
|
301
324
|
dropNode
|
|
302
325
|
});
|
|
303
326
|
if (!canDrop.allowDrop) {
|
|
304
|
-
return
|
|
327
|
+
return false;
|
|
305
328
|
}
|
|
306
|
-
return
|
|
329
|
+
return true;
|
|
330
|
+
}
|
|
331
|
+
/** 判断一个节点是否为另一个节点的父节点(向上查找直到根节点) */
|
|
332
|
+
isParent(node, parent) {
|
|
333
|
+
let current = node.parent;
|
|
334
|
+
while (current) {
|
|
335
|
+
if (current.id === parent.id) {
|
|
336
|
+
return true;
|
|
337
|
+
}
|
|
338
|
+
current = current.parent;
|
|
339
|
+
}
|
|
340
|
+
return false;
|
|
307
341
|
}
|
|
308
342
|
/** 将节点移入容器 */
|
|
309
343
|
async moveIntoContainer(params) {
|
|
310
344
|
const { node, containerNode } = params;
|
|
311
345
|
const parentNode = node.parent;
|
|
312
|
-
const nodeJSON = await this.document.toNodeJSON(node);
|
|
313
346
|
this.operationService.moveNode(node, {
|
|
314
347
|
parent: containerNode
|
|
315
348
|
});
|
|
316
|
-
this.operationService.updateNodePosition(
|
|
317
|
-
node,
|
|
318
|
-
this.dragService.adjustSubNodePosition(
|
|
319
|
-
nodeJSON.type,
|
|
320
|
-
containerNode,
|
|
321
|
-
nodeJSON.meta.position
|
|
322
|
-
)
|
|
323
|
-
);
|
|
349
|
+
this.operationService.updateNodePosition(node, this.adjustSubNodePosition(node, containerNode));
|
|
324
350
|
await this.nextFrame();
|
|
325
351
|
this.emitter.fire({
|
|
326
352
|
type: "in" /* In */,
|
|
@@ -329,6 +355,33 @@ var NodeIntoContainerService = class {
|
|
|
329
355
|
targetContainer: containerNode
|
|
330
356
|
});
|
|
331
357
|
}
|
|
358
|
+
/**
|
|
359
|
+
* 如果存在容器节点,且传入鼠标坐标,需要用容器的坐标减去传入的鼠标坐标
|
|
360
|
+
*/
|
|
361
|
+
adjustSubNodePosition(targetNode, containerNode) {
|
|
362
|
+
if (containerNode.flowNodeType === import_document.FlowNodeBaseType.ROOT) {
|
|
363
|
+
return targetNode.transform.position;
|
|
364
|
+
}
|
|
365
|
+
const nodeWorldTransform = targetNode.transform.transform.worldTransform;
|
|
366
|
+
const containerWorldTransform = containerNode.transform.transform.worldTransform;
|
|
367
|
+
const nodePosition = {
|
|
368
|
+
x: nodeWorldTransform.tx,
|
|
369
|
+
y: nodeWorldTransform.ty
|
|
370
|
+
};
|
|
371
|
+
const isParentEmpty = !containerNode.children || containerNode.children.length === 0;
|
|
372
|
+
const containerPadding = this.document.layout.getPadding(containerNode);
|
|
373
|
+
if (isParentEmpty) {
|
|
374
|
+
return {
|
|
375
|
+
x: 0,
|
|
376
|
+
y: containerPadding.top
|
|
377
|
+
};
|
|
378
|
+
} else {
|
|
379
|
+
return {
|
|
380
|
+
x: nodePosition.x - containerWorldTransform.tx,
|
|
381
|
+
y: nodePosition.y - containerWorldTransform.ty
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
}
|
|
332
385
|
isContainer(node) {
|
|
333
386
|
return node?.getNodeMeta().isContainer ?? false;
|
|
334
387
|
}
|
|
@@ -371,6 +424,25 @@ NodeIntoContainerService = __decorateClass([
|
|
|
371
424
|
(0, import_inversify.injectable)()
|
|
372
425
|
], NodeIntoContainerService);
|
|
373
426
|
|
|
427
|
+
// src/node-into-container/plugin.tsx
|
|
428
|
+
var import_core2 = require("@flowgram.ai/core");
|
|
429
|
+
var createContainerNodePlugin = (0, import_core2.definePluginCreator)({
|
|
430
|
+
onBind: ({ bind }) => {
|
|
431
|
+
bind(NodeIntoContainerService).toSelf().inSingletonScope();
|
|
432
|
+
},
|
|
433
|
+
onInit(ctx, options) {
|
|
434
|
+
ctx.get(NodeIntoContainerService).init();
|
|
435
|
+
},
|
|
436
|
+
onReady(ctx, options) {
|
|
437
|
+
if (options.disableNodeIntoContainer !== true) {
|
|
438
|
+
ctx.get(NodeIntoContainerService).ready();
|
|
439
|
+
}
|
|
440
|
+
},
|
|
441
|
+
onDispose(ctx) {
|
|
442
|
+
ctx.get(NodeIntoContainerService).dispose();
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
|
|
374
446
|
// src/sub-canvas/hooks/use-node-size.ts
|
|
375
447
|
var import_react = require("react");
|
|
376
448
|
var import_free_layout_core2 = require("@flowgram.ai/free-layout-core");
|
|
@@ -414,9 +486,23 @@ var useNodeSize = () => {
|
|
|
414
486
|
};
|
|
415
487
|
};
|
|
416
488
|
|
|
417
|
-
// src/sub-canvas/
|
|
418
|
-
var import_react2 =
|
|
489
|
+
// src/sub-canvas/hooks/use-sync-node-render-size.ts
|
|
490
|
+
var import_react2 = require("react");
|
|
419
491
|
var import_free_layout_core3 = require("@flowgram.ai/free-layout-core");
|
|
492
|
+
var useSyncNodeRenderSize = (nodeSize) => {
|
|
493
|
+
const node = (0, import_free_layout_core3.useCurrentEntity)();
|
|
494
|
+
(0, import_react2.useLayoutEffect)(() => {
|
|
495
|
+
if (!nodeSize) {
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
node.renderData.node.style.width = nodeSize.width + "px";
|
|
499
|
+
node.renderData.node.style.height = nodeSize.height + "px";
|
|
500
|
+
}, [nodeSize?.width, nodeSize?.height]);
|
|
501
|
+
};
|
|
502
|
+
|
|
503
|
+
// src/sub-canvas/components/background/index.tsx
|
|
504
|
+
var import_react3 = __toESM(require("react"));
|
|
505
|
+
var import_free_layout_core4 = require("@flowgram.ai/free-layout-core");
|
|
420
506
|
|
|
421
507
|
// src/sub-canvas/components/background/style.ts
|
|
422
508
|
var import_styled_components = __toESM(require("styled-components"));
|
|
@@ -429,8 +515,8 @@ var SubCanvasBackgroundStyle = import_styled_components.default.div`
|
|
|
429
515
|
|
|
430
516
|
// src/sub-canvas/components/background/index.tsx
|
|
431
517
|
var SubCanvasBackground = () => {
|
|
432
|
-
const node = (0,
|
|
433
|
-
return /* @__PURE__ */
|
|
518
|
+
const node = (0, import_free_layout_core4.useCurrentEntity)();
|
|
519
|
+
return /* @__PURE__ */ import_react3.default.createElement(SubCanvasBackgroundStyle, { className: "sub-canvas-background", "data-flow-editor-selectable": "true" }, /* @__PURE__ */ import_react3.default.createElement("svg", { width: "100%", height: "100%" }, /* @__PURE__ */ import_react3.default.createElement("pattern", { id: "sub-canvas-dot-pattern", width: "20", height: "20", patternUnits: "userSpaceOnUse" }, /* @__PURE__ */ import_react3.default.createElement("circle", { cx: "1", cy: "1", r: "1", stroke: "#eceeef", fillOpacity: "0.5" })), /* @__PURE__ */ import_react3.default.createElement(
|
|
434
520
|
"rect",
|
|
435
521
|
{
|
|
436
522
|
width: "100%",
|
|
@@ -442,7 +528,7 @@ var SubCanvasBackground = () => {
|
|
|
442
528
|
};
|
|
443
529
|
|
|
444
530
|
// src/sub-canvas/components/border/index.tsx
|
|
445
|
-
var
|
|
531
|
+
var import_react4 = __toESM(require("react"));
|
|
446
532
|
|
|
447
533
|
// src/sub-canvas/components/border/style.ts
|
|
448
534
|
var import_styled_components2 = __toESM(require("styled-components"));
|
|
@@ -480,7 +566,7 @@ var SubCanvasBorderStyle = import_styled_components2.default.div`
|
|
|
480
566
|
`;
|
|
481
567
|
|
|
482
568
|
// src/sub-canvas/components/border/index.tsx
|
|
483
|
-
var SubCanvasBorder = ({ style, children }) => /* @__PURE__ */
|
|
569
|
+
var SubCanvasBorder = ({ style, children }) => /* @__PURE__ */ import_react4.default.createElement(
|
|
484
570
|
SubCanvasBorderStyle,
|
|
485
571
|
{
|
|
486
572
|
className: "sub-canvas-border",
|
|
@@ -492,8 +578,8 @@ var SubCanvasBorder = ({ style, children }) => /* @__PURE__ */ import_react3.def
|
|
|
492
578
|
);
|
|
493
579
|
|
|
494
580
|
// src/sub-canvas/components/render/index.tsx
|
|
495
|
-
var
|
|
496
|
-
var
|
|
581
|
+
var import_react8 = __toESM(require("react"));
|
|
582
|
+
var import_free_layout_core6 = require("@flowgram.ai/free-layout-core");
|
|
497
583
|
|
|
498
584
|
// src/sub-canvas/components/render/style.ts
|
|
499
585
|
var import_styled_components3 = __toESM(require("styled-components"));
|
|
@@ -502,18 +588,200 @@ var SubCanvasRenderStyle = import_styled_components3.default.div`
|
|
|
502
588
|
height: 100%;
|
|
503
589
|
`;
|
|
504
590
|
|
|
591
|
+
// src/sub-canvas/components/tips/index.tsx
|
|
592
|
+
var import_react7 = __toESM(require("react"));
|
|
593
|
+
|
|
594
|
+
// src/sub-canvas/components/tips/use-control.ts
|
|
595
|
+
var import_react5 = require("react");
|
|
596
|
+
var import_free_layout_core5 = require("@flowgram.ai/free-layout-core");
|
|
597
|
+
var import_core3 = require("@flowgram.ai/core");
|
|
598
|
+
|
|
599
|
+
// src/sub-canvas/components/tips/global-store.ts
|
|
600
|
+
var STORAGE_KEY = "workflow-move-into-sub-canvas-tip-visible";
|
|
601
|
+
var STORAGE_VALUE = "false";
|
|
602
|
+
var TipsGlobalStore = class _TipsGlobalStore {
|
|
603
|
+
constructor() {
|
|
604
|
+
this.closed = false;
|
|
605
|
+
}
|
|
606
|
+
static get instance() {
|
|
607
|
+
if (!this._instance) {
|
|
608
|
+
this._instance = new _TipsGlobalStore();
|
|
609
|
+
}
|
|
610
|
+
return this._instance;
|
|
611
|
+
}
|
|
612
|
+
isClosed() {
|
|
613
|
+
return this.isCloseForever() || this.closed;
|
|
614
|
+
}
|
|
615
|
+
close() {
|
|
616
|
+
this.closed = true;
|
|
617
|
+
}
|
|
618
|
+
isCloseForever() {
|
|
619
|
+
return localStorage.getItem(STORAGE_KEY) === STORAGE_VALUE;
|
|
620
|
+
}
|
|
621
|
+
closeForever() {
|
|
622
|
+
localStorage.setItem(STORAGE_KEY, STORAGE_VALUE);
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
|
|
626
|
+
// src/sub-canvas/components/tips/use-control.ts
|
|
627
|
+
var useControlTips = () => {
|
|
628
|
+
const node = (0, import_free_layout_core5.useCurrentEntity)();
|
|
629
|
+
const [visible, setVisible] = (0, import_react5.useState)(false);
|
|
630
|
+
const globalStore = TipsGlobalStore.instance;
|
|
631
|
+
const nodeIntoContainerService = (0, import_core3.useService)(NodeIntoContainerService);
|
|
632
|
+
const show = (0, import_react5.useCallback)(() => {
|
|
633
|
+
if (globalStore.isClosed()) {
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
setVisible(true);
|
|
637
|
+
}, [globalStore]);
|
|
638
|
+
const close = (0, import_react5.useCallback)(() => {
|
|
639
|
+
globalStore.close();
|
|
640
|
+
setVisible(false);
|
|
641
|
+
}, [globalStore]);
|
|
642
|
+
const closeForever = (0, import_react5.useCallback)(() => {
|
|
643
|
+
globalStore.closeForever();
|
|
644
|
+
close();
|
|
645
|
+
}, [close, globalStore]);
|
|
646
|
+
(0, import_react5.useEffect)(() => {
|
|
647
|
+
const inDisposer = nodeIntoContainerService.on((e) => {
|
|
648
|
+
if (e.type !== "in" /* In */) {
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
651
|
+
if (e.targetContainer === node) {
|
|
652
|
+
show();
|
|
653
|
+
}
|
|
654
|
+
});
|
|
655
|
+
const outDisposer = nodeIntoContainerService.on((e) => {
|
|
656
|
+
if (e.type !== "out" /* Out */) {
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
659
|
+
if (e.sourceContainer === node && !node.blocks.length) {
|
|
660
|
+
setVisible(false);
|
|
661
|
+
}
|
|
662
|
+
});
|
|
663
|
+
return () => {
|
|
664
|
+
inDisposer.dispose();
|
|
665
|
+
outDisposer.dispose();
|
|
666
|
+
};
|
|
667
|
+
}, [nodeIntoContainerService, node, show, close, visible]);
|
|
668
|
+
return {
|
|
669
|
+
visible,
|
|
670
|
+
close,
|
|
671
|
+
closeForever
|
|
672
|
+
};
|
|
673
|
+
};
|
|
674
|
+
|
|
675
|
+
// src/sub-canvas/components/tips/style.ts
|
|
676
|
+
var import_styled_components4 = __toESM(require("styled-components"));
|
|
677
|
+
var SubCanvasTipsStyle = import_styled_components4.default.div`
|
|
678
|
+
position: absolute;
|
|
679
|
+
top: 0;
|
|
680
|
+
|
|
681
|
+
width: 100%;
|
|
682
|
+
height: 28px;
|
|
683
|
+
|
|
684
|
+
.container {
|
|
685
|
+
height: 100%;
|
|
686
|
+
background-color: #e4e6f5;
|
|
687
|
+
border-radius: 4px 4px 0 0;
|
|
688
|
+
|
|
689
|
+
.content {
|
|
690
|
+
overflow: hidden;
|
|
691
|
+
display: inline-flex;
|
|
692
|
+
align-items: center;
|
|
693
|
+
justify-content: center;
|
|
694
|
+
|
|
695
|
+
width: 100%;
|
|
696
|
+
height: 100%;
|
|
697
|
+
|
|
698
|
+
.text {
|
|
699
|
+
font-size: 14px;
|
|
700
|
+
font-weight: 400;
|
|
701
|
+
font-style: normal;
|
|
702
|
+
line-height: 20px;
|
|
703
|
+
color: rgba(15, 21, 40, 82%);
|
|
704
|
+
text-overflow: ellipsis;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
.space {
|
|
708
|
+
width: 128px;
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
.actions {
|
|
713
|
+
position: absolute;
|
|
714
|
+
top: 0;
|
|
715
|
+
right: 0;
|
|
716
|
+
|
|
717
|
+
display: flex;
|
|
718
|
+
gap: 8px;
|
|
719
|
+
align-items: center;
|
|
720
|
+
|
|
721
|
+
height: 28px;
|
|
722
|
+
padding: 0 16px;
|
|
723
|
+
|
|
724
|
+
.close-forever {
|
|
725
|
+
cursor: pointer;
|
|
726
|
+
|
|
727
|
+
padding: 0 3px;
|
|
728
|
+
|
|
729
|
+
font-size: 12px;
|
|
730
|
+
font-weight: 400;
|
|
731
|
+
font-style: normal;
|
|
732
|
+
line-height: 12px;
|
|
733
|
+
color: rgba(32, 41, 69, 62%);
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
.close {
|
|
737
|
+
display: flex;
|
|
738
|
+
cursor: pointer;
|
|
739
|
+
height: 100%;
|
|
740
|
+
align-items: center;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
`;
|
|
745
|
+
|
|
746
|
+
// src/sub-canvas/components/tips/is-mac-os.ts
|
|
747
|
+
var isMacOS = /(Macintosh|MacIntel|MacPPC|Mac68K|iPad)/.test(navigator.userAgent);
|
|
748
|
+
|
|
749
|
+
// src/sub-canvas/components/tips/icon-close.tsx
|
|
750
|
+
var import_react6 = __toESM(require("react"));
|
|
751
|
+
var IconClose = () => /* @__PURE__ */ import_react6.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", fill: "none", viewBox: "0 0 16 16" }, /* @__PURE__ */ import_react6.default.createElement(
|
|
752
|
+
"path",
|
|
753
|
+
{
|
|
754
|
+
fill: "#060709",
|
|
755
|
+
fillOpacity: "0.5",
|
|
756
|
+
d: "M12.13 12.128a.5.5 0 0 0 .001-.706L8.71 8l3.422-3.423a.5.5 0 0 0-.001-.705.5.5 0 0 0-.706-.002L8.002 7.293 4.579 3.87a.5.5 0 0 0-.705.002.5.5 0 0 0-.002.705L7.295 8l-3.423 3.422a.5.5 0 0 0 .002.706c.195.195.51.197.705.001l3.423-3.422 3.422 3.422c.196.196.51.194.706-.001"
|
|
757
|
+
}
|
|
758
|
+
));
|
|
759
|
+
|
|
760
|
+
// src/sub-canvas/components/tips/index.tsx
|
|
761
|
+
var SubCanvasTips = () => {
|
|
762
|
+
const { visible, close, closeForever } = useControlTips();
|
|
763
|
+
if (!visible) {
|
|
764
|
+
return null;
|
|
765
|
+
}
|
|
766
|
+
return /* @__PURE__ */ import_react7.default.createElement(SubCanvasTipsStyle, { className: "sub-canvas-tips" }, /* @__PURE__ */ import_react7.default.createElement("div", { className: "container" }, /* @__PURE__ */ import_react7.default.createElement("div", { className: "content" }, /* @__PURE__ */ import_react7.default.createElement("p", { className: "text" }, `Hold ${isMacOS ? "Cmd \u2318" : "Ctrl"} to drag node out`), /* @__PURE__ */ import_react7.default.createElement(
|
|
767
|
+
"div",
|
|
768
|
+
{
|
|
769
|
+
className: "space",
|
|
770
|
+
style: {
|
|
771
|
+
width: 0
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
)), /* @__PURE__ */ import_react7.default.createElement("div", { className: "actions" }, /* @__PURE__ */ import_react7.default.createElement("p", { className: "close-forever", onClick: closeForever }, "Never Remind"), /* @__PURE__ */ import_react7.default.createElement("div", { className: "close", onClick: close }, /* @__PURE__ */ import_react7.default.createElement(IconClose, null)))));
|
|
775
|
+
};
|
|
776
|
+
|
|
505
777
|
// src/sub-canvas/components/render/index.tsx
|
|
506
778
|
var SubCanvasRender = ({ className, style }) => {
|
|
507
|
-
const node = (0,
|
|
779
|
+
const node = (0, import_free_layout_core6.useCurrentEntity)();
|
|
508
780
|
const nodeSize = useNodeSize();
|
|
509
|
-
const { height, width } = nodeSize ?? {};
|
|
510
781
|
const nodeHeight = nodeSize?.height ?? 0;
|
|
511
782
|
const { padding } = node.transform;
|
|
512
|
-
(
|
|
513
|
-
|
|
514
|
-
node.renderData.node.style.height = height + "px";
|
|
515
|
-
}, [height, width]);
|
|
516
|
-
return /* @__PURE__ */ import_react4.default.createElement(
|
|
783
|
+
useSyncNodeRenderSize(nodeSize);
|
|
784
|
+
return /* @__PURE__ */ import_react8.default.createElement(
|
|
517
785
|
SubCanvasRenderStyle,
|
|
518
786
|
{
|
|
519
787
|
className: `sub-canvas-render ${className ?? ""}`,
|
|
@@ -526,28 +794,9 @@ var SubCanvasRender = ({ className, style }) => {
|
|
|
526
794
|
e.stopPropagation();
|
|
527
795
|
}
|
|
528
796
|
},
|
|
529
|
-
/* @__PURE__ */
|
|
797
|
+
/* @__PURE__ */ import_react8.default.createElement(SubCanvasBorder, null, /* @__PURE__ */ import_react8.default.createElement(SubCanvasBackground, null), /* @__PURE__ */ import_react8.default.createElement(SubCanvasTips, null))
|
|
530
798
|
);
|
|
531
799
|
};
|
|
532
|
-
|
|
533
|
-
// src/plugin.tsx
|
|
534
|
-
var import_core2 = require("@flowgram.ai/core");
|
|
535
|
-
var createContainerNodePlugin = (0, import_core2.definePluginCreator)({
|
|
536
|
-
onBind: ({ bind }) => {
|
|
537
|
-
bind(NodeIntoContainerService).toSelf().inSingletonScope();
|
|
538
|
-
},
|
|
539
|
-
onInit(ctx, options) {
|
|
540
|
-
ctx.get(NodeIntoContainerService).init();
|
|
541
|
-
},
|
|
542
|
-
onReady(ctx, options) {
|
|
543
|
-
if (options.disableNodeIntoContainer !== true) {
|
|
544
|
-
ctx.get(NodeIntoContainerService).ready();
|
|
545
|
-
}
|
|
546
|
-
},
|
|
547
|
-
onDispose(ctx) {
|
|
548
|
-
ctx.get(NodeIntoContainerService).dispose();
|
|
549
|
-
}
|
|
550
|
-
});
|
|
551
800
|
// Annotate the CommonJS export names for ESM import in node:
|
|
552
801
|
0 && (module.exports = {
|
|
553
802
|
NodeIntoContainerService,
|
|
@@ -555,7 +804,9 @@ var createContainerNodePlugin = (0, import_core2.definePluginCreator)({
|
|
|
555
804
|
SubCanvasBackground,
|
|
556
805
|
SubCanvasBorder,
|
|
557
806
|
SubCanvasRender,
|
|
807
|
+
SubCanvasTips,
|
|
558
808
|
createContainerNodePlugin,
|
|
559
|
-
useNodeSize
|
|
809
|
+
useNodeSize,
|
|
810
|
+
useSyncNodeRenderSize
|
|
560
811
|
});
|
|
561
812
|
//# sourceMappingURL=index.js.map
|