mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-22 06:37:56 +01:00
Fix lints warnings.
This commit is contained in:
parent
6dbf70ffbb
commit
6c52933f84
@ -21,6 +21,7 @@ import PersistenceManager from './PersistenceManager';
|
||||
import Designer from './Designer';
|
||||
import { DesignerOptions } from './DesignerOptionsBuilder';
|
||||
import WidgetManager from './WidgetManager';
|
||||
import ReadOnlyWidgetManager from './ReadOnlyWidgetManager';
|
||||
|
||||
let designer: Designer;
|
||||
|
||||
@ -35,8 +36,11 @@ export function buildDesigner(options: DesignerOptions): Designer {
|
||||
const persistence = options.persistenceManager;
|
||||
$assert(persistence, 'persistence must be defined');
|
||||
PersistenceManager.init(persistence);
|
||||
const widgetManager = options.widgetManager ? options.widgetManager : new WidgetManager();
|
||||
|
||||
// If not manager was specifed, use the readonly one.
|
||||
const widgetManager = options.widgetManager ? options.widgetManager : new ReadOnlyWidgetManager();
|
||||
WidgetManager.init(widgetManager);
|
||||
|
||||
return designer;
|
||||
}
|
||||
|
||||
|
30
packages/mindplot/src/components/ReadOnlyWidgetManager.ts
Normal file
30
packages/mindplot/src/components/ReadOnlyWidgetManager.ts
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright [2021] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import WidgetManager from './WidgetManager';
|
||||
|
||||
class ReadOnlyWidgetManager extends WidgetManager {
|
||||
showEditorForLink(): void {
|
||||
throw new Error('ReadOnly widget manager does not support edition');
|
||||
}
|
||||
|
||||
showEditorForNote(): void {
|
||||
throw new Error('ReadOnly widget manager does not support edition');
|
||||
}
|
||||
}
|
||||
|
||||
export default ReadOnlyWidgetManager;
|
@ -99,18 +99,17 @@ class ScreenManager {
|
||||
|
||||
private tocuchEvents = ['touchstart', 'touchend', 'touchmove'];
|
||||
|
||||
// the received type was changed from MouseEvent to "any", because we must support touch events
|
||||
getWorkspaceMousePosition(event: any) {
|
||||
let x;
|
||||
let y;
|
||||
getWorkspaceMousePosition(event: MouseEvent | TouchEvent): Point {
|
||||
let x: number;
|
||||
let y: number;
|
||||
|
||||
if (this.mouseEvents.includes(event.type)) {
|
||||
// Retrieve current mouse position.
|
||||
x = event.clientX;
|
||||
y = event.clientY;
|
||||
x = (event as MouseEvent).clientX;
|
||||
y = (event as MouseEvent).clientY;
|
||||
} else if (this.tocuchEvents.includes(event.type)) {
|
||||
x = event.touches[0].clientX;
|
||||
y = event.touches[0].clientY;
|
||||
x = (event as TouchEvent).touches[0].clientX;
|
||||
y = (event as TouchEvent).touches[0].clientY;
|
||||
}
|
||||
|
||||
// if value is zero assert throws error
|
||||
@ -138,11 +137,11 @@ class ScreenManager {
|
||||
return new Point(x, y);
|
||||
}
|
||||
|
||||
getContainer() {
|
||||
getContainer(): JQuery {
|
||||
return this._divContainer;
|
||||
}
|
||||
|
||||
setOffset(x: number, y: number) {
|
||||
setOffset(x: number, y: number): void {
|
||||
this._padding.x = x;
|
||||
this._padding.y = y;
|
||||
}
|
||||
|
@ -6,9 +6,9 @@ import NoteIcon from './NoteIcon';
|
||||
import Topic from './Topic';
|
||||
import { $msg } from './Messages';
|
||||
|
||||
class WidgetManager {
|
||||
abstract class WidgetManager {
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
static _instance: WidgetManager;
|
||||
private static _instance: WidgetManager;
|
||||
|
||||
static init = (instance: WidgetManager) => {
|
||||
this._instance = instance;
|
||||
@ -18,7 +18,7 @@ class WidgetManager {
|
||||
return this._instance;
|
||||
}
|
||||
|
||||
private createTooltip(mindmapElement, title, linkModel: LinkModel, noteModel: NoteModel) {
|
||||
private createTooltip(mindmapElement, title: string, linkModel: LinkModel, noteModel: NoteModel) {
|
||||
const webcomponentShadowRoot = $($('#mindmap-comp')[0].shadowRoot);
|
||||
let tooltip = webcomponentShadowRoot.find('#mindplot-svg-tooltip');
|
||||
if (!tooltip.length) {
|
||||
@ -75,11 +75,11 @@ class WidgetManager {
|
||||
this.createTooltip(linkIcon.getElement().peer, $msg('LINK'), linkModel, undefined);
|
||||
}
|
||||
|
||||
createTooltipForNote(topic: Topic, noteModel: NoteModel, noteIcon: NoteIcon) {
|
||||
createTooltipForNote(topic: Topic, noteModel: NoteModel, noteIcon: NoteIcon): void {
|
||||
this.createTooltip(noteIcon.getElement().peer, $msg('NOTE'), undefined, noteModel);
|
||||
}
|
||||
|
||||
configureEditorForLink(topic: Topic, linkModel: LinkModel, linkIcon: LinkIcon) {
|
||||
configureEditorForLink(topic: Topic, linkModel: LinkModel, linkIcon: LinkIcon): void {
|
||||
const htmlImage = linkIcon.getElement().peer;
|
||||
htmlImage.addEvent('click', (evt) => {
|
||||
this.showEditorForLink(topic, linkModel, linkIcon);
|
||||
@ -87,7 +87,7 @@ class WidgetManager {
|
||||
});
|
||||
}
|
||||
|
||||
configureEditorForNote(topic: Topic, noteModel: NoteModel, noteIcon: NoteIcon) {
|
||||
configureEditorForNote(topic: Topic, noteModel: NoteModel, noteIcon: NoteIcon): void {
|
||||
const htmlImage = noteIcon.getElement().peer;
|
||||
htmlImage.addEvent('click', (evt) => {
|
||||
this.showEditorForNote(topic, noteModel, noteIcon);
|
||||
@ -95,13 +95,9 @@ class WidgetManager {
|
||||
});
|
||||
}
|
||||
|
||||
showEditorForLink(topic: Topic, linkModel: LinkModel, linkIcon: LinkIcon) {
|
||||
console.log('Show link editor not yet implemented');
|
||||
}
|
||||
abstract showEditorForLink(topic: Topic, linkModel: LinkModel, linkIcon: LinkIcon): void;
|
||||
|
||||
showEditorForNote(topic: Topic, noteModel: NoteModel, noteIcon: NoteIcon) {
|
||||
console.log('Show note editor not yet implemented');
|
||||
}
|
||||
abstract showEditorForNote(topic: Topic, noteModel: NoteModel, noteIcon: NoteIcon): void;
|
||||
}
|
||||
|
||||
export default WidgetManager;
|
||||
|
Loading…
Reference in New Issue
Block a user