mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-22 06:37:56 +01:00
Configure typescript
This commit is contained in:
parent
ef3984cfd0
commit
29f3e41fa3
@ -1,5 +1,5 @@
|
||||
import Exporter from "src/components/export/Exporter";
|
||||
import Mindmap from "src/components/model/Mindmap";
|
||||
import Exporter from "./Exporter";
|
||||
import Mindmap from "../model/Mindmap";
|
||||
|
||||
|
||||
class TextExporter implements Exporter {
|
||||
|
@ -2,41 +2,36 @@ import { $assert } from '@wisemapping/core-js';
|
||||
import IconModel from './IconModel';
|
||||
import LinkModel from './LinkModel';
|
||||
import NoteModel from './NoteModel';
|
||||
import FeatureModel from './FeatureModel';
|
||||
|
||||
const FeatureModelFactory = {
|
||||
Icon: {
|
||||
class FeatureModelFactory {
|
||||
|
||||
private static modelById = [{
|
||||
id: IconModel.FEATURE_TYPE,
|
||||
model: IconModel,
|
||||
},
|
||||
|
||||
Link: {
|
||||
}, {
|
||||
id: LinkModel.FEATURE_TYPE,
|
||||
model: LinkModel,
|
||||
},
|
||||
|
||||
/** the note object */
|
||||
Note: {
|
||||
}, {
|
||||
id: NoteModel.FEATURE_TYPE,
|
||||
model: NoteModel,
|
||||
},
|
||||
}] as const;
|
||||
|
||||
createModel(type, attributes) {
|
||||
static createModel(type: string, attributes): FeatureModel {
|
||||
$assert(type, 'type can not be null');
|
||||
$assert(attributes, 'attributes can not be null');
|
||||
|
||||
const { model: Model } = FeatureModelFactory._featuresMetadataById
|
||||
const { model: Model } = FeatureModelFactory.modelById
|
||||
.filter((elem) => elem.id === type)[0];
|
||||
return new Model(attributes);
|
||||
},
|
||||
}
|
||||
/**
|
||||
* @param id the feature metadata id
|
||||
* @return {Boolean} returns true if the given id is contained in the metadata array
|
||||
*/
|
||||
isSupported(id) {
|
||||
return FeatureModelFactory._featuresMetadataById.some((elem) => elem.id === id);
|
||||
},
|
||||
static isSupported(type: string): boolean {
|
||||
return FeatureModelFactory.modelById.some((elem) => elem.id === type);
|
||||
}
|
||||
};
|
||||
|
||||
FeatureModelFactory._featuresMetadataById = [FeatureModelFactory.Icon, FeatureModelFactory.Link, FeatureModelFactory.Note];
|
||||
|
||||
export default FeatureModelFactory;
|
@ -2,7 +2,7 @@ import TxtExporter from '../../src/components/export/TxtExporter';
|
||||
import Mindmap from '../../src/components/model/Mindmap';
|
||||
|
||||
test('adds 1 + 2 to equal 3', () => {
|
||||
const m = new Mindmap();
|
||||
const m = new Mindmap(1);
|
||||
|
||||
const exporter = new TxtExporter();
|
||||
console.log(exporter.export(m));
|
||||
|
@ -4,6 +4,7 @@
|
||||
"sourceMap": true,
|
||||
"noImplicitAny": false,
|
||||
"module": "es6",
|
||||
"moduleResolution": "Node",
|
||||
"target": "es6",
|
||||
"allowJs": true,
|
||||
"esModuleInterop": true
|
||||
|
Loading…
Reference in New Issue
Block a user