diff --git a/examples/SVG Export/Rotated Primitives.html b/examples/SVG Export/Rotated Primitives.html index c6bd39ca..e03c6cf4 100644 --- a/examples/SVG Export/Rotated Primitives.html +++ b/examples/SVG Export/Rotated Primitives.html @@ -29,7 +29,21 @@ var rect = new Path.RoundRectangle(250, 20, 200, 300, 40, 20); rect.fillColor = 'yellow'; rect.rotate(-20); - + rect.data = { + string: '----', + number: 1234, + array: ['a ray', 'some rays'], + bool: true, + nil: null, + point: new Point(12, 34), + size: new Size(12, 34), + rectangle: new Rectangle([12, 34], [56, 78]), + deep: { + deeper: { + deepest: true + } + } + }; document.getElementById('svg').appendChild(project.exportSvg()); diff --git a/examples/SVG Import/Rect Testing.html b/examples/SVG Import/Rect Testing.html index 969f6c36..bcfe5197 100644 --- a/examples/SVG Import/Rect Testing.html +++ b/examples/SVG Import/Rect Testing.html @@ -6,12 +6,13 @@ - + diff --git a/src/svg/SvgExport.js b/src/svg/SvgExport.js index b5a2f775..a42288e9 100644 --- a/src/svg/SvgExport.js +++ b/src/svg/SvgExport.js @@ -482,6 +482,8 @@ new function() { function exportSvg(item) { var exporter = exporters[item._type], node = exporter && exporter(item, item._type); + if (node && item._data) + node.setAttribute('data-paper-data', JSON.stringify(item._data)); return node && applyStyle(item, node); } diff --git a/src/svg/SvgImport.js b/src/svg/SvgImport.js index 9b735245..b8338e87 100644 --- a/src/svg/SvgImport.js +++ b/src/svg/SvgImport.js @@ -453,10 +453,13 @@ new function() { function importSvg(node, clearDefs) { var type = node.nodeName, importer = importers[type], - item = importer && importer(node, type); + item = importer && importer(node, type), + data = node.getAttribute('data-paper-data'); // See importGroup() for an explanation of this filtering: if (item && item._type !== 'group') item = applyAttributes(item, node); + if (item && data) + item._data = JSON.parse(data); // Clear definitions at the end of import? if (clearDefs) definitions = {};