UNPKG

mind-map

Version:
65 lines (64 loc) 2.44 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MindMapDataProvider = void 0; var config_1 = require("./config"); var customize_format_1 = require("./customize-format"); var constants_1 = require("./constants"); var MindMapDataProvider = (function () { function MindMapDataProvider(jm) { this.jm = jm; } MindMapDataProvider.prototype.init = function () { config_1.logger.debug('data.init'); }; MindMapDataProvider.prototype.reset = function () { config_1.logger.debug('data.reset'); }; MindMapDataProvider.prototype.load = function (mind_data, opts) { var df = null; var mind = null; if (typeof mind_data === 'object') { if (!!mind_data.format) { df = mind_data.format; } else { df = constants_1.MIND_TYPE.NODE_TREE; } } else { df = constants_1.MIND_TYPE.FREE_MIND; } customize_format_1.customizeFormat.setSelectable(opts.selectable); if (df === constants_1.MIND_TYPE.NODE_ARRAY) { mind = customize_format_1.customizeFormat.node_array.getMind(mind_data); } else if (df === constants_1.MIND_TYPE.NODE_TREE) { mind = customize_format_1.customizeFormat.nodeTree.getMind(mind_data); } else if (df === constants_1.MIND_TYPE.FREE_MIND) { mind = customize_format_1.customizeFormat.freemind.getMind(mind_data); } else { config_1.logger.warn('unsupported format'); } return mind; }; MindMapDataProvider.prototype.getData = function (data_format) { var data = null; if (data_format === constants_1.MIND_TYPE.NODE_ARRAY) { data = customize_format_1.customizeFormat.node_array.getData(this.jm.mind); } else if (data_format === constants_1.MIND_TYPE.NODE_TREE) { data = customize_format_1.customizeFormat.nodeTree.getData(this.jm.mind); } else if (data_format === constants_1.MIND_TYPE.FREE_MIND) { data = customize_format_1.customizeFormat.freemind.getData(this.jm.mind); } else { config_1.logger.error('unsupported ' + data_format + ' format'); } return data; }; return MindMapDataProvider; }()); exports.MindMapDataProvider = MindMapDataProvider;