@logicflow/core 2.1.6 → 2.1.7

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.
@@ -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));
@@ -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));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logicflow/core",
3
- "version": "2.1.6",
3
+ "version": "2.1.7",
4
4
  "description": "LogicFlow, help you quickly create flowcharts",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -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))