@logicflow/core 2.1.6 → 2.1.8

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/es/LogicFlow.js CHANGED
@@ -1217,7 +1217,6 @@ var LogicFlow = /** @class */ (function () {
1217
1217
  this.graphModel.destroy();
1218
1218
  this.tool.destroy();
1219
1219
  this.history.destroy();
1220
- clearThemeMode();
1221
1220
  for (var extensionName in this.extension) {
1222
1221
  var extensionInstance = this.extension[extensionName];
1223
1222
  if ('destroy' in extensionInstance) {
@@ -43,6 +43,7 @@ var __read = (this && this.__read) || function (o, n) {
43
43
  import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
44
44
  import { Component, createRef } from 'preact/compat';
45
45
  import { Circle } from '../shape';
46
+ import { isNil, isFunction } from 'lodash-es';
46
47
  import { LineText } from '../text';
47
48
  import { ElementState, EventType, ModelType, TextMode } from '../../constant';
48
49
  import { isMultipleSelect, getClosestPointOfPolyline, degrees, getThetaOfVector, } from '../../util';
@@ -193,6 +194,14 @@ var BaseEdge = /** @class */ (function (_super) {
193
194
  e: e,
194
195
  position: position,
195
196
  });
197
+ // 会偶现边点击后会马上失去焦点的问题,这里手动让节点获焦以解决这个问题
198
+ var el_1 = e.currentTarget;
199
+ var rAF = !isNil(window) && isFunction(window.requestAnimationFrame)
200
+ ? window.requestAnimationFrame.bind(window)
201
+ : function (fn) { return setTimeout(fn, 0); };
202
+ rAF(function () {
203
+ el_1.focus();
204
+ });
196
205
  }
197
206
  var editConfigModel = graphModel.editConfigModel;
198
207
  graphModel.selectEdgeById(model.id, isMultipleSelect(e, editConfigModel));
@@ -51,7 +51,7 @@ var OutlineOverlay = /** @class */ (function (_super) {
51
51
  var isHovered = element.isHovered, isSelected = element.isSelected, x = element.x, y = element.y, width = element.width, height = element.height;
52
52
  if ((nodeSelectedOutline && isSelected) ||
53
53
  (hoverOutline && isHovered)) {
54
- var style_1 = element.getOutlineStyle();
54
+ var style_1 = element.getOutlineStyle() || {};
55
55
  var attributes_1 = {};
56
56
  Object.keys(style_1).forEach(function (key) {
57
57
  if (key !== 'hover') {
package/lib/LogicFlow.js CHANGED
@@ -1246,7 +1246,6 @@ var LogicFlow = /** @class */ (function () {
1246
1246
  this.graphModel.destroy();
1247
1247
  this.tool.destroy();
1248
1248
  this.history.destroy();
1249
- (0, util_1.clearThemeMode)();
1250
1249
  for (var extensionName in this.extension) {
1251
1250
  var extensionInstance = this.extension[extensionName];
1252
1251
  if ('destroy' in extensionInstance) {
@@ -69,6 +69,7 @@ exports.BaseEdge = void 0;
69
69
  var jsx_runtime_1 = require("preact/jsx-runtime");
70
70
  var compat_1 = require("preact/compat");
71
71
  var shape_1 = require("../shape");
72
+ var lodash_es_1 = require("lodash-es");
72
73
  var text_1 = require("../text");
73
74
  var constant_1 = require("../../constant");
74
75
  var util_1 = require("../../util");
@@ -219,6 +220,14 @@ var BaseEdge = /** @class */ (function (_super) {
219
220
  e: e,
220
221
  position: position,
221
222
  });
223
+ // 会偶现边点击后会马上失去焦点的问题,这里手动让节点获焦以解决这个问题
224
+ var el_1 = e.currentTarget;
225
+ var rAF = !(0, lodash_es_1.isNil)(window) && (0, lodash_es_1.isFunction)(window.requestAnimationFrame)
226
+ ? window.requestAnimationFrame.bind(window)
227
+ : function (fn) { return setTimeout(fn, 0); };
228
+ rAF(function () {
229
+ el_1.focus();
230
+ });
222
231
  }
223
232
  var editConfigModel = graphModel.editConfigModel;
224
233
  graphModel.selectEdgeById(model.id, (0, util_1.isMultipleSelect)(e, editConfigModel));
@@ -54,7 +54,7 @@ var OutlineOverlay = /** @class */ (function (_super) {
54
54
  var isHovered = element.isHovered, isSelected = element.isSelected, x = element.x, y = element.y, width = element.width, height = element.height;
55
55
  if ((nodeSelectedOutline && isSelected) ||
56
56
  (hoverOutline && isHovered)) {
57
- var style_1 = element.getOutlineStyle();
57
+ var style_1 = element.getOutlineStyle() || {};
58
58
  var attributes_1 = {};
59
59
  Object.keys(style_1).forEach(function (key) {
60
60
  if (key !== 'hover') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logicflow/core",
3
- "version": "2.1.6",
3
+ "version": "2.1.8",
4
4
  "description": "LogicFlow, help you quickly create flowcharts",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
package/src/LogicFlow.tsx CHANGED
@@ -1445,7 +1445,6 @@ export class LogicFlow {
1445
1445
  this.graphModel.destroy()
1446
1446
  this.tool.destroy()
1447
1447
  this.history.destroy()
1448
- clearThemeMode()
1449
1448
  for (const extensionName in this.extension) {
1450
1449
  const extensionInstance = this.extension[extensionName]
1451
1450
  if ('destroy' in extensionInstance) {
@@ -1,5 +1,6 @@
1
1
  import { createElement as h, Component, createRef } from 'preact/compat'
2
2
  import { Circle } from '../shape'
3
+ import { isNil, isFunction } from 'lodash-es'
3
4
  import { LineText } from '../text'
4
5
  import LogicFlow from '../../LogicFlow'
5
6
  import { GraphModel, BaseEdgeModel, PolylineEdgeModel } from '../../model'
@@ -550,6 +551,15 @@ export abstract class BaseEdge<P extends IProps> extends Component<
550
551
  e,
551
552
  position,
552
553
  })
554
+ // 会偶现边点击后会马上失去焦点的问题,这里手动让节点获焦以解决这个问题
555
+ const el = e.currentTarget as HTMLElement
556
+ const rAF =
557
+ !isNil(window) && isFunction(window.requestAnimationFrame)
558
+ ? window.requestAnimationFrame.bind(window)
559
+ : (fn: () => void) => setTimeout(fn, 0)
560
+ rAF(() => {
561
+ el.focus()
562
+ })
553
563
  }
554
564
  const { editConfigModel } = graphModel
555
565
  graphModel.selectEdgeById(model.id, isMultipleSelect(e, editConfigModel))
@@ -31,7 +31,7 @@ export class OutlineOverlay extends Component<IProps> {
31
31
  (nodeSelectedOutline && isSelected) ||
32
32
  (hoverOutline && isHovered)
33
33
  ) {
34
- const style = element.getOutlineStyle()
34
+ const style = element.getOutlineStyle() || {}
35
35
  let attributes = {}
36
36
  Object.keys(style).forEach((key) => {
37
37
  if (key !== 'hover') {