mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-22 06:37:56 +01:00
Fix connection line type.
This commit is contained in:
parent
68866fe4fe
commit
a230d343ab
@ -89,10 +89,8 @@ const Editor = ({
|
||||
model.registerEvents(setCanvasUpdate, capability);
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(JSON.stringify(e));
|
||||
window.newrelic?.noticeError(
|
||||
new Error(`Unexpected error loading map ${mapInfo.getId()} = ${JSON.stringify(e)}`),
|
||||
);
|
||||
console.error(e);
|
||||
window.newrelic?.noticeError(e);
|
||||
});
|
||||
setModel(model);
|
||||
}
|
||||
|
@ -22,23 +22,25 @@
|
||||
"@typescript-eslint"
|
||||
],
|
||||
"rules": {
|
||||
// ignore errors when a line finishes with (setting this value to 0 ignores all errors)
|
||||
"operator-linebreak": [
|
||||
"error", "after", {
|
||||
"overrides": {
|
||||
"+": "ignore",
|
||||
"-": "ignore",
|
||||
":": "ignore",
|
||||
"*": "ignore",
|
||||
"?": "ignore",
|
||||
">": "ignore",
|
||||
"||": "ignore",
|
||||
"&&": "ignore",
|
||||
"(": "ignore"
|
||||
}
|
||||
}
|
||||
],
|
||||
"object-curly-newline": "off",
|
||||
// ignore errors when a line finishes with (setting this value to 0 ignores all errors)
|
||||
"operator-linebreak": [
|
||||
"error",
|
||||
"after",
|
||||
{
|
||||
"overrides": {
|
||||
"+": "ignore",
|
||||
"-": "ignore",
|
||||
":": "ignore",
|
||||
"*": "ignore",
|
||||
"?": "ignore",
|
||||
">": "ignore",
|
||||
"||": "ignore",
|
||||
"&&": "ignore",
|
||||
"(": "ignore"
|
||||
}
|
||||
}
|
||||
],
|
||||
"object-curly-newline": "off",
|
||||
"no-underscore-dangle": "off",
|
||||
"no-plusplus": "off",
|
||||
"no-param-reassign": "off",
|
||||
@ -48,10 +50,10 @@
|
||||
],
|
||||
"class-methods-use-this": "off",
|
||||
"no-console": "off",
|
||||
// codebase contains many this aliases, fix in the future?
|
||||
"@typescript-eslint/no-explicit-any": "error",
|
||||
"@typescript-eslint/no-unused-vars": "error",
|
||||
"@typescript-eslint/no-this-alias": "off",
|
||||
// Remove once migration is completed ...
|
||||
"@typescript-eslint/no-explicit-any": "warn",
|
||||
"@typescript-eslint/no-non-null-assertion": "off",
|
||||
"import/extensions": [
|
||||
"error",
|
||||
"ignorePackages",
|
||||
@ -62,7 +64,7 @@
|
||||
"tsx": "never"
|
||||
}
|
||||
],
|
||||
"implicit-arrow-linebreak": "off"
|
||||
"implicit-arrow-linebreak": "off"
|
||||
},
|
||||
"settings": {
|
||||
"import/resolver": {
|
||||
|
1
packages/mindplot/src/@types/custom.d.ts
vendored
1
packages/mindplot/src/@types/custom.d.ts
vendored
@ -1,4 +1,5 @@
|
||||
declare module '*.svg' {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const content: any;
|
||||
export default content;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import { $assert } from '@wisemapping/core-js';
|
||||
import Point from '@wisemapping/web2d';
|
||||
import { Mindmap } from '..';
|
||||
import CommandContext from './CommandContext';
|
||||
import RelationshipControlPoints, { PivotType } from './RelationshipControlPoints';
|
||||
import { PivotType } from './RelationshipControlPoints';
|
||||
import Events from './Events';
|
||||
import NodeModel from './model/NodeModel';
|
||||
import RelationshipModel from './model/RelationshipModel';
|
||||
|
@ -16,7 +16,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { $assert, $defined } from '@wisemapping/core-js';
|
||||
import { $assert } from '@wisemapping/core-js';
|
||||
import { Point, CurvedLine, PolyLine, Line } from '@wisemapping/web2d';
|
||||
import { TopicShape } from './model/INodeModel';
|
||||
import RelationshipModel from './model/RelationshipModel';
|
||||
@ -24,18 +24,26 @@ import Topic from './Topic';
|
||||
import TopicConfig from './TopicConfig';
|
||||
import Workspace from './Workspace';
|
||||
|
||||
// eslint-disable-next-line no-shadow
|
||||
export enum LineType {
|
||||
SIMPLE,
|
||||
POLYLINE,
|
||||
CURVED,
|
||||
SIMPLE_CURVED,
|
||||
}
|
||||
|
||||
class ConnectionLine {
|
||||
protected _targetTopic: Topic;
|
||||
|
||||
protected _sourceTopic: Topic;
|
||||
|
||||
protected _lineType: number;
|
||||
protected _lineType: LineType;
|
||||
|
||||
protected _line2d: Line;
|
||||
|
||||
protected _model: RelationshipModel;
|
||||
|
||||
constructor(sourceNode: Topic, targetNode: Topic, lineType?: number) {
|
||||
constructor(sourceNode: Topic, targetNode: Topic) {
|
||||
$assert(targetNode, 'parentNode node can not be null');
|
||||
$assert(sourceNode, 'childNode node can not be null');
|
||||
$assert(sourceNode !== targetNode, 'Circular connection');
|
||||
@ -46,11 +54,11 @@ class ConnectionLine {
|
||||
let line: Line;
|
||||
const ctrlPoints = this._getCtrlPoints(sourceNode, targetNode);
|
||||
if (targetNode.getType() === 'CentralTopic') {
|
||||
line = this._createLine(lineType, ConnectionLine.CURVED);
|
||||
line = this._createLine(LineType.CURVED);
|
||||
line.setSrcControlPoint(ctrlPoints[0]);
|
||||
line.setDestControlPoint(ctrlPoints[1]);
|
||||
} else {
|
||||
line = this._createLine(lineType, ConnectionLine.SIMPLE_CURVED);
|
||||
line = this._createLine(LineType.SIMPLE_CURVED);
|
||||
line.setSrcControlPoint(ctrlPoints[0]);
|
||||
line.setDestControlPoint(ctrlPoints[1]);
|
||||
}
|
||||
@ -69,24 +77,25 @@ class ConnectionLine {
|
||||
return [new Point(deltaX, 0), new Point(-deltaX, 0)];
|
||||
}
|
||||
|
||||
protected _createLine(lineTypeParam: number, defaultStyle: number): Line {
|
||||
const lineType = $defined(lineTypeParam) ? lineTypeParam : defaultStyle;
|
||||
protected _createLine(lineType: LineType): Line {
|
||||
this._lineType = lineType;
|
||||
let line: ConnectionLine;
|
||||
switch (lineType) {
|
||||
case ConnectionLine.POLYLINE:
|
||||
case LineType.POLYLINE:
|
||||
line = new PolyLine();
|
||||
break;
|
||||
case ConnectionLine.CURVED:
|
||||
case LineType.CURVED:
|
||||
line = new CurvedLine();
|
||||
break;
|
||||
case ConnectionLine.SIMPLE_CURVED:
|
||||
case LineType.SIMPLE_CURVED:
|
||||
line = new CurvedLine();
|
||||
(line as CurvedLine).setStyle(CurvedLine.SIMPLE_LINE);
|
||||
break;
|
||||
default:
|
||||
case LineType.SIMPLE:
|
||||
line = new Line();
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unexpected line type. ${lineType}`);
|
||||
}
|
||||
return line;
|
||||
}
|
||||
@ -205,14 +214,6 @@ class ConnectionLine {
|
||||
this._line2d.moveToFront();
|
||||
}
|
||||
|
||||
static SIMPLE = 0;
|
||||
|
||||
static POLYLINE = 1;
|
||||
|
||||
static CURVED = 2;
|
||||
|
||||
static SIMPLE_CURVED = 3;
|
||||
|
||||
static getStrokeColor = () => '#495879';
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ class EmojiCharIcon implements Icon {
|
||||
return this.group.getPosition();
|
||||
}
|
||||
|
||||
addEvent(type: string, fnc: any): void {
|
||||
addEvent(type: string, fnc: (e: object) => void): void {
|
||||
this.element.addEvent(type, fnc);
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ ORDER_BY_TYPE.set('link', 2);
|
||||
class IconGroup {
|
||||
private _icons: ImageIcon[];
|
||||
|
||||
private _group: any;
|
||||
private _group;
|
||||
|
||||
private _removeTip: IconGroupRemoveTip;
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
import { $assert, $defined } from '@wisemapping/core-js';
|
||||
import { Arrow, Point, CurvedLine } from '@wisemapping/web2d';
|
||||
import ConnectionLine from './ConnectionLine';
|
||||
import ConnectionLine, { LineType } from './ConnectionLine';
|
||||
import RelationshipControlPoints from './RelationshipControlPoints';
|
||||
import RelationshipModel from './model/RelationshipModel';
|
||||
import PositionType from './PositionType';
|
||||
@ -48,7 +48,7 @@ class Relationship extends ConnectionLine {
|
||||
$assert(sourceNode, 'sourceNode can not be null');
|
||||
$assert(targetNode, 'targetNode can not be null');
|
||||
|
||||
super(sourceNode, targetNode, model.getLineType());
|
||||
super(sourceNode, targetNode);
|
||||
this.setModel(model);
|
||||
|
||||
const strokeColor = Relationship.getStrokeColor();
|
||||
@ -62,7 +62,7 @@ class Relationship extends ConnectionLine {
|
||||
this._line2d.setTestId(`${model.getFromNode()}-${model.getToNode()}-relationship`);
|
||||
|
||||
// Build focus shape ...
|
||||
this._focusShape = this._createLine(this.getLineType(), ConnectionLine.SIMPLE_CURVED);
|
||||
this._focusShape = this._createLine(LineType.SIMPLE_CURVED);
|
||||
this._focusShape.setStroke(8, 'solid', '#3f96ff');
|
||||
this._focusShape.setIsSrcControlPointCustom(false);
|
||||
this._focusShape.setIsDestControlPointCustom(false);
|
||||
|
@ -16,7 +16,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import $ from 'jquery';
|
||||
import { $assert, $defined } from '@wisemapping/core-js';
|
||||
import { $assert } from '@wisemapping/core-js';
|
||||
import { Point } from '@wisemapping/web2d';
|
||||
// https://stackoverflow.com/questions/60357083/does-not-use-passive-listeners-to-improve-scrolling-performance-lighthouse-repo
|
||||
// https://web.dev/uses-passive-event-listeners/?utm_source=lighthouse&utm_medium=lr
|
||||
|
@ -629,7 +629,7 @@ abstract class Topic extends NodeGraph {
|
||||
group.setTestId(model.getId());
|
||||
}
|
||||
|
||||
_registerDefaultListenersToElement(elem: ElementClass, topic: Topic) {
|
||||
private _registerDefaultListenersToElement(elem: ElementClass, topic: Topic) {
|
||||
const mouseOver = function mouseOver() {
|
||||
if (topic.isMouseEventsEnabled()) {
|
||||
topic.handleMouseOver();
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
import { $assert, $defined } from '@wisemapping/core-js';
|
||||
import Point from '@wisemapping/web2d';
|
||||
import ConnectionLine from '../ConnectionLine';
|
||||
import { LineType } from '../ConnectionLine';
|
||||
|
||||
class RelationshipModel {
|
||||
static _nextUuid = 0;
|
||||
@ -47,7 +47,7 @@ class RelationshipModel {
|
||||
this._id = RelationshipModel._nextUUID();
|
||||
this._sourceTargetId = sourceTopicId;
|
||||
this._targetTopicId = targetTopicId;
|
||||
this._lineType = ConnectionLine.SIMPLE_CURVED;
|
||||
this._lineType = LineType.SIMPLE_CURVED;
|
||||
this._srcCtrlPoint = null;
|
||||
this._destCtrlPoint = null;
|
||||
this._endArrow = true;
|
||||
|
@ -15,7 +15,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { $assert } from '@wisemapping/core-js';
|
||||
import ModelCodeName from './ModelCodeName';
|
||||
import Beta2PelaMigrator from './Beta2PelaMigrator';
|
||||
import Pela2TangoMigrator from './Pela2TangoMigrator';
|
||||
|
@ -19,7 +19,7 @@ import { $assert, $defined, createDocument } from '@wisemapping/core-js';
|
||||
import { Point } from '@wisemapping/web2d';
|
||||
import Mindmap from '../model/Mindmap';
|
||||
import { TopicShape } from '../model/INodeModel';
|
||||
import ConnectionLine from '../ConnectionLine';
|
||||
import { LineType } from '../ConnectionLine';
|
||||
import FeatureModelFactory from '../model/FeatureModelFactory';
|
||||
import NodeModel from '../model/NodeModel';
|
||||
import RelationshipModel from '../model/RelationshipModel';
|
||||
@ -207,7 +207,7 @@ class XMLSerializerTango implements XMLMindmapSerializer {
|
||||
|
||||
const lineType = relationship.getLineType();
|
||||
result.setAttribute('lineType', lineType.toString());
|
||||
if (lineType === ConnectionLine.CURVED || lineType === ConnectionLine.SIMPLE_CURVED) {
|
||||
if (lineType === LineType.CURVED || lineType === LineType.SIMPLE_CURVED) {
|
||||
if ($defined(relationship.getSrcCtrlPoint())) {
|
||||
const srcPoint = relationship.getSrcCtrlPoint();
|
||||
result.setAttribute('srcCtrlPoint', `${Math.round(srcPoint.x)},${Math.round(srcPoint.y)}`);
|
||||
|
@ -58,6 +58,7 @@ declare global {
|
||||
var designer: Designer;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const globalAny: any = global;
|
||||
globalAny.jQuery = jquery;
|
||||
// WebComponent registration
|
||||
|
Loading…
Reference in New Issue
Block a user