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