- Refactoring (minor): getIssues to return codes and strings, lbs
- JSDoc: Fix param
This commit is contained in:
@@ -3189,12 +3189,13 @@ this.save = function (opts) {
|
|||||||
/**
|
/**
|
||||||
* Codes only is useful for locale-independent detection
|
* Codes only is useful for locale-independent detection
|
||||||
*/
|
*/
|
||||||
function getIssues ({codesOnly = false} = {}) {
|
function getIssues () {
|
||||||
// remove the selected outline before serializing
|
// remove the selected outline before serializing
|
||||||
clearSelection();
|
clearSelection();
|
||||||
|
|
||||||
// Check for known CanVG issues
|
// Check for known CanVG issues
|
||||||
const issues = [];
|
const issues = [];
|
||||||
|
const issueCodes = [];
|
||||||
|
|
||||||
// Selector and notice
|
// Selector and notice
|
||||||
const issueList = {
|
const issueList = {
|
||||||
@@ -3211,10 +3212,11 @@ function getIssues ({codesOnly = false} = {}) {
|
|||||||
|
|
||||||
$.each(issueList, function (sel, descr) {
|
$.each(issueList, function (sel, descr) {
|
||||||
if (content.find(sel).length) {
|
if (content.find(sel).length) {
|
||||||
issues.push(codesOnly ? sel : descr);
|
issueCodes.push(sel);
|
||||||
|
issues.push(descr);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return issues;
|
return {issues, issueCodes};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3228,9 +3230,8 @@ function getIssues ({codesOnly = false} = {}) {
|
|||||||
*/
|
*/
|
||||||
this.rasterExport = function (imgType, quality, exportWindowName, cb) {
|
this.rasterExport = function (imgType, quality, exportWindowName, cb) {
|
||||||
const mimeType = 'image/' + imgType.toLowerCase();
|
const mimeType = 'image/' + imgType.toLowerCase();
|
||||||
const issues = getIssues();
|
const {issues, issueCodes} = getIssues();
|
||||||
const issueCodes = getIssues({codesOnly: true});
|
const svg = this.svgCanvasToString();
|
||||||
const str = this.svgCanvasToString();
|
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
buildCanvgCallback(function () {
|
buildCanvgCallback(function () {
|
||||||
@@ -3242,12 +3243,17 @@ this.rasterExport = function (imgType, quality, exportWindowName, cb) {
|
|||||||
c.width = canvas.contentW;
|
c.width = canvas.contentW;
|
||||||
c.height = canvas.contentH;
|
c.height = canvas.contentH;
|
||||||
|
|
||||||
canvg(c, str, {renderCallback () {
|
canvg(c, svg, {renderCallback () {
|
||||||
const dataURLType = (type === 'ICO' ? 'BMP' : type).toLowerCase();
|
const dataURLType = (type === 'ICO' ? 'BMP' : type).toLowerCase();
|
||||||
const datauri = quality ? c.toDataURL('image/' + dataURLType, quality) : c.toDataURL('image/' + dataURLType);
|
const datauri = quality
|
||||||
|
? c.toDataURL('image/' + dataURLType, quality)
|
||||||
|
: c.toDataURL('image/' + dataURLType);
|
||||||
let bloburl;
|
let bloburl;
|
||||||
function done () {
|
function done () {
|
||||||
const obj = {datauri, bloburl, svg: str, issues, issueCodes, type: imgType, mimeType, quality, exportWindowName};
|
const obj = {
|
||||||
|
datauri, bloburl, svg, issues, issueCodes, type: imgType,
|
||||||
|
mimeType, quality, exportWindowName
|
||||||
|
};
|
||||||
call('exported', obj);
|
call('exported', obj);
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb(obj);
|
cb(obj);
|
||||||
@@ -3295,16 +3301,15 @@ this.exportPDF = function (exportWindowName, outputType, cb) {
|
|||||||
keywords: '',
|
keywords: '',
|
||||||
creator: '' */
|
creator: '' */
|
||||||
});
|
});
|
||||||
const issues = getIssues();
|
const {issues, issueCodes} = getIssues();
|
||||||
const issueCodes = getIssues({codesOnly: true});
|
const svg = that.svgCanvasToString();
|
||||||
const str = that.svgCanvasToString();
|
doc.addSVG(svg, 0, 0);
|
||||||
doc.addSVG(str, 0, 0);
|
|
||||||
|
|
||||||
// doc.output('save'); // Works to open in a new
|
// doc.output('save'); // Works to open in a new
|
||||||
// window; todo: configure this and other export
|
// window; todo: configure this and other export
|
||||||
// options to optionally work in this manner as
|
// options to optionally work in this manner as
|
||||||
// opposed to opening a new tab
|
// opposed to opening a new tab
|
||||||
const obj = {svg: str, issues, issueCodes, exportWindowName};
|
const obj = {svg, issues, issueCodes, exportWindowName};
|
||||||
const method = outputType || 'dataurlstring';
|
const method = outputType || 'dataurlstring';
|
||||||
obj[method] = doc.output(method);
|
obj[method] = doc.output(method);
|
||||||
if (cb) {
|
if (cb) {
|
||||||
|
|||||||
@@ -1179,7 +1179,7 @@ export const preventClickDefault = function (img) {
|
|||||||
/**
|
/**
|
||||||
* Create a clone of an element, updating its ID and its children's IDs when needed
|
* Create a clone of an element, updating its ID and its children's IDs when needed
|
||||||
* @param {Element} el - DOM element to clone
|
* @param {Element} el - DOM element to clone
|
||||||
* @param {function()} getNextId - function the get the next unique ID.
|
* @param {Function} getNextId - The getter of the next unique ID.
|
||||||
* @returns {Element}
|
* @returns {Element}
|
||||||
*/
|
*/
|
||||||
export const copyElem = function (el, getNextId) {
|
export const copyElem = function (el, getNextId) {
|
||||||
|
|||||||
Reference in New Issue
Block a user