mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-22 14:47:56 +01:00
WIp
This commit is contained in:
parent
1f977e1ce2
commit
bccd26aad6
@ -73,6 +73,7 @@ export default class Freemap {
|
|||||||
freemap.setVesion(version);
|
freemap.setVesion(version);
|
||||||
|
|
||||||
const mainTopicElement = rootElem.firstElementChild;
|
const mainTopicElement = rootElem.firstElementChild;
|
||||||
|
if (mainTopicElement) {
|
||||||
const mainTopic: Node = new Node().loadFromElement(mainTopicElement);
|
const mainTopic: Node = new Node().loadFromElement(mainTopicElement);
|
||||||
freemap.setNode(mainTopic);
|
freemap.setNode(mainTopic);
|
||||||
|
|
||||||
@ -83,14 +84,16 @@ export default class Freemap {
|
|||||||
|
|
||||||
childsNodes.forEach((child: Element) => {
|
childsNodes.forEach((child: Element) => {
|
||||||
const node = this.domToNode(child);
|
const node = this.domToNode(child);
|
||||||
|
if (node) {
|
||||||
mainTopic.setArrowlinkOrCloudOrEdge(node);
|
mainTopic.setArrowlinkOrCloudOrEdge(node);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
return freemap;
|
return freemap;
|
||||||
}
|
}
|
||||||
|
|
||||||
private filterNodes(child: ChildNode): Element {
|
private filterNodes(child: ChildNode): Element | null {
|
||||||
let element: Element;
|
let element: Element | null = null;
|
||||||
if (child.nodeType === 1) {
|
if (child.nodeType === 1) {
|
||||||
if (
|
if (
|
||||||
(child as Element).tagName === 'node' ||
|
(child as Element).tagName === 'node' ||
|
||||||
@ -108,8 +111,8 @@ export default class Freemap {
|
|||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
private domToNode(nodeElem: Element): Choise {
|
private domToNode(nodeElem: Element): Choise | null {
|
||||||
let node: Choise;
|
let node: Choise | null = null;
|
||||||
|
|
||||||
if (nodeElem.tagName === 'node') {
|
if (nodeElem.tagName === 'node') {
|
||||||
node = new Node().loadFromElement(nodeElem);
|
node = new Node().loadFromElement(nodeElem);
|
||||||
@ -122,84 +125,105 @@ export default class Freemap {
|
|||||||
|
|
||||||
childsNodes.forEach((child) => {
|
childsNodes.forEach((child) => {
|
||||||
const childNode = this.domToNode(child);
|
const childNode = this.domToNode(child);
|
||||||
if (node instanceof Node) node.setArrowlinkOrCloudOrEdge(childNode);
|
if (node instanceof Node && childNode) {
|
||||||
|
node.setArrowlinkOrCloudOrEdge(childNode);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nodeElem.tagName === 'font') {
|
if (nodeElem.tagName === 'font') {
|
||||||
node = new Font();
|
node = new Font();
|
||||||
if (nodeElem.getAttribute('NAME')) {
|
|
||||||
node.setName(nodeElem.getAttribute('NAME'));
|
const nameAttr = nodeElem.getAttribute('NAME');
|
||||||
|
if (nameAttr) {
|
||||||
|
node.setName(nameAttr);
|
||||||
}
|
}
|
||||||
if (nodeElem.getAttribute('BOLD')) {
|
|
||||||
node.setBold(nodeElem.getAttribute('BOLD'));
|
const boldAttr = nodeElem.getAttribute('BOLD');
|
||||||
|
if (boldAttr) {
|
||||||
|
node.setBold(boldAttr);
|
||||||
}
|
}
|
||||||
if (nodeElem.getAttribute('ITALIC')) {
|
const italicAttr = nodeElem.getAttribute('ITALIC');
|
||||||
node.setItalic(nodeElem.getAttribute('ITALIC'));
|
if (italicAttr) {
|
||||||
|
node.setItalic(italicAttr);
|
||||||
}
|
}
|
||||||
if (nodeElem.getAttribute('SIZE')) {
|
const sizeAttr = nodeElem.getAttribute('SIZE');
|
||||||
node.setSize(nodeElem.getAttribute('SIZE'));
|
if (sizeAttr) {
|
||||||
|
node.setSize(sizeAttr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nodeElem.tagName === 'edge') {
|
if (nodeElem.tagName === 'edge') {
|
||||||
node = new Edge();
|
node = new Edge();
|
||||||
if (nodeElem.getAttribute('COLOR')) {
|
const colorAttr = nodeElem.getAttribute('COLOR');
|
||||||
node.setColor(nodeElem.getAttribute('COLOR'));
|
if (colorAttr) {
|
||||||
|
node.setColor(colorAttr);
|
||||||
}
|
}
|
||||||
if (nodeElem.getAttribute('STYLE')) {
|
const styleAttr = nodeElem.getAttribute('STYLE');
|
||||||
node.setStyle(nodeElem.getAttribute('STYLE'));
|
if (styleAttr) {
|
||||||
|
node.setStyle(styleAttr);
|
||||||
}
|
}
|
||||||
if (nodeElem.getAttribute('WIDTH')) {
|
const widthAttr = nodeElem.getAttribute('WIDTH');
|
||||||
node.setWidth(nodeElem.getAttribute('WIDTH'));
|
if (widthAttr) {
|
||||||
|
node.setWidth(widthAttr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nodeElem.tagName === 'arrowlink') {
|
if (nodeElem.tagName === 'arrowlink') {
|
||||||
node = new Arrowlink();
|
node = new Arrowlink();
|
||||||
if (nodeElem.getAttribute('COLOR')) {
|
const colorAttr = nodeElem.getAttribute('COLOR');
|
||||||
node.setColor(nodeElem.getAttribute('COLOR'));
|
if (colorAttr) {
|
||||||
|
node.setColor(colorAttr);
|
||||||
}
|
}
|
||||||
if (nodeElem.getAttribute('DESTINATION')) {
|
const destAttr = nodeElem.getAttribute('DESTINATION');
|
||||||
node.setDestination(nodeElem.getAttribute('DESTINATION'));
|
if (destAttr) {
|
||||||
|
node.setDestination(destAttr);
|
||||||
}
|
}
|
||||||
if (nodeElem.getAttribute('ENDARROW')) {
|
const endAttr = nodeElem.getAttribute('ENDARROW');
|
||||||
node.setEndarrow(nodeElem.getAttribute('ENDARROW'));
|
if (endAttr) {
|
||||||
|
node.setEndarrow(endAttr);
|
||||||
}
|
}
|
||||||
if (nodeElem.getAttribute('ENDINCLINATION')) {
|
const endIncAttr = nodeElem.getAttribute('ENDINCLINATION');
|
||||||
node.setEndinclination(nodeElem.getAttribute('ENDINCLINATION'));
|
if (endIncAttr) {
|
||||||
|
node.setEndinclination(endIncAttr);
|
||||||
}
|
}
|
||||||
if (nodeElem.getAttribute('ID')) {
|
const idAttr = nodeElem.getAttribute('ID');
|
||||||
node.setId(nodeElem.getAttribute('ID'));
|
if (idAttr) {
|
||||||
|
node.setId(idAttr);
|
||||||
}
|
}
|
||||||
if (nodeElem.getAttribute('STARTARROW')) {
|
const starAttr = nodeElem.getAttribute('STARTARROW');
|
||||||
node.setStartarrow(nodeElem.getAttribute('STARTARROW'));
|
if (starAttr) {
|
||||||
|
node.setStartarrow(starAttr);
|
||||||
}
|
}
|
||||||
if (nodeElem.getAttribute('STARTINCLINATION')) {
|
const startIncAttr = nodeElem.getAttribute('STARTINCLINATION');
|
||||||
node.setStartinclination(nodeElem.getAttribute('STARTINCLINATION'));
|
if (startIncAttr) {
|
||||||
|
node.setStartinclination(startIncAttr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nodeElem.tagName === 'cloud') {
|
if (nodeElem.tagName === 'cloud') {
|
||||||
node = new Cloud();
|
node = new Cloud();
|
||||||
if (nodeElem.getAttribute('COLOR')) {
|
const colorAttr = nodeElem.getAttribute('COLOR');
|
||||||
node.setColor(nodeElem.getAttribute('COLOR'));
|
if (colorAttr) {
|
||||||
|
node.setColor(colorAttr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nodeElem.tagName === 'icon') {
|
if (nodeElem.tagName === 'icon') {
|
||||||
node = new Icon();
|
node = new Icon();
|
||||||
if (nodeElem.getAttribute('BUILTIN')) {
|
const bultInAttr = nodeElem.getAttribute('BUILTIN');
|
||||||
node.setBuiltin(nodeElem.getAttribute('BUILTIN'));
|
if (bultInAttr) {
|
||||||
|
node.setBuiltin(bultInAttr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nodeElem.tagName === 'richcontent') {
|
if (nodeElem.tagName === 'richcontent') {
|
||||||
node = new Richcontent();
|
node = new Richcontent();
|
||||||
|
|
||||||
if (nodeElem.getAttribute('TYPE')) {
|
const typeAttr = nodeElem.getAttribute('TYPE');
|
||||||
node.setType(nodeElem.getAttribute('TYPE'));
|
if (typeAttr) {
|
||||||
|
node.setType(typeAttr);
|
||||||
}
|
}
|
||||||
if (nodeElem.firstChild && nodeElem.getElementsByTagName('html')) {
|
if (nodeElem.firstChild && nodeElem.getElementsByTagName('html')) {
|
||||||
const content = nodeElem.getElementsByTagName('html');
|
const content = nodeElem.getElementsByTagName('html');
|
||||||
|
@ -69,7 +69,7 @@ class Node {
|
|||||||
return this.FOLDED;
|
return this.FOLDED;
|
||||||
}
|
}
|
||||||
|
|
||||||
getId(): string {
|
getId(): string | null {
|
||||||
return this.ID;
|
return this.ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,7 +342,7 @@ export default class FreemindImporter extends Importer {
|
|||||||
const id = node.getId();
|
const id = node.getId();
|
||||||
let idFreeToIdWise: number;
|
let idFreeToIdWise: number;
|
||||||
|
|
||||||
if (id) {
|
if (id !== null && id !== undefined) {
|
||||||
if (id === '_') {
|
if (id === '_') {
|
||||||
this.idDefault++;
|
this.idDefault++;
|
||||||
idFreeToIdWise = this.idDefault;
|
idFreeToIdWise = this.idDefault;
|
||||||
|
@ -28,7 +28,7 @@ class BalancedSorter extends AbstractBasicSorter {
|
|||||||
|
|
||||||
private static INTERNODE_HORIZONTAL_PADDING = 30;
|
private static INTERNODE_HORIZONTAL_PADDING = 30;
|
||||||
|
|
||||||
predict(graph, parent, node: Node, position: PositionType) {
|
predict(graph, parent, node: Node, position: PositionType): [number, PositionType] {
|
||||||
const rootNode = graph.getRootNode(parent);
|
const rootNode = graph.getRootNode(parent);
|
||||||
|
|
||||||
// If it is a dragged node...
|
// If it is a dragged node...
|
||||||
@ -44,19 +44,16 @@ class BalancedSorter extends AbstractBasicSorter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let right;
|
// Find the order ...
|
||||||
let left;
|
let order: number;
|
||||||
if (!position) {
|
if (!position) {
|
||||||
right = this._getChildrenForOrder(parent, graph, 0);
|
const right = this._getChildrenForOrder(parent, graph, 0);
|
||||||
left = this._getChildrenForOrder(parent, graph, 1);
|
const left = this._getChildrenForOrder(parent, graph, 1);
|
||||||
}
|
|
||||||
// Filter nodes on one side..
|
|
||||||
let order;
|
|
||||||
if (position) {
|
|
||||||
order = position.x > rootNode.getPosition().x ? 0 : 1;
|
|
||||||
} else {
|
|
||||||
order = right.length - left.length > 0 ? 1 : 0;
|
order = right.length - left.length > 0 ? 1 : 0;
|
||||||
|
} else {
|
||||||
|
order = position.x > rootNode.getPosition().x ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const direction = order % 2 === 0 ? 1 : -1;
|
const direction = order % 2 === 0 ? 1 : -1;
|
||||||
|
|
||||||
// Exclude the dragged node (if set)
|
// Exclude the dragged node (if set)
|
||||||
@ -79,7 +76,7 @@ class BalancedSorter extends AbstractBasicSorter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try to fit within ...
|
// Try to fit within ...
|
||||||
let result = null;
|
let result: [number, PositionType] | null = null;
|
||||||
const last = children[children.length - 1];
|
const last = children[children.length - 1];
|
||||||
const newestPosition = position || { x: last.getPosition().x, y: last.getPosition().y + 1 };
|
const newestPosition = position || { x: last.getPosition().x, y: last.getPosition().y + 1 };
|
||||||
children.forEach((child, index) => {
|
children.forEach((child, index) => {
|
||||||
@ -234,7 +231,7 @@ class BalancedSorter extends AbstractBasicSorter {
|
|||||||
return 'Balanced Sorter';
|
return 'Balanced Sorter';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected _getChildrenForOrder(parent: Node, graph: RootedTreeSet, order: number) {
|
protected _getChildrenForOrder(parent: Node, graph: RootedTreeSet, order: number): Node[] {
|
||||||
return this._getSortedChildren(graph, parent).filter(
|
return this._getSortedChildren(graph, parent).filter(
|
||||||
(child) => child.getOrder() % 2 === order % 2,
|
(child) => child.getOrder() % 2 === order % 2,
|
||||||
);
|
);
|
||||||
|
@ -288,7 +288,7 @@ abstract class INodeModel {
|
|||||||
|
|
||||||
abstract getPropertiesKeys(): string[];
|
abstract getPropertiesKeys(): string[];
|
||||||
|
|
||||||
abstract getProperty(key: string): number | string | boolean | undefined;
|
abstract getProperty(key: string): number | string | boolean;
|
||||||
|
|
||||||
abstract putProperty(key: string, value: number | string | boolean): void;
|
abstract putProperty(key: string, value: number | string | boolean): void;
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ import Mindmap from '../model/Mindmap';
|
|||||||
import FeatureModelFactory from '../model/FeatureModelFactory';
|
import FeatureModelFactory from '../model/FeatureModelFactory';
|
||||||
import NodeModel from '../model/NodeModel';
|
import NodeModel from '../model/NodeModel';
|
||||||
import XMLMindmapSerializer from './XMLMindmapSerializer';
|
import XMLMindmapSerializer from './XMLMindmapSerializer';
|
||||||
|
import FeatureModel from '../model/FeatureModel';
|
||||||
|
|
||||||
class XMLSerializerBeta implements XMLMindmapSerializer {
|
class XMLSerializerBeta implements XMLMindmapSerializer {
|
||||||
private static MAP_ROOT_NODE = 'map';
|
private static MAP_ROOT_NODE = 'map';
|
||||||
@ -65,7 +66,7 @@ class XMLSerializerBeta implements XMLMindmapSerializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const text = topic.getText();
|
const text = topic.getText();
|
||||||
if ($defined(text)) {
|
if (text) {
|
||||||
parentTopic.setAttribute('text', text);
|
parentTopic.setAttribute('text', text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,9 +298,9 @@ class XMLSerializerBeta implements XMLMindmapSerializer {
|
|||||||
return topic;
|
return topic;
|
||||||
}
|
}
|
||||||
|
|
||||||
_deserializeIcon(domElem: Element) {
|
private _deserializeIcon(domElem: Element): FeatureModel {
|
||||||
let icon = domElem.getAttribute('id');
|
let icon = domElem.getAttribute('id');
|
||||||
icon = icon.replace('images/', 'icons/legacy/');
|
icon = icon ? icon.replace('images/', 'icons/legacy/') : 'missing';
|
||||||
return FeatureModelFactory.createModel('icon', { id: icon });
|
return FeatureModelFactory.createModel('icon', { id: icon });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,7 +268,7 @@ class XMLSerializerTango implements XMLMindmapSerializer {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Clean up from the recursion ...
|
// Clean up from the recursion ...
|
||||||
this._idsMap = null;
|
this._idsMap = {};
|
||||||
mindmap.setId(mapId);
|
mindmap.setId(mapId);
|
||||||
return mindmap;
|
return mindmap;
|
||||||
}
|
}
|
||||||
@ -389,8 +389,10 @@ class XMLSerializerTango implements XMLMindmapSerializer {
|
|||||||
|
|
||||||
for (let j = 0; j < namedNodeMap.length; j++) {
|
for (let j = 0; j < namedNodeMap.length; j++) {
|
||||||
const attribute = namedNodeMap.item(j);
|
const attribute = namedNodeMap.item(j);
|
||||||
|
if (attribute !== null) {
|
||||||
attributes[attribute.name] = attribute.value;
|
attributes[attribute.name] = attribute.value;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Has text node ?.
|
// Has text node ?.
|
||||||
const textAttr = XMLSerializerTango._deserializeTextAttr(elem);
|
const textAttr = XMLSerializerTango._deserializeTextAttr(elem);
|
||||||
@ -437,7 +439,7 @@ class XMLSerializerTango implements XMLMindmapSerializer {
|
|||||||
|
|
||||||
static _deserializeTextAttr(domElem: Element): string {
|
static _deserializeTextAttr(domElem: Element): string {
|
||||||
let value = domElem.getAttribute('text');
|
let value = domElem.getAttribute('text');
|
||||||
if (!$defined(value)) {
|
if (!value) {
|
||||||
const children = domElem.childNodes;
|
const children = domElem.childNodes;
|
||||||
for (let i = 0; i < children.length; i++) {
|
for (let i = 0; i < children.length; i++) {
|
||||||
const child = children[i];
|
const child = children[i];
|
||||||
@ -448,11 +450,10 @@ class XMLSerializerTango implements XMLMindmapSerializer {
|
|||||||
} else {
|
} else {
|
||||||
// Notes must be decoded ...
|
// Notes must be decoded ...
|
||||||
value = unescape(value);
|
value = unescape(value);
|
||||||
|
|
||||||
// Hack for empty nodes ...
|
|
||||||
if (value === '') {
|
|
||||||
value = ' ';
|
|
||||||
}
|
}
|
||||||
|
// Hack for empty nodes ...
|
||||||
|
if (!value) {
|
||||||
|
value = ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
@ -462,7 +463,7 @@ class XMLSerializerTango implements XMLMindmapSerializer {
|
|||||||
return emojiToIconMap[icon];
|
return emojiToIconMap[icon];
|
||||||
}
|
}
|
||||||
|
|
||||||
private static _deserializeNodeText(domElem: ChildNode): string | null {
|
private static _deserializeNodeText(domElem: ChildNode): string {
|
||||||
const children = domElem.childNodes;
|
const children = domElem.childNodes;
|
||||||
let value: string | null = null;
|
let value: string | null = null;
|
||||||
for (let i = 0; i < children.length; i++) {
|
for (let i = 0; i < children.length; i++) {
|
||||||
@ -471,13 +472,13 @@ class XMLSerializerTango implements XMLMindmapSerializer {
|
|||||||
value = child.nodeValue;
|
value = child.nodeValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return value;
|
return value !== null ? value : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
static _deserializeRelationship(domElement: Element, mindmap: Mindmap): RelationshipModel {
|
static _deserializeRelationship(domElement: Element, mindmap: Mindmap): RelationshipModel {
|
||||||
const srcId = Number.parseInt(domElement.getAttribute('srcTopicId'), 10);
|
const srcId = Number.parseInt(domElement.getAttribute('srcTopicId')!, 10);
|
||||||
const destId = Number.parseInt(domElement.getAttribute('destTopicId'), 10);
|
const destId = Number.parseInt(domElement.getAttribute('destTopicId')!, 10);
|
||||||
const lineType = Number.parseInt(domElement.getAttribute('lineType'), 10);
|
const lineType = Number.parseInt(domElement.getAttribute('lineType')!, 10);
|
||||||
const srcCtrlPoint = domElement.getAttribute('srcCtrlPoint');
|
const srcCtrlPoint = domElement.getAttribute('srcCtrlPoint');
|
||||||
const destCtrlPoint = domElement.getAttribute('destCtrlPoint');
|
const destCtrlPoint = domElement.getAttribute('destCtrlPoint');
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ class ToolbarNotifier {
|
|||||||
this.container.data('transitioning', true);
|
this.container.data('transitioning', true);
|
||||||
this.container.text(msg);
|
this.container.text(msg);
|
||||||
this.container.css({
|
this.container.css({
|
||||||
left: ($(window).width() - this.container.width()) / 2 - 9,
|
left: ($(window).width()! - this.container.width()!) / 2 - 9,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (fade) {
|
if (fade) {
|
||||||
|
File diff suppressed because one or more lines are too long
@ -10,7 +10,7 @@
|
|||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"strictNullChecks": true,
|
"strictNullChecks": false,
|
||||||
"rootDirs": [
|
"rootDirs": [
|
||||||
"src",
|
"src",
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user