Remoeve icon.

This commit is contained in:
Paulo Gustavo Veiga 2022-11-24 15:35:39 -08:00
parent bd9b73048a
commit bd25cec139
19 changed files with 78 additions and 96 deletions

View File

@ -39,11 +39,9 @@
} }
], ],
"object-curly-newline": "off", "object-curly-newline": "off",
"@typescript-eslint/no-unused-vars": "error",
"no-underscore-dangle": "off", "no-underscore-dangle": "off",
"no-plusplus": "off", "no-plusplus": "off",
"no-param-reassign": "off", "no-param-reassign": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"max-len": [ "max-len": [
1, 1,
300 300
@ -52,6 +50,8 @@
"no-console": "off", "no-console": "off",
// codebase contains many this aliases, fix in the future? // codebase contains many this aliases, fix in the future?
"@typescript-eslint/no-this-alias": "off", "@typescript-eslint/no-this-alias": "off",
// Remove once migration is completed ...
"@typescript-eslint/no-explicit-any": "warn",
"import/extensions": [ "import/extensions": [
"error", "error",
"ignorePackages", "ignorePackages",

View File

@ -1,5 +1,4 @@
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;
} }

View File

@ -21,7 +21,6 @@ import { $defined } from '@wisemapping/core-js';
import Shape from './util/Shape'; import Shape from './util/Shape';
import ActionDispatcher from './ActionDispatcher'; import ActionDispatcher from './ActionDispatcher';
import Workspace from './Workspace'; import Workspace from './Workspace';
import PositionType from './PositionType';
class ControlPoint { class ControlPoint {
private control1: Elipse; private control1: Elipse;
@ -38,11 +37,11 @@ class ControlPoint {
private _workspace: Workspace; private _workspace: Workspace;
private _endPoint: PositionType[]; private _endPoint: any[];
private _orignalCtrlPoint: PositionType[]; private _orignalCtrlPoint: any;
private _controls: PositionType[]; private _controls: any;
private _mouseMoveFunction: (e: Event) => void; private _mouseMoveFunction: (e: Event) => void;
@ -74,24 +73,25 @@ class ControlPoint {
]; ];
this._isBinded = false; this._isBinded = false;
this._controlPointsController[0].addEvent('mousedown', (event: MouseEvent) => { const me = this;
this._mouseDown(event, ControlPoint.FROM); this._controlPointsController[0].addEvent('mousedown', (event) => {
me._mouseDown(event, ControlPoint.FROM, me);
}); });
this._controlPointsController[0].addEvent('click', (event: MouseEvent) => { this._controlPointsController[0].addEvent('click', (event) => {
this._mouseClick(event); me._mouseClick(event);
}); });
this._controlPointsController[0].addEvent('dblclick', (event: MouseEvent) => { this._controlPointsController[0].addEvent('dblclick', (event) => {
this._mouseClick(event); me._mouseClick(event);
}); });
this._controlPointsController[1].addEvent('mousedown', (event: MouseEvent) => { this._controlPointsController[1].addEvent('mousedown', (event) => {
this._mouseDown(event, ControlPoint.TO); me._mouseDown(event, ControlPoint.TO, me);
}); });
this._controlPointsController[1].addEvent('click', (event: MouseEvent) => { this._controlPointsController[1].addEvent('click', (event) => {
this._mouseClick(event); me._mouseClick(event);
}); });
this._controlPointsController[1].addEvent('dblclick', (event: MouseEvent) => { this._controlPointsController[1].addEvent('dblclick', (event) => {
this._mouseClick(event); me._mouseClick(event);
}); });
} }
@ -103,11 +103,10 @@ class ControlPoint {
this._createControlPoint(); this._createControlPoint();
this._endPoint = []; this._endPoint = [];
this._orignalCtrlPoint = []; this._orignalCtrlPoint = [];
this._orignalCtrlPoint[0] = { ...this._controls[0] };
[this._orignalCtrlPoint[0], this._orignalCtrlPoint[1]] = this._controls; this._orignalCtrlPoint[1] = { ...this._controls[1] };
this._endPoint[0] = { ...this._line.getLine().getFrom() };
this._endPoint[0] = this._line.getLine().getFrom() as PositionType; this._endPoint[1] = { ...this._line.getLine().getTo() };
this._endPoint[1] = this._line.getLine().getTo() as PositionType;
} }
setControlPointTestId(ctrlPoint1, ctrlPoint2) { setControlPointTestId(ctrlPoint1, ctrlPoint2) {
@ -116,9 +115,7 @@ class ControlPoint {
} }
redraw() { redraw() {
if (this._line) { if ($defined(this._line)) this._createControlPoint();
this._createControlPoint();
}
} }
private _createControlPoint() { private _createControlPoint() {
@ -128,20 +125,17 @@ class ControlPoint {
this._controls[ControlPoint.FROM].x + pos.x, this._controls[ControlPoint.FROM].x + pos.x,
this._controls[ControlPoint.FROM].y + pos.y - 3, this._controls[ControlPoint.FROM].y + pos.y - 3,
); );
this._controlLines[0].setFrom(pos.x, pos.y); this._controlLines[0].setFrom(pos.x, pos.y);
this._controlLines[0].setTo( this._controlLines[0].setTo(
this._controls[ControlPoint.FROM].x + pos.x + 3, this._controls[ControlPoint.FROM].x + pos.x + 3,
this._controls[ControlPoint.FROM].y + pos.y, this._controls[ControlPoint.FROM].y + pos.y,
); );
pos = this._line.getLine().getTo(); pos = this._line.getLine().getTo();
this._controlLines[1].setFrom(pos.x, pos.y); this._controlLines[1].setFrom(pos.x, pos.y);
this._controlLines[1].setTo( this._controlLines[1].setTo(
this._controls[ControlPoint.TO].x + pos.x + 3, this._controls[ControlPoint.TO].x + pos.x + 3,
this._controls[ControlPoint.TO].y + pos.y, this._controls[ControlPoint.TO].y + pos.y,
); );
this._controlPointsController[1].setPosition( this._controlPointsController[1].setPosition(
this._controls[ControlPoint.TO].x + pos.x, this._controls[ControlPoint.TO].x + pos.x,
this._controls[ControlPoint.TO].y + pos.y - 3, this._controls[ControlPoint.TO].y + pos.y - 3,
@ -152,16 +146,16 @@ class ControlPoint {
// Overwrite default behaviour ... // Overwrite default behaviour ...
} }
private _mouseDown(event: MouseEvent, point: number) { private _mouseDown(event: Event, point, me) {
if (!this._isBinded) { if (!this._isBinded) {
this._isBinded = true; this._isBinded = true;
this._mouseMoveFunction = (e: MouseEvent) => { this._mouseMoveFunction = (e) => {
this._mouseMoveEvent(e, point); me._mouseMoveEvent(e, point, me);
}; };
this._workspace.getScreenManager().addEvent('mousemove', this._mouseMoveFunction); this._workspace.getScreenManager().addEvent('mousemove', this._mouseMoveFunction);
this._mouseUpFunction = (e: MouseEvent) => { this._mouseUpFunction = (e: Event) => {
this._mouseUp(e, point); me._mouseUp(e, point, me);
}; };
this._workspace.getScreenManager().addEvent('mouseup', this._mouseUpFunction); this._workspace.getScreenManager().addEvent('mouseup', this._mouseUpFunction);
} }
@ -170,7 +164,7 @@ class ControlPoint {
return false; return false;
} }
private _mouseMoveEvent(event: MouseEvent, point: number) { private _mouseMoveEvent(event: MouseEvent, point: Point) {
const screen = this._workspace.getScreenManager(); const screen = this._workspace.getScreenManager();
const pos = screen.getWorkspaceMousePosition(event); const pos = screen.getWorkspaceMousePosition(event);
@ -202,7 +196,7 @@ class ControlPoint {
this._isBinded = false; this._isBinded = false;
} }
private _mouseClick(event: MouseEvent) { _mouseClick(event: MouseEvent) {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
return false; return false;
@ -229,29 +223,29 @@ class ControlPoint {
workspace.append(this._controlLines[1]); workspace.append(this._controlLines[1]);
} }
removeFromWorkspace(workspace: Workspace): void { removeFromWorkspace(workspace: Workspace) {
this._workspace!; this._workspace = null;
workspace.removeChild(this._controlPointsController[0]); workspace.removeChild(this._controlPointsController[0]);
workspace.removeChild(this._controlPointsController[1]); workspace.removeChild(this._controlPointsController[1]);
workspace.removeChild(this._controlLines[0]); workspace.removeChild(this._controlLines[0]);
workspace.removeChild(this._controlLines[1]); workspace.removeChild(this._controlLines[1]);
} }
getControlPoint(index: number): PositionType { getControlPoint(index: number): ControlPoint {
return this._controls[index]; return this._controls[index];
} }
getOriginalEndPoint(index: number): PositionType { getOriginalEndPoint(index: number) {
return this._endPoint[index]; return this._endPoint[index];
} }
getOriginalCtrlPoint(index: number): PositionType { getOriginalCtrlPoint(index: number): ControlPoint {
return this._orignalCtrlPoint[index]; return this._orignalCtrlPoint[index];
} }
private static FROM = 0; static FROM = 0;
private static TO = 1; static TO = 1;
} }
export default ControlPoint; export default ControlPoint;

View File

@ -81,7 +81,7 @@ class EmojiCharIcon implements Icon {
return this.group.getPosition(); return this.group.getPosition();
} }
addEvent(type: string, fnc: () => void): void { addEvent(type: string, fnc: any): void {
this.element.addEvent(type, fnc); this.element.addEvent(type, fnc);
} }

View File

@ -31,7 +31,7 @@ ORDER_BY_TYPE.set('link', 2);
class IconGroup { class IconGroup {
private _icons: ImageIcon[]; private _icons: ImageIcon[];
private _group: Group; private _group: any;
private _removeTip: IconGroupRemoveTip; private _removeTip: IconGroupRemoveTip;

View File

@ -182,8 +182,8 @@ class Workspace {
const workspace = this._workspace; const workspace = this._workspace;
const divContainer = this._screenManager.getContainer(); const divContainer = this._screenManager.getContainer();
const containerWidth = divContainer.width()!; const containerWidth = divContainer.width();
const containerHeight = divContainer.height()!; const containerHeight = divContainer.height();
const newVisibleAreaSize = { width: containerWidth, height: containerHeight }; const newVisibleAreaSize = { width: containerWidth, height: containerHeight };
// - svg must fit container size // - svg must fit container size

View File

@ -28,7 +28,7 @@ class AddFeatureToTopicCommand extends Command {
private _attributes: object; private _attributes: object;
private _featureModel: FeatureModel | null; private _featureModel: FeatureModel;
/* /*
* @classdesc This command class handles do/undo of adding features to topics, e.g. an * @classdesc This command class handles do/undo of adding features to topics, e.g. an
@ -65,7 +65,7 @@ class AddFeatureToTopicCommand extends Command {
undoExecute(commandContext: CommandContext) { undoExecute(commandContext: CommandContext) {
const topic = commandContext.findTopics([this._topicId])[0]; const topic = commandContext.findTopics([this._topicId])[0];
topic.removeFeature(this._featureModel!); topic.removeFeature(this._featureModel);
} }
} }

View File

@ -70,7 +70,7 @@ class AddTopicCommand extends Command {
undoExecute(commandContext: CommandContext) { undoExecute(commandContext: CommandContext) {
// Delete disconnected the nodes. Create a copy of the topics ... // Delete disconnected the nodes. Create a copy of the topics ...
const clonedModel: NodeModel[] = []; const clonedModel = [];
this._models.forEach((model) => { this._models.forEach((model) => {
clonedModel.push(model.clone()); clonedModel.push(model.clone());
}); });

View File

@ -34,7 +34,7 @@ class MoveControlPointCommand extends Command {
private _wasCustom: boolean; private _wasCustom: boolean;
private _endPoint: PositionType; private _endPoint: any;
private _point: number; private _point: number;
@ -52,7 +52,7 @@ class MoveControlPointCommand extends Command {
this._ctrlPointControler = ctrlPointController; this._ctrlPointControler = ctrlPointController;
this._line = ctrlPointController._line; this._line = ctrlPointController._line;
this._controlPoint = { ...this._ctrlPointControler.getControlPoint(point) }; this._controlPoint = { ...this._ctrlPointControler.getControlPoint(point) };
this._oldControlPoint = this._ctrlPointControler.getOriginalCtrlPoint(point); this._oldControlPoint = { ...this._ctrlPointControler.getOriginalCtrlPoint(point) };
this._originalEndPoint = this._ctrlPointControler.getOriginalEndPoint(point); this._originalEndPoint = this._ctrlPointControler.getOriginalEndPoint(point);
switch (point) { switch (point) {
case 0: case 0:

View File

@ -66,30 +66,27 @@ class SVGExporter extends Exporter {
private _calcualteDimensions(): { minX: number; maxX: number; minY: number; maxY: number } { private _calcualteDimensions(): { minX: number; maxX: number; minY: number; maxY: number } {
// Collect all group elements ... // Collect all group elements ...
const rectElems = Array.from(this.svgElement.querySelectorAll('g>rect')); const rectElems = Array.from(this.svgElement.querySelectorAll('g>rect'));
let result: SizeType = { width: 0, height: 0 };
const translates: SizeType[] = rectElems.map((rect: Element) => { const translates: SizeType[] = rectElems.map((rect: Element) => {
const g = rect.parentElement; const g = rect.parentElement;
const transformStr = g?.getAttribute('transform'); const transformStr = g.getAttribute('transform');
if (transformStr) {
// Looking to parse translate(220.00000,279.00000) scale(1.00000,1.00000) // Looking to parse translate(220.00000,279.00000) scale(1.00000,1.00000)
const match = transformStr.match(SVGExporter.regexpTranslate); const match = transformStr.match(SVGExporter.regexpTranslate);
let result: SizeType = { width: 0, height: 0 };
if (match !== null) { if (match !== null) {
result = { width: Number.parseFloat(match[1]), height: Number.parseFloat(match[2]) }; result = { width: Number.parseFloat(match[1]), height: Number.parseFloat(match[2]) };
// Add rect size ... // Add rect size ...
const width = rect.getAttribute('width'); if (result.width > 0) {
if (result.width > 0 && width) { const rectWidth = Number.parseFloat(rect.getAttribute('width'));
const rectWidth = Number.parseFloat(width);
result.width += rectWidth; result.width += rectWidth;
} }
const height = rect.getAttribute('height'); if (result.height > 0) {
if (result.height > 0 && height) { const rectHeight = Number.parseFloat(rect.getAttribute('height'));
const rectHeight = Number.parseFloat(height);
result.height += rectHeight; result.height += rectHeight;
} }
} }
}
return result; return result;
}); });

View File

@ -169,7 +169,7 @@ export default class FreemindImporter extends Importer {
} }
// Check for style... // Check for style...
const fontStyle = this.generateFontStyle(freeNode); const fontStyle = this.generateFontStyle(freeNode, null);
if (fontStyle && fontStyle !== ';;;;') wiseTopic.setFontStyle(fontStyle); if (fontStyle && fontStyle !== ';;;;') wiseTopic.setFontStyle(fontStyle);
// Is there any link... // Is there any link...
@ -393,7 +393,7 @@ export default class FreemindImporter extends Importer {
return result; return result;
} }
private generateFontStyle(node: FreemindNode, font?: FreemindFont): string { private generateFontStyle(node: FreemindNode, font: FreemindFont | undefined): string {
const fontStyle: Array<string> = []; const fontStyle: Array<string> = [];
// Font family // Font family
@ -485,6 +485,6 @@ export default class FreemindImporter extends Importer {
private html2Text(content: string): string { private html2Text(content: string): string {
const temporalDivElement = document.createElement('div'); const temporalDivElement = document.createElement('div');
temporalDivElement.innerHTML = content; temporalDivElement.innerHTML = content;
return temporalDivElement.textContent?.trim() || temporalDivElement.innerText.trim() || ''; return temporalDivElement.textContent.trim() || temporalDivElement.innerText.trim() || '';
} }
} }

View File

@ -28,12 +28,7 @@ abstract class ChildrenSorterStrategy {
abstract detach(treeSet: RootedTreeSet, node: Node): void; abstract detach(treeSet: RootedTreeSet, node: Node): void;
abstract predict( abstract predict(treeSet: RootedTreeSet, parent, node: Node | null, position: PositionType);
treeSet: RootedTreeSet,
parent: Node,
node: Node | null,
position: PositionType | null,
);
abstract verify(treeSet: RootedTreeSet, node: Node); abstract verify(treeSet: RootedTreeSet, node: Node);

View File

@ -24,7 +24,7 @@ class Node {
private _id: number; private _id: number;
// eslint-disable-next-line no-use-before-define // eslint-disable-next-line no-use-before-define
_parent: Node | null; _parent: Node;
private _sorter: ChildrenSorterStrategy; private _sorter: ChildrenSorterStrategy;

View File

@ -89,7 +89,7 @@ class RootedTreeSet {
* @throws will throw an error if nodeId is null or undefined * @throws will throw an error if nodeId is null or undefined
* @throws will throw an error if node is not connected * @throws will throw an error if node is not connected
*/ */
disconnect(nodeId: number): void { disconnect(nodeId: number) {
$assert($defined(nodeId), 'nodeId can not be null'); $assert($defined(nodeId), 'nodeId can not be null');
const node = this.find(nodeId); const node = this.find(nodeId);
$assert(node._parent, 'Node is not connected'); $assert(node._parent, 'Node is not connected');
@ -106,11 +106,11 @@ class RootedTreeSet {
* @throws will throw an error if node cannot be found * @throws will throw an error if node cannot be found
* @return node * @return node
*/ */
find(id: number, validate = true): Node | null { find(id: number, validate = true): Node {
$assert($defined(id), 'id can not be null'); $assert($defined(id), 'id can not be null');
const graphs = this._rootNodes; const graphs = this._rootNodes;
let result: Node | null = null; let result = null;
for (let i = 0; i < graphs.length; i++) { for (let i = 0; i < graphs.length; i++) {
const node = graphs[i]; const node = graphs[i];
result = this._find(id, node); result = this._find(id, node);
@ -126,12 +126,12 @@ class RootedTreeSet {
return result; return result;
} }
private _find(id: number, parent: Node): Node | null { private _find(id: number, parent: Node): Node {
if (parent.getId() === id) { if (parent.getId() === id) {
return parent; return parent;
} }
let result: Node | null = null; let result = null;
const children = parent._children; const children = parent._children;
for (let i = 0; i < children.length; i++) { for (let i = 0; i < children.length; i++) {
const child = children[i]; const child = children[i];
@ -192,10 +192,10 @@ class RootedTreeSet {
*/ */
getSiblings(node: Node): Node[] { getSiblings(node: Node): Node[] {
$assert(node, 'node cannot be null'); $assert(node, 'node cannot be null');
if (!node._parent) { if (!$defined(node._parent)) {
return []; return [];
} }
const siblings = node._parent?._children.filter((child) => child !== node); const siblings = node._parent._children.filter((child) => child !== node);
return siblings; return siblings;
} }
@ -241,7 +241,7 @@ class RootedTreeSet {
* @throws will throw an error if node is null or undefined * @throws will throw an error if node is null or undefined
* @return parent * @return parent
*/ */
getParent(node: Node): Node | null { getParent(node: Node): Node {
$assert(node, 'node cannot be null'); $assert(node, 'node cannot be null');
return node._parent; return node._parent;
} }

View File

@ -67,7 +67,7 @@ abstract class IMindmap {
$assert(child, 'Child can not be null.'); $assert(child, 'Child can not be null.');
$assert(parent, 'Child model seems to be already connected'); $assert(parent, 'Child model seems to be already connected');
parent?.removeChild(child); parent.removeChild(child);
this.addBranch(child); this.addBranch(child);
} }

View File

@ -46,7 +46,7 @@ abstract class INodeModel {
abstract getFeatures(): FeatureModel[]; abstract getFeatures(): FeatureModel[];
setId(id?: number): void { setId(id?: number): void {
if (id === null || id === undefined) { if (!$defined(id)) {
const newId = INodeModel._nextUUID(); const newId = INodeModel._nextUUID();
this.putProperty('id', newId); this.putProperty('id', newId);
} else { } else {

View File

@ -121,7 +121,6 @@
{ {
"id": "object", "id": "object",
"icons": [ "icons": [
"object_clip",
"object_music" "object_music"
] ]
}, },

View File

@ -15,6 +15,7 @@
* 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';
@ -88,9 +89,7 @@ class XMLSerializerFactory {
result = new migrator(result); result = new migrator(result);
} }
} }
if (!result) { $assert(result, `Cound not find serialized for ${version}`);
throw new Error(`Cound not find serialized for ${version}`);
}
return result; return result;
} }
} }

View File

@ -58,7 +58,6 @@ 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