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",
"@typescript-eslint/no-unused-vars": "error",
"no-underscore-dangle": "off",
"no-plusplus": "off",
"no-param-reassign": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"max-len": [
1,
300
@ -52,6 +50,8 @@
"no-console": "off",
// codebase contains many this aliases, fix in the future?
"@typescript-eslint/no-this-alias": "off",
// Remove once migration is completed ...
"@typescript-eslint/no-explicit-any": "warn",
"import/extensions": [
"error",
"ignorePackages",

View File

@ -1,5 +1,4 @@
declare module '*.svg' {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const content: any;
export default content;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -58,7 +58,6 @@ declare global {
var designer: Designer;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const globalAny: any = global;
globalAny.jQuery = jquery;
// WebComponent registration