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