mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-11 01:43:23 +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 Designer from './Designer';
|
||||||
import { DesignerOptions } from './DesignerOptionsBuilder';
|
import { DesignerOptions } from './DesignerOptionsBuilder';
|
||||||
import WidgetManager from './WidgetManager';
|
import WidgetManager from './WidgetManager';
|
||||||
|
import ReadOnlyWidgetManager from './ReadOnlyWidgetManager';
|
||||||
|
|
||||||
let designer: Designer;
|
let designer: Designer;
|
||||||
|
|
||||||
@ -35,8 +36,11 @@ export function buildDesigner(options: DesignerOptions): Designer {
|
|||||||
const persistence = options.persistenceManager;
|
const persistence = options.persistenceManager;
|
||||||
$assert(persistence, 'persistence must be defined');
|
$assert(persistence, 'persistence must be defined');
|
||||||
PersistenceManager.init(persistence);
|
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);
|
WidgetManager.init(widgetManager);
|
||||||
|
|
||||||
return designer;
|
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'];
|
private tocuchEvents = ['touchstart', 'touchend', 'touchmove'];
|
||||||
|
|
||||||
// the received type was changed from MouseEvent to "any", because we must support touch events
|
getWorkspaceMousePosition(event: MouseEvent | TouchEvent): Point {
|
||||||
getWorkspaceMousePosition(event: any) {
|
let x: number;
|
||||||
let x;
|
let y: number;
|
||||||
let y;
|
|
||||||
|
|
||||||
if (this.mouseEvents.includes(event.type)) {
|
if (this.mouseEvents.includes(event.type)) {
|
||||||
// Retrieve current mouse position.
|
// Retrieve current mouse position.
|
||||||
x = event.clientX;
|
x = (event as MouseEvent).clientX;
|
||||||
y = event.clientY;
|
y = (event as MouseEvent).clientY;
|
||||||
} else if (this.tocuchEvents.includes(event.type)) {
|
} else if (this.tocuchEvents.includes(event.type)) {
|
||||||
x = event.touches[0].clientX;
|
x = (event as TouchEvent).touches[0].clientX;
|
||||||
y = event.touches[0].clientY;
|
y = (event as TouchEvent).touches[0].clientY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if value is zero assert throws error
|
// if value is zero assert throws error
|
||||||
@ -138,11 +137,11 @@ class ScreenManager {
|
|||||||
return new Point(x, y);
|
return new Point(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
getContainer() {
|
getContainer(): JQuery {
|
||||||
return this._divContainer;
|
return this._divContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
setOffset(x: number, y: number) {
|
setOffset(x: number, y: number): void {
|
||||||
this._padding.x = x;
|
this._padding.x = x;
|
||||||
this._padding.y = y;
|
this._padding.y = y;
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,9 @@ import NoteIcon from './NoteIcon';
|
|||||||
import Topic from './Topic';
|
import Topic from './Topic';
|
||||||
import { $msg } from './Messages';
|
import { $msg } from './Messages';
|
||||||
|
|
||||||
class WidgetManager {
|
abstract class WidgetManager {
|
||||||
// eslint-disable-next-line no-use-before-define
|
// eslint-disable-next-line no-use-before-define
|
||||||
static _instance: WidgetManager;
|
private static _instance: WidgetManager;
|
||||||
|
|
||||||
static init = (instance: WidgetManager) => {
|
static init = (instance: WidgetManager) => {
|
||||||
this._instance = instance;
|
this._instance = instance;
|
||||||
@ -18,7 +18,7 @@ class WidgetManager {
|
|||||||
return this._instance;
|
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);
|
const webcomponentShadowRoot = $($('#mindmap-comp')[0].shadowRoot);
|
||||||
let tooltip = webcomponentShadowRoot.find('#mindplot-svg-tooltip');
|
let tooltip = webcomponentShadowRoot.find('#mindplot-svg-tooltip');
|
||||||
if (!tooltip.length) {
|
if (!tooltip.length) {
|
||||||
@ -75,11 +75,11 @@ class WidgetManager {
|
|||||||
this.createTooltip(linkIcon.getElement().peer, $msg('LINK'), linkModel, undefined);
|
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);
|
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;
|
const htmlImage = linkIcon.getElement().peer;
|
||||||
htmlImage.addEvent('click', (evt) => {
|
htmlImage.addEvent('click', (evt) => {
|
||||||
this.showEditorForLink(topic, linkModel, linkIcon);
|
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;
|
const htmlImage = noteIcon.getElement().peer;
|
||||||
htmlImage.addEvent('click', (evt) => {
|
htmlImage.addEvent('click', (evt) => {
|
||||||
this.showEditorForNote(topic, noteModel, noteIcon);
|
this.showEditorForNote(topic, noteModel, noteIcon);
|
||||||
@ -95,13 +95,9 @@ class WidgetManager {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
showEditorForLink(topic: Topic, linkModel: LinkModel, linkIcon: LinkIcon) {
|
abstract showEditorForLink(topic: Topic, linkModel: LinkModel, linkIcon: LinkIcon): void;
|
||||||
console.log('Show link editor not yet implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
showEditorForNote(topic: Topic, noteModel: NoteModel, noteIcon: NoteIcon) {
|
abstract showEditorForNote(topic: Topic, noteModel: NoteModel, noteIcon: NoteIcon): void;
|
||||||
console.log('Show note editor not yet implemented');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default WidgetManager;
|
export default WidgetManager;
|
||||||
|
Loading…
Reference in New Issue
Block a user