react-design-editor 0.0.58 → 0.0.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -326,7 +326,8 @@ declare class Handler implements HandlerOptions {
|
|
|
326
326
|
* Set the image
|
|
327
327
|
* @param {FabricImage} obj
|
|
328
328
|
* @param {(File | string)} [source]
|
|
329
|
-
* @param {boolean} [keepSize]
|
|
329
|
+
* @param {boolean} [keepSize] Keep size of previous Image
|
|
330
|
+
* @param {fabric.IImageOptions} [options]
|
|
330
331
|
* @returns
|
|
331
332
|
*/
|
|
332
333
|
setImage: (obj: FabricImage, source?: File | string, keepSize?: boolean, options?: fabric.IImageOptions) => Promise<FabricImage>;
|
|
@@ -334,6 +335,7 @@ declare class Handler implements HandlerOptions {
|
|
|
334
335
|
* Set image by id
|
|
335
336
|
* @param {string} id
|
|
336
337
|
* @param {*} source
|
|
338
|
+
* @param {boolean} [keepSize] Keep size of previous Image
|
|
337
339
|
* @returns
|
|
338
340
|
*/
|
|
339
341
|
setImageById: (id: string, source: any, keepSize?: boolean) => Promise<fabric.Object & fabric.IObjectOptions & {
|
|
@@ -375,10 +377,10 @@ declare class Handler implements HandlerOptions {
|
|
|
375
377
|
*
|
|
376
378
|
* @param {SvgObject} obj
|
|
377
379
|
* @param {(File | string)} [source]
|
|
378
|
-
* @param {boolean} [
|
|
379
|
-
* @param {boolean} [
|
|
380
|
+
* @param {boolean} [keepSize] Keep size of previous SVG
|
|
381
|
+
* @param {boolean} [xmlString] XML string
|
|
380
382
|
*/
|
|
381
|
-
setSvg: (obj: SvgObject, source?: File | string,
|
|
383
|
+
setSvg: (obj: SvgObject, source?: File | string, keepSize?: boolean, xmlString?: boolean) => Promise<SvgObject>;
|
|
382
384
|
/**
|
|
383
385
|
* Set visible
|
|
384
386
|
* @param {boolean} [visible]
|
package/lib/handlers/Handler.js
CHANGED
|
@@ -331,7 +331,8 @@ class Handler {
|
|
|
331
331
|
* Set the image
|
|
332
332
|
* @param {FabricImage} obj
|
|
333
333
|
* @param {(File | string)} [source]
|
|
334
|
-
* @param {boolean} [keepSize]
|
|
334
|
+
* @param {boolean} [keepSize] Keep size of previous Image
|
|
335
|
+
* @param {fabric.IImageOptions} [options]
|
|
335
336
|
* @returns
|
|
336
337
|
*/
|
|
337
338
|
this.setImage = (obj, source, keepSize, options) => {
|
|
@@ -379,6 +380,7 @@ class Handler {
|
|
|
379
380
|
* Set image by id
|
|
380
381
|
* @param {string} id
|
|
381
382
|
* @param {*} source
|
|
383
|
+
* @param {boolean} [keepSize] Keep size of previous Image
|
|
382
384
|
* @returns
|
|
383
385
|
*/
|
|
384
386
|
this.setImageById = (id, source, keepSize) => {
|
|
@@ -390,10 +392,10 @@ class Handler {
|
|
|
390
392
|
*
|
|
391
393
|
* @param {SvgObject} obj
|
|
392
394
|
* @param {(File | string)} [source]
|
|
393
|
-
* @param {boolean} [
|
|
394
|
-
* @param {boolean} [
|
|
395
|
+
* @param {boolean} [keepSize] Keep size of previous SVG
|
|
396
|
+
* @param {boolean} [xmlString] XML string
|
|
395
397
|
*/
|
|
396
|
-
this.setSvg = (obj, source,
|
|
398
|
+
this.setSvg = (obj, source, keepSize, xmlString) => {
|
|
397
399
|
return new Promise(resolve => {
|
|
398
400
|
if (!source) {
|
|
399
401
|
resolve(obj.loadSvg({ src: './images/sample/chiller.svg', loadType: 'file', keepSize }));
|
|
@@ -404,7 +406,7 @@ class Handler {
|
|
|
404
406
|
reader.onload = () => resolve(obj.loadSvg({ src: reader.result, loadType: 'file', keepSize }));
|
|
405
407
|
}
|
|
406
408
|
else {
|
|
407
|
-
resolve(obj.loadSvg({ src: source, loadType:
|
|
409
|
+
resolve(obj.loadSvg({ src: source, loadType: xmlString ? 'svg' : 'file', keepSize }));
|
|
408
410
|
}
|
|
409
411
|
});
|
|
410
412
|
};
|
package/lib/objects/Svg.d.ts
CHANGED
package/lib/objects/Svg.js
CHANGED
|
@@ -56,15 +56,15 @@ const Svg = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
|
|
|
56
56
|
return this;
|
|
57
57
|
},
|
|
58
58
|
loadSvg(option) {
|
|
59
|
-
const { src, loadType, fill, stroke } = option;
|
|
59
|
+
const { src, svg, loadType, fill, stroke } = option;
|
|
60
60
|
return new Promise(resolve => {
|
|
61
61
|
if (loadType === 'svg') {
|
|
62
|
-
fabric_1.fabric.loadSVGFromString(src, (objects, options) => {
|
|
62
|
+
fabric_1.fabric.loadSVGFromString(svg || src, (objects, options) => {
|
|
63
63
|
resolve(this.addSvgElements(objects, { ...options, fill, stroke }));
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
else {
|
|
67
|
-
fabric_1.fabric.loadSVGFromURL(src, (objects, options) => {
|
|
67
|
+
fabric_1.fabric.loadSVGFromURL(svg || src, (objects, options) => {
|
|
68
68
|
resolve(this.addSvgElements(objects, { ...options, fill, stroke }));
|
|
69
69
|
});
|
|
70
70
|
}
|