mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-22 14:47:56 +01:00
Fix web2d patch issue
This commit is contained in:
parent
475c5e2538
commit
f774a8a0c9
@ -16,7 +16,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { $assert, innerXML } from '@wisemapping/core-js';
|
||||
import { $assert } from '@wisemapping/core-js';
|
||||
import XMLSerializerFactory from './persistence/XMLSerializerFactory';
|
||||
|
||||
class PersistenceManager {
|
||||
@ -29,7 +29,7 @@ class PersistenceManager {
|
||||
|
||||
const serializer = XMLSerializerFactory.getSerializerFromMindmap(mindmap);
|
||||
const domMap = serializer.toXML(mindmap);
|
||||
const mapXml = innerXML(domMap);
|
||||
const mapXml = new XMLSerializer().serializeToString(domMap);
|
||||
|
||||
const pref = JSON.stringify(editorProperties);
|
||||
try {
|
||||
|
@ -1,6 +1,5 @@
|
||||
|
||||
import { Mindmap } from "../..";
|
||||
import ImageIcon from "../ImageIcon";
|
||||
import Exporter from "./Exporter";
|
||||
|
||||
class SVGExporter implements Exporter {
|
||||
@ -12,14 +11,14 @@ class SVGExporter implements Exporter {
|
||||
export(): string {
|
||||
// Replace all images for in-line images ...
|
||||
const imagesElements: HTMLCollection = this.svgElement.getElementsByTagName('image');
|
||||
console.log(imagesElements.length);
|
||||
let result:string = new XMLSerializer().serializeToString(this.svgElement);
|
||||
|
||||
const image = ImageIcon.getImageUrl('face_smile');
|
||||
Array.from(imagesElements).forEach((image) => {
|
||||
const imgValue = image.attributes['xlink:href'].value;
|
||||
console.log(image.attributes);
|
||||
});
|
||||
return "";
|
||||
// Are namespace declared ?. Otherwise, force the declaration ...
|
||||
if(result.indexOf('xmlns=')!=-1){
|
||||
result.replace('<svg ', '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" ')
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -169,18 +169,6 @@ class XMLSerializerBeta {
|
||||
return noteDom;
|
||||
}
|
||||
|
||||
static innerXML(element) {
|
||||
let result = null;
|
||||
if ($defined(element.innerXML)) {
|
||||
result = element.innerXML;
|
||||
} if ($defined(element.xml)) {
|
||||
result = element.xml;
|
||||
} if ($defined(XMLSerializer)) {
|
||||
result = new XMLSerializer().serializeToString(element);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
loadFromDom(dom, mapId) {
|
||||
$assert(dom, 'Dom can not be null');
|
||||
$assert(mapId, 'mapId can not be null');
|
||||
@ -196,7 +184,7 @@ class XMLSerializerBeta {
|
||||
$assert(
|
||||
documentElement.tagName === XMLSerializerBeta.MAP_ROOT_NODE,
|
||||
`This seem not to be a map document. Root Tag: '${documentElement.tagName}',HTML:${dom.innerHTML
|
||||
},XML:,${XMLSerializerBeta.innerXML(dom)}`,
|
||||
},XML:,${new XMLSerializer().serializeToString(dom)}`,
|
||||
);
|
||||
|
||||
// Start the loading process ...
|
||||
|
@ -495,18 +495,6 @@ class XMLSerializerPela {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static innerXML(element) {
|
||||
let result = null;
|
||||
if ($defined(element.innerXML)) {
|
||||
result = element.innerXML;
|
||||
} if ($defined(element.xml)) {
|
||||
result = element.xml;
|
||||
} if ($defined(XMLSerializer)) {
|
||||
result = new XMLSerializer().serializeToString(element);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,7 +19,8 @@ test('mindplot generation of simple maps', () => {
|
||||
|
||||
// Inspect ...
|
||||
const exporter = new SVGExporter(mindmap, svgDocument.documentElement);
|
||||
console.log(exporter.export());
|
||||
console.log('Exported map:' + exporter.export());
|
||||
|
||||
|
||||
function parseXMLFile(filePath: fs.PathOrFileDescriptor, mimeType: DOMParserSupportedType) {
|
||||
const parser = new DOMParser();
|
||||
@ -28,8 +29,10 @@ test('mindplot generation of simple maps', () => {
|
||||
|
||||
// Is there any parsing error ?.
|
||||
if (xmlDoc.getElementsByTagName("parsererror").length > 0) {
|
||||
console.log(new XMLSerializer().serializeToString(xmlDoc));
|
||||
throw new Error(`Unexpected error parsing: ${filePath}. Error: ${new XMLSerializer().serializeToString(xmlDoc)}`);
|
||||
}
|
||||
|
||||
return xmlDoc;
|
||||
}
|
||||
});
|
||||
|
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 81 KiB |
@ -90,7 +90,7 @@ class Text extends ElementClass {
|
||||
}
|
||||
|
||||
getHeight() {
|
||||
return parseInt(this.peer.getHeight(), 10);
|
||||
return Number.parseInt(this.peer.getHeight(), 10);
|
||||
}
|
||||
|
||||
getFontHeight() {
|
||||
|
@ -31,10 +31,6 @@ import VerdanaFont from './peer/svg/VerdanaFont';
|
||||
import TahomaFont from './peer/svg/TahomaFont';
|
||||
|
||||
class Toolkit {
|
||||
static init() {
|
||||
|
||||
}
|
||||
|
||||
static createWorkspace(element) {
|
||||
return new WorkspacePeer(element);
|
||||
}
|
||||
|
@ -37,8 +37,8 @@ class CurvedLinePeer extends ElementPeer {
|
||||
const change = this._control1.x !== control.x || this._control1.y !== control.y;
|
||||
if ($defined(control.x)) {
|
||||
this._control1 = control;
|
||||
this._control1.x = Number.parseInt(this._control1.x, 10);
|
||||
this._control1.y = Number.parseInt(this._control1.y, 10);
|
||||
this._control1.x = Number.parseFloat(this._control1.x, 10);
|
||||
this._control1.y = Number.parseFloat(this._control1.y, 10);
|
||||
}
|
||||
if (change) {
|
||||
this._updatePath();
|
||||
@ -50,8 +50,8 @@ class CurvedLinePeer extends ElementPeer {
|
||||
const change = this._control2.x !== control.x || this._control2.y !== control.y;
|
||||
if ($defined(control.x)) {
|
||||
this._control2 = control;
|
||||
this._control2.x = Number.parseInt(this._control2.x, 10);
|
||||
this._control2.y = Number.parseInt(this._control2.y, 10);
|
||||
this._control2.x = Number.parseFloat(this._control2.x, 10);
|
||||
this._control2.y = Number.parseFloat(this._control2.y, 10);
|
||||
}
|
||||
if (change) this._updatePath();
|
||||
}
|
||||
@ -77,16 +77,16 @@ class CurvedLinePeer extends ElementPeer {
|
||||
}
|
||||
|
||||
setFrom(x1, y1) {
|
||||
const change = this._x1 !== parseInt(x1, 10) || this._y1 !== parseInt(y1, 10);
|
||||
this._x1 = Number.parseInt(x1, 10);
|
||||
this._y1 = Number.parseInt(y1, 10);
|
||||
const change = this._x1 !== Number.parseFloat(x1, 10) || this._y1 !== Number.parseFloat(y1, 10);
|
||||
this._x1 = Number.parseFloat(x1, 10);
|
||||
this._y1 = Number.parseFloat(y1, 10);
|
||||
if (change) this._updatePath();
|
||||
}
|
||||
|
||||
setTo(x2, y2) {
|
||||
const change = this._x2 !== parseInt(x2, 10) || this._y2 !== parseInt(y2, 10);
|
||||
this._x2 = Number.parseInt(x2, 10);
|
||||
this._y2 = Number.parseInt(y2, 10);
|
||||
const change = this._x2 !== Number.parseFloat(x2, 10) || this._y2 !== parseFloat(y2, 10);
|
||||
this._x2 = Number.parseFloat(x2, 10);
|
||||
this._y2 = Number.parseFloat(y2, 10);
|
||||
if (change) this._updatePath();
|
||||
}
|
||||
|
||||
@ -196,8 +196,8 @@ class CurvedLinePeer extends ElementPeer {
|
||||
const y2 = m * (x2 - tarPos.x) + tarPos.y;
|
||||
|
||||
return [
|
||||
new Point(Number.toFixed(-srcPos.x + x1, 5), Number.toFixed(-srcPos.y + y1), 5),
|
||||
new Point(Number.toFixed(-tarPos.x + x2, 5), Number.toFixed(-tarPos.y + y2, 5)),
|
||||
new Point(-srcPos.x + x1, -srcPos.y + y1),
|
||||
new Point(-tarPos.x + x2, -tarPos.y + y2),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -120,13 +120,13 @@ class ElementPeer {
|
||||
}
|
||||
|
||||
setSize(width, height) {
|
||||
if ($defined(width) && this._size.width !== parseInt(width, 10)) {
|
||||
this._size.width = parseInt(width, 10);
|
||||
if ($defined(width) && this._size.width !== Number.parseFloat(width, 10)) {
|
||||
this._size.width = Number.parseFloat(width, 10);
|
||||
this._native.setAttribute('width', this._size.width);
|
||||
}
|
||||
|
||||
if ($defined(height) && this._size.height !== parseInt(height, 10)) {
|
||||
this._size.height = parseInt(height, 10);
|
||||
if ($defined(height) && this._size.height !== Number.parseFloat(height, 10)) {
|
||||
this._size.height = Number.parseFloat(height, 10);
|
||||
this._native.setAttribute('height', this._size.height);
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ class Font {
|
||||
}
|
||||
|
||||
getSize() {
|
||||
return parseInt(this._size, 10);
|
||||
return Number.parseInt(this._size, 10);
|
||||
}
|
||||
|
||||
getStyle() {
|
||||
|
@ -132,11 +132,11 @@ class GroupPeer extends ElementPeer {
|
||||
setPosition(x, y) {
|
||||
const change = x !== this._position.x || y !== this._position.y;
|
||||
if ($defined(x)) {
|
||||
this._position.x = parseInt(x, 10);
|
||||
this._position.x = Number.parseFloat(x, 10);
|
||||
}
|
||||
|
||||
if ($defined(y)) {
|
||||
this._position.y = parseInt(y, 10);
|
||||
this._position.y = Number.parseFloat(y, 10);
|
||||
}
|
||||
if (change) {
|
||||
this.updateTransform();
|
||||
|
@ -31,22 +31,23 @@ class RectPeer extends ElementPeer {
|
||||
|
||||
setPosition(x, y) {
|
||||
if ($defined(x)) {
|
||||
this._native.setAttribute('x', parseInt(x, 10));
|
||||
this._native.setAttribute('x', Number.parseFloat(x, 10));
|
||||
}
|
||||
if ($defined(y)) {
|
||||
this._native.setAttribute('y', parseInt(y, 10));
|
||||
this._native.setAttribute('y', Number.parseFloat(y, 10));
|
||||
}
|
||||
}
|
||||
|
||||
getPosition() {
|
||||
const x = this._native.getAttribute('x');
|
||||
const y = this._native.getAttribute('y');
|
||||
return { x: parseInt(x, 10), y: parseInt(y, 10) };
|
||||
return { x: Number.parseFloat(x, 10), y: Number.parseFloat(y, 10) };
|
||||
}
|
||||
|
||||
setSize(width, height) {
|
||||
super.setSize(width, height);
|
||||
const min = width < height ? width : height;
|
||||
|
||||
if ($defined(this._arc)) {
|
||||
// Transform percentages to SVG format.
|
||||
const arc = (min / 2) * this._arc;
|
||||
|
@ -51,16 +51,17 @@ class WorkspacePeer extends ElementPeer {
|
||||
|
||||
setCoordSize(width, height) {
|
||||
const viewBox = this._native.getAttribute('viewBox');
|
||||
|
||||
let coords = [0, 0, 0, 0];
|
||||
if (viewBox != null) {
|
||||
coords = viewBox.split(/ /);
|
||||
}
|
||||
if ($defined(width)) {
|
||||
coords[2] = width;
|
||||
coords[2] = width.toFixed(5);
|
||||
}
|
||||
|
||||
if ($defined(height)) {
|
||||
coords[3] = height;
|
||||
coords[3] = height.toFixed(5);
|
||||
}
|
||||
|
||||
this._native.setAttribute('viewBox', coords.join(' '));
|
||||
|
@ -25,8 +25,8 @@ const TransformUtil = {
|
||||
const coordSize = current.getCoordSize();
|
||||
const size = current.getSize();
|
||||
|
||||
width *= parseInt(size.width, 10) / coordSize.width;
|
||||
height *= parseInt(size.height, 10) / coordSize.height;
|
||||
width *= Number.parseFloat(size.width, 10) / coordSize.width;
|
||||
height *= Number.parseFloat(size.height, 10) / coordSize.height;
|
||||
current = current.getParent();
|
||||
}
|
||||
return { width, height };
|
||||
|
Loading…
Reference in New Issue
Block a user