mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-22 23:39:59 -05:00
Prebuilt module for commit df57c4adb9
This commit is contained in:
parent
ebfaee9d4c
commit
b2bbe1b535
5 changed files with 224 additions and 203 deletions
137
dist/docs/assets/js/paper.js
vendored
137
dist/docs/assets/js/paper.js
vendored
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Date: Thu Feb 11 10:05:21 2016 +0100
|
* Date: Thu Feb 11 11:06:09 2016 +0100
|
||||||
*
|
*
|
||||||
***
|
***
|
||||||
*
|
*
|
||||||
|
@ -10983,9 +10983,9 @@ var GradientStop = Base.extend({
|
||||||
|
|
||||||
var Style = Base.extend(new function() {
|
var Style = Base.extend(new function() {
|
||||||
var defaults = {
|
var defaults = {
|
||||||
fillColor: undefined,
|
fillColor: null,
|
||||||
fillRule: 'nonzero',
|
fillRule: 'nonzero',
|
||||||
strokeColor: undefined,
|
strokeColor: null,
|
||||||
strokeWidth: 1,
|
strokeWidth: 1,
|
||||||
strokeCap: 'butt',
|
strokeCap: 'butt',
|
||||||
strokeJoin: 'miter',
|
strokeJoin: 'miter',
|
||||||
|
@ -10993,10 +10993,10 @@ var Style = Base.extend(new function() {
|
||||||
miterLimit: 10,
|
miterLimit: 10,
|
||||||
dashOffset: 0,
|
dashOffset: 0,
|
||||||
dashArray: [],
|
dashArray: [],
|
||||||
shadowColor: undefined,
|
shadowColor: null,
|
||||||
shadowBlur: 0,
|
shadowBlur: 0,
|
||||||
shadowOffset: new Point(),
|
shadowOffset: new Point(),
|
||||||
selectedColor: undefined
|
selectedColor: null
|
||||||
},
|
},
|
||||||
textDefaults = new Base(defaults, {
|
textDefaults = new Base(defaults, {
|
||||||
fillColor: new Color(),
|
fillColor: new Color(),
|
||||||
|
@ -13386,18 +13386,19 @@ new function() {
|
||||||
function importGroup(node, type, options, isRoot) {
|
function importGroup(node, type, options, isRoot) {
|
||||||
var nodes = node.childNodes,
|
var nodes = node.childNodes,
|
||||||
isClip = type === 'clippath',
|
isClip = type === 'clippath',
|
||||||
|
isDefs = type === 'defs',
|
||||||
item = new Group(),
|
item = new Group(),
|
||||||
project = item._project,
|
project = item._project,
|
||||||
currentStyle = project._currentStyle,
|
currentStyle = project._currentStyle,
|
||||||
children = [];
|
children = [];
|
||||||
if (!isClip) {
|
if (!isClip && !isDefs) {
|
||||||
item = applyAttributes(item, node, isRoot);
|
item = applyAttributes(item, node, isRoot);
|
||||||
project._currentStyle = item._style.clone();
|
project._currentStyle = item._style.clone();
|
||||||
}
|
}
|
||||||
if (isRoot) {
|
if (isRoot) {
|
||||||
var defs = node.querySelectorAll('defs');
|
var defs = node.querySelectorAll('defs');
|
||||||
for (var i = 0, l = defs.length; i < l; i++) {
|
for (var i = 0, l = defs.length; i < l; i++) {
|
||||||
importSVG(defs[i], options, false);
|
importNode(defs[i], options, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (var i = 0, l = nodes.length; i < l; i++) {
|
for (var i = 0, l = nodes.length; i < l; i++) {
|
||||||
|
@ -13405,7 +13406,7 @@ new function() {
|
||||||
child;
|
child;
|
||||||
if (childNode.nodeType === 1
|
if (childNode.nodeType === 1
|
||||||
&& childNode.nodeName.toLowerCase() !== 'defs'
|
&& childNode.nodeName.toLowerCase() !== 'defs'
|
||||||
&& (child = importSVG(childNode, options, false))
|
&& (child = importNode(childNode, options, false))
|
||||||
&& !(child instanceof SymbolDefinition))
|
&& !(child instanceof SymbolDefinition))
|
||||||
children.push(child);
|
children.push(child);
|
||||||
}
|
}
|
||||||
|
@ -13413,7 +13414,7 @@ new function() {
|
||||||
if (isClip)
|
if (isClip)
|
||||||
item = applyAttributes(item.reduce(), node, isRoot);
|
item = applyAttributes(item.reduce(), node, isRoot);
|
||||||
project._currentStyle = currentStyle;
|
project._currentStyle = currentStyle;
|
||||||
if (isClip || type === 'defs') {
|
if (isClip || isDefs) {
|
||||||
item.remove();
|
item.remove();
|
||||||
item = null;
|
item = null;
|
||||||
}
|
}
|
||||||
|
@ -13484,28 +13485,9 @@ new function() {
|
||||||
'#document': function (node, type, options, isRoot) {
|
'#document': function (node, type, options, isRoot) {
|
||||||
var nodes = node.childNodes;
|
var nodes = node.childNodes;
|
||||||
for (var i = 0, l = nodes.length; i < l; i++) {
|
for (var i = 0, l = nodes.length; i < l; i++) {
|
||||||
var child = nodes[i],
|
var child = nodes[i];
|
||||||
next;
|
if (child.nodeType === 1)
|
||||||
if (child.nodeType === 1) {
|
return importNode(child, options, isRoot);
|
||||||
var body = document.body,
|
|
||||||
parent = !paper.agent.node && SvgElement.create('svg');
|
|
||||||
if (parent) {
|
|
||||||
body.appendChild(parent);
|
|
||||||
parent.style.strokeWidth = '1px';
|
|
||||||
next = child.nextSibling;
|
|
||||||
parent.appendChild(child);
|
|
||||||
}
|
|
||||||
var item = importSVG(child, options, isRoot);
|
|
||||||
if (parent) {
|
|
||||||
body.removeChild(parent);
|
|
||||||
if (next) {
|
|
||||||
node.insertBefore(child, next);
|
|
||||||
} else {
|
|
||||||
node.appendChild(child);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
g: importGroup,
|
g: importGroup,
|
||||||
|
@ -13752,6 +13734,64 @@ new function() {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function importNode(node, options, isRoot) {
|
||||||
|
var type = node.nodeName.toLowerCase(),
|
||||||
|
isElement = type !== '#document',
|
||||||
|
body = document.body,
|
||||||
|
container,
|
||||||
|
parent,
|
||||||
|
next;
|
||||||
|
if (isRoot && isElement) {
|
||||||
|
rootSize = getSize(node, null, null, true)
|
||||||
|
|| paper.getView().getSize();
|
||||||
|
container = !paper.agent.node && SvgElement.create('svg', {
|
||||||
|
style: 'stroke-width: 1px; stroke-miterlimit: 10'
|
||||||
|
});
|
||||||
|
if (container) {
|
||||||
|
body.appendChild(container);
|
||||||
|
parent = node.parentNode;
|
||||||
|
next = node.nextSibling;
|
||||||
|
container.appendChild(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var settings = paper.settings,
|
||||||
|
applyMatrix = settings.applyMatrix;
|
||||||
|
settings.applyMatrix = false;
|
||||||
|
var importer = importers[type],
|
||||||
|
item = importer && importer(node, type, options, isRoot) || null;
|
||||||
|
settings.applyMatrix = applyMatrix;
|
||||||
|
if (item) {
|
||||||
|
if (isElement && !(item instanceof Group))
|
||||||
|
item = applyAttributes(item, node, isRoot);
|
||||||
|
var onImport = options.onImport,
|
||||||
|
data = isElement && node.getAttribute('data-paper-data');
|
||||||
|
if (onImport)
|
||||||
|
item = onImport(node, item, options) || item;
|
||||||
|
if (options.expandShapes && item instanceof Shape) {
|
||||||
|
item.remove();
|
||||||
|
item = item.toPath();
|
||||||
|
}
|
||||||
|
if (data)
|
||||||
|
item._data = JSON.parse(data);
|
||||||
|
}
|
||||||
|
if (container) {
|
||||||
|
body.removeChild(container);
|
||||||
|
if (parent) {
|
||||||
|
if (next) {
|
||||||
|
parent.insertBefore(node, next);
|
||||||
|
} else {
|
||||||
|
parent.appendChild(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isRoot) {
|
||||||
|
definitions = {};
|
||||||
|
if (item && Base.pick(options.applyMatrix, applyMatrix))
|
||||||
|
item.matrix.apply(true, true);
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
function importSVG(source, options, isRoot) {
|
function importSVG(source, options, isRoot) {
|
||||||
if (!source)
|
if (!source)
|
||||||
return null;
|
return null;
|
||||||
|
@ -13784,46 +13824,13 @@ new function() {
|
||||||
return reader.readAsText(source);
|
return reader.readAsText(source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof source === 'string') {
|
if (typeof source === 'string') {
|
||||||
node = new window.DOMParser().parseFromString(source,
|
node = new window.DOMParser().parseFromString(source,
|
||||||
'image/svg+xml');
|
'image/svg+xml');
|
||||||
}
|
}
|
||||||
if (!node.nodeName)
|
if (!node.nodeName)
|
||||||
throw new Error('Unsupported SVG source: ' + source);
|
throw new Error('Unsupported SVG source: ' + source);
|
||||||
var type = node.nodeName.toLowerCase(),
|
return importNode(node, options, isRoot);
|
||||||
isElement = type !== '#document',
|
|
||||||
importer = importers[type],
|
|
||||||
item,
|
|
||||||
data = isElement && node.getAttribute('data-paper-data'),
|
|
||||||
settings = scope.settings,
|
|
||||||
applyMatrix = settings.applyMatrix;
|
|
||||||
if (isRoot && isElement) {
|
|
||||||
rootSize = getSize(node, null, null, true)
|
|
||||||
|| scope.getView().getSize();
|
|
||||||
}
|
|
||||||
settings.applyMatrix = false;
|
|
||||||
item = importer && importer(node, type, options, isRoot) || null;
|
|
||||||
settings.applyMatrix = applyMatrix;
|
|
||||||
if (item) {
|
|
||||||
if (isElement && !(item instanceof Group))
|
|
||||||
item = applyAttributes(item, node, isRoot);
|
|
||||||
var onImport = options.onImport;
|
|
||||||
if (onImport)
|
|
||||||
item = onImport(node, item, options) || item;
|
|
||||||
if (options.expandShapes && item instanceof Shape) {
|
|
||||||
item.remove();
|
|
||||||
item = item.toPath();
|
|
||||||
}
|
|
||||||
if (data)
|
|
||||||
item._data = JSON.parse(data);
|
|
||||||
}
|
|
||||||
if (isRoot) {
|
|
||||||
definitions = {};
|
|
||||||
if (item && Base.pick(options.applyMatrix, applyMatrix))
|
|
||||||
item.matrix.apply(true, true);
|
|
||||||
}
|
|
||||||
return item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Item.inject({
|
Item.inject({
|
||||||
|
|
137
dist/paper-core.js
vendored
137
dist/paper-core.js
vendored
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Date: Thu Feb 11 10:05:21 2016 +0100
|
* Date: Thu Feb 11 11:06:09 2016 +0100
|
||||||
*
|
*
|
||||||
***
|
***
|
||||||
*
|
*
|
||||||
|
@ -10983,9 +10983,9 @@ var GradientStop = Base.extend({
|
||||||
|
|
||||||
var Style = Base.extend(new function() {
|
var Style = Base.extend(new function() {
|
||||||
var defaults = {
|
var defaults = {
|
||||||
fillColor: undefined,
|
fillColor: null,
|
||||||
fillRule: 'nonzero',
|
fillRule: 'nonzero',
|
||||||
strokeColor: undefined,
|
strokeColor: null,
|
||||||
strokeWidth: 1,
|
strokeWidth: 1,
|
||||||
strokeCap: 'butt',
|
strokeCap: 'butt',
|
||||||
strokeJoin: 'miter',
|
strokeJoin: 'miter',
|
||||||
|
@ -10993,10 +10993,10 @@ var Style = Base.extend(new function() {
|
||||||
miterLimit: 10,
|
miterLimit: 10,
|
||||||
dashOffset: 0,
|
dashOffset: 0,
|
||||||
dashArray: [],
|
dashArray: [],
|
||||||
shadowColor: undefined,
|
shadowColor: null,
|
||||||
shadowBlur: 0,
|
shadowBlur: 0,
|
||||||
shadowOffset: new Point(),
|
shadowOffset: new Point(),
|
||||||
selectedColor: undefined
|
selectedColor: null
|
||||||
},
|
},
|
||||||
textDefaults = new Base(defaults, {
|
textDefaults = new Base(defaults, {
|
||||||
fillColor: new Color(),
|
fillColor: new Color(),
|
||||||
|
@ -13386,18 +13386,19 @@ new function() {
|
||||||
function importGroup(node, type, options, isRoot) {
|
function importGroup(node, type, options, isRoot) {
|
||||||
var nodes = node.childNodes,
|
var nodes = node.childNodes,
|
||||||
isClip = type === 'clippath',
|
isClip = type === 'clippath',
|
||||||
|
isDefs = type === 'defs',
|
||||||
item = new Group(),
|
item = new Group(),
|
||||||
project = item._project,
|
project = item._project,
|
||||||
currentStyle = project._currentStyle,
|
currentStyle = project._currentStyle,
|
||||||
children = [];
|
children = [];
|
||||||
if (!isClip) {
|
if (!isClip && !isDefs) {
|
||||||
item = applyAttributes(item, node, isRoot);
|
item = applyAttributes(item, node, isRoot);
|
||||||
project._currentStyle = item._style.clone();
|
project._currentStyle = item._style.clone();
|
||||||
}
|
}
|
||||||
if (isRoot) {
|
if (isRoot) {
|
||||||
var defs = node.querySelectorAll('defs');
|
var defs = node.querySelectorAll('defs');
|
||||||
for (var i = 0, l = defs.length; i < l; i++) {
|
for (var i = 0, l = defs.length; i < l; i++) {
|
||||||
importSVG(defs[i], options, false);
|
importNode(defs[i], options, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (var i = 0, l = nodes.length; i < l; i++) {
|
for (var i = 0, l = nodes.length; i < l; i++) {
|
||||||
|
@ -13405,7 +13406,7 @@ new function() {
|
||||||
child;
|
child;
|
||||||
if (childNode.nodeType === 1
|
if (childNode.nodeType === 1
|
||||||
&& childNode.nodeName.toLowerCase() !== 'defs'
|
&& childNode.nodeName.toLowerCase() !== 'defs'
|
||||||
&& (child = importSVG(childNode, options, false))
|
&& (child = importNode(childNode, options, false))
|
||||||
&& !(child instanceof SymbolDefinition))
|
&& !(child instanceof SymbolDefinition))
|
||||||
children.push(child);
|
children.push(child);
|
||||||
}
|
}
|
||||||
|
@ -13413,7 +13414,7 @@ new function() {
|
||||||
if (isClip)
|
if (isClip)
|
||||||
item = applyAttributes(item.reduce(), node, isRoot);
|
item = applyAttributes(item.reduce(), node, isRoot);
|
||||||
project._currentStyle = currentStyle;
|
project._currentStyle = currentStyle;
|
||||||
if (isClip || type === 'defs') {
|
if (isClip || isDefs) {
|
||||||
item.remove();
|
item.remove();
|
||||||
item = null;
|
item = null;
|
||||||
}
|
}
|
||||||
|
@ -13484,28 +13485,9 @@ new function() {
|
||||||
'#document': function (node, type, options, isRoot) {
|
'#document': function (node, type, options, isRoot) {
|
||||||
var nodes = node.childNodes;
|
var nodes = node.childNodes;
|
||||||
for (var i = 0, l = nodes.length; i < l; i++) {
|
for (var i = 0, l = nodes.length; i < l; i++) {
|
||||||
var child = nodes[i],
|
var child = nodes[i];
|
||||||
next;
|
if (child.nodeType === 1)
|
||||||
if (child.nodeType === 1) {
|
return importNode(child, options, isRoot);
|
||||||
var body = document.body,
|
|
||||||
parent = !paper.agent.node && SvgElement.create('svg');
|
|
||||||
if (parent) {
|
|
||||||
body.appendChild(parent);
|
|
||||||
parent.style.strokeWidth = '1px';
|
|
||||||
next = child.nextSibling;
|
|
||||||
parent.appendChild(child);
|
|
||||||
}
|
|
||||||
var item = importSVG(child, options, isRoot);
|
|
||||||
if (parent) {
|
|
||||||
body.removeChild(parent);
|
|
||||||
if (next) {
|
|
||||||
node.insertBefore(child, next);
|
|
||||||
} else {
|
|
||||||
node.appendChild(child);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
g: importGroup,
|
g: importGroup,
|
||||||
|
@ -13752,6 +13734,64 @@ new function() {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function importNode(node, options, isRoot) {
|
||||||
|
var type = node.nodeName.toLowerCase(),
|
||||||
|
isElement = type !== '#document',
|
||||||
|
body = document.body,
|
||||||
|
container,
|
||||||
|
parent,
|
||||||
|
next;
|
||||||
|
if (isRoot && isElement) {
|
||||||
|
rootSize = getSize(node, null, null, true)
|
||||||
|
|| paper.getView().getSize();
|
||||||
|
container = !paper.agent.node && SvgElement.create('svg', {
|
||||||
|
style: 'stroke-width: 1px; stroke-miterlimit: 10'
|
||||||
|
});
|
||||||
|
if (container) {
|
||||||
|
body.appendChild(container);
|
||||||
|
parent = node.parentNode;
|
||||||
|
next = node.nextSibling;
|
||||||
|
container.appendChild(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var settings = paper.settings,
|
||||||
|
applyMatrix = settings.applyMatrix;
|
||||||
|
settings.applyMatrix = false;
|
||||||
|
var importer = importers[type],
|
||||||
|
item = importer && importer(node, type, options, isRoot) || null;
|
||||||
|
settings.applyMatrix = applyMatrix;
|
||||||
|
if (item) {
|
||||||
|
if (isElement && !(item instanceof Group))
|
||||||
|
item = applyAttributes(item, node, isRoot);
|
||||||
|
var onImport = options.onImport,
|
||||||
|
data = isElement && node.getAttribute('data-paper-data');
|
||||||
|
if (onImport)
|
||||||
|
item = onImport(node, item, options) || item;
|
||||||
|
if (options.expandShapes && item instanceof Shape) {
|
||||||
|
item.remove();
|
||||||
|
item = item.toPath();
|
||||||
|
}
|
||||||
|
if (data)
|
||||||
|
item._data = JSON.parse(data);
|
||||||
|
}
|
||||||
|
if (container) {
|
||||||
|
body.removeChild(container);
|
||||||
|
if (parent) {
|
||||||
|
if (next) {
|
||||||
|
parent.insertBefore(node, next);
|
||||||
|
} else {
|
||||||
|
parent.appendChild(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isRoot) {
|
||||||
|
definitions = {};
|
||||||
|
if (item && Base.pick(options.applyMatrix, applyMatrix))
|
||||||
|
item.matrix.apply(true, true);
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
function importSVG(source, options, isRoot) {
|
function importSVG(source, options, isRoot) {
|
||||||
if (!source)
|
if (!source)
|
||||||
return null;
|
return null;
|
||||||
|
@ -13784,46 +13824,13 @@ new function() {
|
||||||
return reader.readAsText(source);
|
return reader.readAsText(source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof source === 'string') {
|
if (typeof source === 'string') {
|
||||||
node = new window.DOMParser().parseFromString(source,
|
node = new window.DOMParser().parseFromString(source,
|
||||||
'image/svg+xml');
|
'image/svg+xml');
|
||||||
}
|
}
|
||||||
if (!node.nodeName)
|
if (!node.nodeName)
|
||||||
throw new Error('Unsupported SVG source: ' + source);
|
throw new Error('Unsupported SVG source: ' + source);
|
||||||
var type = node.nodeName.toLowerCase(),
|
return importNode(node, options, isRoot);
|
||||||
isElement = type !== '#document',
|
|
||||||
importer = importers[type],
|
|
||||||
item,
|
|
||||||
data = isElement && node.getAttribute('data-paper-data'),
|
|
||||||
settings = scope.settings,
|
|
||||||
applyMatrix = settings.applyMatrix;
|
|
||||||
if (isRoot && isElement) {
|
|
||||||
rootSize = getSize(node, null, null, true)
|
|
||||||
|| scope.getView().getSize();
|
|
||||||
}
|
|
||||||
settings.applyMatrix = false;
|
|
||||||
item = importer && importer(node, type, options, isRoot) || null;
|
|
||||||
settings.applyMatrix = applyMatrix;
|
|
||||||
if (item) {
|
|
||||||
if (isElement && !(item instanceof Group))
|
|
||||||
item = applyAttributes(item, node, isRoot);
|
|
||||||
var onImport = options.onImport;
|
|
||||||
if (onImport)
|
|
||||||
item = onImport(node, item, options) || item;
|
|
||||||
if (options.expandShapes && item instanceof Shape) {
|
|
||||||
item.remove();
|
|
||||||
item = item.toPath();
|
|
||||||
}
|
|
||||||
if (data)
|
|
||||||
item._data = JSON.parse(data);
|
|
||||||
}
|
|
||||||
if (isRoot) {
|
|
||||||
definitions = {};
|
|
||||||
if (item && Base.pick(options.applyMatrix, applyMatrix))
|
|
||||||
item.matrix.apply(true, true);
|
|
||||||
}
|
|
||||||
return item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Item.inject({
|
Item.inject({
|
||||||
|
|
8
dist/paper-core.min.js
vendored
8
dist/paper-core.min.js
vendored
File diff suppressed because one or more lines are too long
137
dist/paper-full.js
vendored
137
dist/paper-full.js
vendored
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Date: Thu Feb 11 10:05:21 2016 +0100
|
* Date: Thu Feb 11 11:06:09 2016 +0100
|
||||||
*
|
*
|
||||||
***
|
***
|
||||||
*
|
*
|
||||||
|
@ -10983,9 +10983,9 @@ var GradientStop = Base.extend({
|
||||||
|
|
||||||
var Style = Base.extend(new function() {
|
var Style = Base.extend(new function() {
|
||||||
var defaults = {
|
var defaults = {
|
||||||
fillColor: undefined,
|
fillColor: null,
|
||||||
fillRule: 'nonzero',
|
fillRule: 'nonzero',
|
||||||
strokeColor: undefined,
|
strokeColor: null,
|
||||||
strokeWidth: 1,
|
strokeWidth: 1,
|
||||||
strokeCap: 'butt',
|
strokeCap: 'butt',
|
||||||
strokeJoin: 'miter',
|
strokeJoin: 'miter',
|
||||||
|
@ -10993,10 +10993,10 @@ var Style = Base.extend(new function() {
|
||||||
miterLimit: 10,
|
miterLimit: 10,
|
||||||
dashOffset: 0,
|
dashOffset: 0,
|
||||||
dashArray: [],
|
dashArray: [],
|
||||||
shadowColor: undefined,
|
shadowColor: null,
|
||||||
shadowBlur: 0,
|
shadowBlur: 0,
|
||||||
shadowOffset: new Point(),
|
shadowOffset: new Point(),
|
||||||
selectedColor: undefined
|
selectedColor: null
|
||||||
},
|
},
|
||||||
textDefaults = new Base(defaults, {
|
textDefaults = new Base(defaults, {
|
||||||
fillColor: new Color(),
|
fillColor: new Color(),
|
||||||
|
@ -13386,18 +13386,19 @@ new function() {
|
||||||
function importGroup(node, type, options, isRoot) {
|
function importGroup(node, type, options, isRoot) {
|
||||||
var nodes = node.childNodes,
|
var nodes = node.childNodes,
|
||||||
isClip = type === 'clippath',
|
isClip = type === 'clippath',
|
||||||
|
isDefs = type === 'defs',
|
||||||
item = new Group(),
|
item = new Group(),
|
||||||
project = item._project,
|
project = item._project,
|
||||||
currentStyle = project._currentStyle,
|
currentStyle = project._currentStyle,
|
||||||
children = [];
|
children = [];
|
||||||
if (!isClip) {
|
if (!isClip && !isDefs) {
|
||||||
item = applyAttributes(item, node, isRoot);
|
item = applyAttributes(item, node, isRoot);
|
||||||
project._currentStyle = item._style.clone();
|
project._currentStyle = item._style.clone();
|
||||||
}
|
}
|
||||||
if (isRoot) {
|
if (isRoot) {
|
||||||
var defs = node.querySelectorAll('defs');
|
var defs = node.querySelectorAll('defs');
|
||||||
for (var i = 0, l = defs.length; i < l; i++) {
|
for (var i = 0, l = defs.length; i < l; i++) {
|
||||||
importSVG(defs[i], options, false);
|
importNode(defs[i], options, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (var i = 0, l = nodes.length; i < l; i++) {
|
for (var i = 0, l = nodes.length; i < l; i++) {
|
||||||
|
@ -13405,7 +13406,7 @@ new function() {
|
||||||
child;
|
child;
|
||||||
if (childNode.nodeType === 1
|
if (childNode.nodeType === 1
|
||||||
&& childNode.nodeName.toLowerCase() !== 'defs'
|
&& childNode.nodeName.toLowerCase() !== 'defs'
|
||||||
&& (child = importSVG(childNode, options, false))
|
&& (child = importNode(childNode, options, false))
|
||||||
&& !(child instanceof SymbolDefinition))
|
&& !(child instanceof SymbolDefinition))
|
||||||
children.push(child);
|
children.push(child);
|
||||||
}
|
}
|
||||||
|
@ -13413,7 +13414,7 @@ new function() {
|
||||||
if (isClip)
|
if (isClip)
|
||||||
item = applyAttributes(item.reduce(), node, isRoot);
|
item = applyAttributes(item.reduce(), node, isRoot);
|
||||||
project._currentStyle = currentStyle;
|
project._currentStyle = currentStyle;
|
||||||
if (isClip || type === 'defs') {
|
if (isClip || isDefs) {
|
||||||
item.remove();
|
item.remove();
|
||||||
item = null;
|
item = null;
|
||||||
}
|
}
|
||||||
|
@ -13484,28 +13485,9 @@ new function() {
|
||||||
'#document': function (node, type, options, isRoot) {
|
'#document': function (node, type, options, isRoot) {
|
||||||
var nodes = node.childNodes;
|
var nodes = node.childNodes;
|
||||||
for (var i = 0, l = nodes.length; i < l; i++) {
|
for (var i = 0, l = nodes.length; i < l; i++) {
|
||||||
var child = nodes[i],
|
var child = nodes[i];
|
||||||
next;
|
if (child.nodeType === 1)
|
||||||
if (child.nodeType === 1) {
|
return importNode(child, options, isRoot);
|
||||||
var body = document.body,
|
|
||||||
parent = !paper.agent.node && SvgElement.create('svg');
|
|
||||||
if (parent) {
|
|
||||||
body.appendChild(parent);
|
|
||||||
parent.style.strokeWidth = '1px';
|
|
||||||
next = child.nextSibling;
|
|
||||||
parent.appendChild(child);
|
|
||||||
}
|
|
||||||
var item = importSVG(child, options, isRoot);
|
|
||||||
if (parent) {
|
|
||||||
body.removeChild(parent);
|
|
||||||
if (next) {
|
|
||||||
node.insertBefore(child, next);
|
|
||||||
} else {
|
|
||||||
node.appendChild(child);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
g: importGroup,
|
g: importGroup,
|
||||||
|
@ -13752,6 +13734,64 @@ new function() {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function importNode(node, options, isRoot) {
|
||||||
|
var type = node.nodeName.toLowerCase(),
|
||||||
|
isElement = type !== '#document',
|
||||||
|
body = document.body,
|
||||||
|
container,
|
||||||
|
parent,
|
||||||
|
next;
|
||||||
|
if (isRoot && isElement) {
|
||||||
|
rootSize = getSize(node, null, null, true)
|
||||||
|
|| paper.getView().getSize();
|
||||||
|
container = !paper.agent.node && SvgElement.create('svg', {
|
||||||
|
style: 'stroke-width: 1px; stroke-miterlimit: 10'
|
||||||
|
});
|
||||||
|
if (container) {
|
||||||
|
body.appendChild(container);
|
||||||
|
parent = node.parentNode;
|
||||||
|
next = node.nextSibling;
|
||||||
|
container.appendChild(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var settings = paper.settings,
|
||||||
|
applyMatrix = settings.applyMatrix;
|
||||||
|
settings.applyMatrix = false;
|
||||||
|
var importer = importers[type],
|
||||||
|
item = importer && importer(node, type, options, isRoot) || null;
|
||||||
|
settings.applyMatrix = applyMatrix;
|
||||||
|
if (item) {
|
||||||
|
if (isElement && !(item instanceof Group))
|
||||||
|
item = applyAttributes(item, node, isRoot);
|
||||||
|
var onImport = options.onImport,
|
||||||
|
data = isElement && node.getAttribute('data-paper-data');
|
||||||
|
if (onImport)
|
||||||
|
item = onImport(node, item, options) || item;
|
||||||
|
if (options.expandShapes && item instanceof Shape) {
|
||||||
|
item.remove();
|
||||||
|
item = item.toPath();
|
||||||
|
}
|
||||||
|
if (data)
|
||||||
|
item._data = JSON.parse(data);
|
||||||
|
}
|
||||||
|
if (container) {
|
||||||
|
body.removeChild(container);
|
||||||
|
if (parent) {
|
||||||
|
if (next) {
|
||||||
|
parent.insertBefore(node, next);
|
||||||
|
} else {
|
||||||
|
parent.appendChild(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isRoot) {
|
||||||
|
definitions = {};
|
||||||
|
if (item && Base.pick(options.applyMatrix, applyMatrix))
|
||||||
|
item.matrix.apply(true, true);
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
function importSVG(source, options, isRoot) {
|
function importSVG(source, options, isRoot) {
|
||||||
if (!source)
|
if (!source)
|
||||||
return null;
|
return null;
|
||||||
|
@ -13784,46 +13824,13 @@ new function() {
|
||||||
return reader.readAsText(source);
|
return reader.readAsText(source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof source === 'string') {
|
if (typeof source === 'string') {
|
||||||
node = new window.DOMParser().parseFromString(source,
|
node = new window.DOMParser().parseFromString(source,
|
||||||
'image/svg+xml');
|
'image/svg+xml');
|
||||||
}
|
}
|
||||||
if (!node.nodeName)
|
if (!node.nodeName)
|
||||||
throw new Error('Unsupported SVG source: ' + source);
|
throw new Error('Unsupported SVG source: ' + source);
|
||||||
var type = node.nodeName.toLowerCase(),
|
return importNode(node, options, isRoot);
|
||||||
isElement = type !== '#document',
|
|
||||||
importer = importers[type],
|
|
||||||
item,
|
|
||||||
data = isElement && node.getAttribute('data-paper-data'),
|
|
||||||
settings = scope.settings,
|
|
||||||
applyMatrix = settings.applyMatrix;
|
|
||||||
if (isRoot && isElement) {
|
|
||||||
rootSize = getSize(node, null, null, true)
|
|
||||||
|| scope.getView().getSize();
|
|
||||||
}
|
|
||||||
settings.applyMatrix = false;
|
|
||||||
item = importer && importer(node, type, options, isRoot) || null;
|
|
||||||
settings.applyMatrix = applyMatrix;
|
|
||||||
if (item) {
|
|
||||||
if (isElement && !(item instanceof Group))
|
|
||||||
item = applyAttributes(item, node, isRoot);
|
|
||||||
var onImport = options.onImport;
|
|
||||||
if (onImport)
|
|
||||||
item = onImport(node, item, options) || item;
|
|
||||||
if (options.expandShapes && item instanceof Shape) {
|
|
||||||
item.remove();
|
|
||||||
item = item.toPath();
|
|
||||||
}
|
|
||||||
if (data)
|
|
||||||
item._data = JSON.parse(data);
|
|
||||||
}
|
|
||||||
if (isRoot) {
|
|
||||||
definitions = {};
|
|
||||||
if (item && Base.pick(options.applyMatrix, applyMatrix))
|
|
||||||
item.matrix.apply(true, true);
|
|
||||||
}
|
|
||||||
return item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Item.inject({
|
Item.inject({
|
||||||
|
|
8
dist/paper-full.min.js
vendored
8
dist/paper-full.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue