- Docs: Exclude from jsdoc firefox-extension, opera-widget, screencasts, test folders and build.html.js/rollup files

- Docs: Further JSDoc of methods
- Docs: Transfer some changes from ExtensionDocs on wiki (need to fully reconcile)
- Refactoring (minor): variadic args through ellipsis
This commit is contained in:
Brett Zamir
2018-05-31 16:07:44 +08:00
parent 96e089f930
commit a27a5d5637
10 changed files with 276 additions and 38 deletions

99
dist/index-es.js vendored
View File

@@ -17695,8 +17695,15 @@ var SvgCanvas = function SvgCanvas(container, config) {
return issues;
}
// Generates a Data URL based on the current image, then calls "exported"
// with an object including the string, image information, and any issues found
/**
* Generates a Data URL based on the current image, then calls "exported"
* with an object including the string, image information, and any issues found
* @param {String} [imgType="PNG"]
* @param {Number} [quality] Between 0 and 1
* @param {String} [exportWindowName]
* @param {Function} [cb]
* @returns {Promise}
*/
this.rasterExport = function (imgType, quality, exportWindowName, cb) {
var mimeType = 'image/' + imgType.toLowerCase();
var issues = getIssues();
@@ -17741,6 +17748,12 @@ var SvgCanvas = function SvgCanvas(container, config) {
});
};
/**
* @param {String} exportWindowName
* @param outputType Needed?
* @param {Function} cb
* @returns {Promise}
*/
this.exportPDF = function (exportWindowName, outputType, cb) {
var that = this;
return new Promise(function (resolve, reject) {
@@ -26708,11 +26721,16 @@ editor.init = function () {
$$b(opt).addClass('current').siblings().removeClass('current');
}
// This is a common function used when a tool has been clicked (chosen)
// It does several common things:
// - removes the tool_button_current class from whatever tool currently has it
// - hides any flyouts
// - adds the tool_button_current class to the button passed in
/**
* This is a common function used when a tool has been clicked (chosen)
* It does several common things:
* - removes the `tool_button_current` class from whatever tool currently has it
* - hides any flyouts
* - adds the `tool_button_current` class to the button passed in
* @param {String|Element} button The DOM element or string selector representing the toolbar button
* @param {Boolean} noHiding Whether not to hide any flyouts
* @returns {Boolean} Whether the button was disabled or not
*/
var toolButtonClick = editor.toolButtonClick = function (button, noHiding) {
if ($$b(button).hasClass('disabled')) {
return false;
@@ -26731,6 +26749,10 @@ editor.init = function () {
return true;
};
/**
* Unless the select toolbar button is disabled, sets the button
* and sets the select mode and cursor styles.
*/
var clickSelect = editor.clickSelect = function () {
if (toolButtonClick('#tool_select')) {
svgCanvas.setMode('select');
@@ -26738,6 +26760,10 @@ editor.init = function () {
}
};
/**
* Set a selected image's URL
* @param {String} url
*/
var setImageURL = editor.setImageURL = function (url) {
if (!url) {
url = defaultImageURL;
@@ -26949,6 +26975,10 @@ editor.init = function () {
}
}
/**
* @param center
* @param newCtr
*/
var updateCanvas = editor.updateCanvas = function (center, newCtr) {
var zoom = svgCanvas.getZoom();
var wArea = workarea;
@@ -28509,6 +28539,9 @@ editor.init = function () {
}
});
/**
* @param {Boolean} active
*/
editor.setPanning = function (active) {
svgCanvas.spaceKey = keypan = active;
};
@@ -28595,10 +28628,15 @@ editor.init = function () {
})();
// Made public for UI customization.
// TODO: Group UI functions into a public editor.ui interface.
/**
* @param {Element|String} elem DOM Element or selector
* @param {Function} callback Mouseup callback
* @param {Boolean} dropUp
*/
editor.addDropDown = function (elem, callback, dropUp) {
if (!$$b(elem).length) {
return;
} // Quit if called on non-existant element
} // Quit if called on non-existent element
var button = $$b(elem).find('button');
var list = $$b(elem).find('ul').attr('id', $$b(elem)[0].id + '-list');
if (dropUp) {
@@ -29263,6 +29301,9 @@ editor.init = function () {
hideDocProperties();
};
/**
* Save user preferences based on current values in the UI
*/
var savePreferences = editor.savePreferences = function () {
// Set background
var color = $$b('#bg_blocks div.cur_background').css('background-color') || '#FFF';
@@ -30347,10 +30388,16 @@ editor.init = function () {
}
}, false);
/**
* Expose the uiStrings
*/
editor.canvas.getUIStrings = function () {
return uiStrings$1;
};
/**
* @param {Function} func Confirmation dialog callback
*/
editor.openPrep = function (func) {
$$b('#main_menu').hide();
if (undoMgr.getUndoStackSize() === 0) {
@@ -30491,6 +30538,10 @@ editor.init = function () {
// revnums += svgCanvas.getVersion();
// $('#copyright')[0].setAttribute('title', revnums);
/**
* @param {String} lang The language code
* @param {Object} allStrings
*/
var setLang = editor.setLang = function (lang, allStrings) {
editor.langChanged = true;
$$b.pref('lang', lang);
@@ -30561,6 +30612,12 @@ editor.init = function () {
}
};
/**
* Queues a callback to be invoked when the editor is ready (or
* to be invoked immediately if it is already ready)--i.e.,
* once all callbacks set by `svgEditor.runCallbacks` have been run
* @param {Function} cb Callback to be queued to invoke
*/
editor.ready = function (cb) {
if (!isReady) {
callbacks.push(cb);
@@ -30569,6 +30626,9 @@ editor.ready = function (cb) {
}
};
/**
* Invokes the callbacks previous set by `svgEditor.ready`
*/
editor.runCallbacks = function () {
// Todo: See if there is any benefit to refactoring some
// of the existing `editor.ready()` calls to return Promises
@@ -30579,12 +30639,19 @@ editor.runCallbacks = function () {
});
};
/**
* @param {String} str The SVG string to load
*/
editor.loadFromString = function (str) {
editor.ready(function () {
loadSvgString(str);
});
};
/**
* Not presently in use
* @param featList
*/
editor.disableUI = function (featList) {
// $(function () {
// $('#tool_wireframe, #tool_image, #main_button, #tool_source, #sidepanels').remove();
@@ -30592,6 +30659,10 @@ editor.disableUI = function (featList) {
// });
};
/**
* @param url URL from which to load an SVG string via Ajax
* @param {Object} [opts] May contain properties: `cache`, `callback` (invoked with `true` or `false` depending on success)
*/
editor.loadFromURL = function (url, opts) {
if (!opts) {
opts = {};
@@ -30627,6 +30698,9 @@ editor.loadFromURL = function (url, opts) {
});
};
/**
* @param {String} str The Data URI to base64-decode (if relevant) and load
*/
editor.loadFromDataURI = function (str) {
editor.ready(function () {
var base64 = false;
@@ -30644,13 +30718,18 @@ editor.loadFromDataURI = function (str) {
});
};
/**
* @param {...*} args Arguments to pass to `svgCanvas.addExtension` (though invoked on `svgEditor`)
*/
editor.addExtension = function () {
var args = arguments;
// Note that we don't want this on editor.ready since some extensions
// may want to run before then (like server_opensave).
// $(function () {
if (svgCanvas) {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
svgCanvas.addExtension.apply(this, args);
}
// });

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

99
dist/index-umd.js vendored
View File

@@ -17701,8 +17701,15 @@
return issues;
}
// Generates a Data URL based on the current image, then calls "exported"
// with an object including the string, image information, and any issues found
/**
* Generates a Data URL based on the current image, then calls "exported"
* with an object including the string, image information, and any issues found
* @param {String} [imgType="PNG"]
* @param {Number} [quality] Between 0 and 1
* @param {String} [exportWindowName]
* @param {Function} [cb]
* @returns {Promise}
*/
this.rasterExport = function (imgType, quality, exportWindowName, cb) {
var mimeType = 'image/' + imgType.toLowerCase();
var issues = getIssues();
@@ -17747,6 +17754,12 @@
});
};
/**
* @param {String} exportWindowName
* @param outputType Needed?
* @param {Function} cb
* @returns {Promise}
*/
this.exportPDF = function (exportWindowName, outputType, cb) {
var that = this;
return new Promise(function (resolve, reject) {
@@ -26714,11 +26727,16 @@
$$b(opt).addClass('current').siblings().removeClass('current');
}
// This is a common function used when a tool has been clicked (chosen)
// It does several common things:
// - removes the tool_button_current class from whatever tool currently has it
// - hides any flyouts
// - adds the tool_button_current class to the button passed in
/**
* This is a common function used when a tool has been clicked (chosen)
* It does several common things:
* - removes the `tool_button_current` class from whatever tool currently has it
* - hides any flyouts
* - adds the `tool_button_current` class to the button passed in
* @param {String|Element} button The DOM element or string selector representing the toolbar button
* @param {Boolean} noHiding Whether not to hide any flyouts
* @returns {Boolean} Whether the button was disabled or not
*/
var toolButtonClick = editor.toolButtonClick = function (button, noHiding) {
if ($$b(button).hasClass('disabled')) {
return false;
@@ -26737,6 +26755,10 @@
return true;
};
/**
* Unless the select toolbar button is disabled, sets the button
* and sets the select mode and cursor styles.
*/
var clickSelect = editor.clickSelect = function () {
if (toolButtonClick('#tool_select')) {
svgCanvas.setMode('select');
@@ -26744,6 +26766,10 @@
}
};
/**
* Set a selected image's URL
* @param {String} url
*/
var setImageURL = editor.setImageURL = function (url) {
if (!url) {
url = defaultImageURL;
@@ -26955,6 +26981,10 @@
}
}
/**
* @param center
* @param newCtr
*/
var updateCanvas = editor.updateCanvas = function (center, newCtr) {
var zoom = svgCanvas.getZoom();
var wArea = workarea;
@@ -28515,6 +28545,9 @@
}
});
/**
* @param {Boolean} active
*/
editor.setPanning = function (active) {
svgCanvas.spaceKey = keypan = active;
};
@@ -28601,10 +28634,15 @@
})();
// Made public for UI customization.
// TODO: Group UI functions into a public editor.ui interface.
/**
* @param {Element|String} elem DOM Element or selector
* @param {Function} callback Mouseup callback
* @param {Boolean} dropUp
*/
editor.addDropDown = function (elem, callback, dropUp) {
if (!$$b(elem).length) {
return;
} // Quit if called on non-existant element
} // Quit if called on non-existent element
var button = $$b(elem).find('button');
var list = $$b(elem).find('ul').attr('id', $$b(elem)[0].id + '-list');
if (dropUp) {
@@ -29269,6 +29307,9 @@
hideDocProperties();
};
/**
* Save user preferences based on current values in the UI
*/
var savePreferences = editor.savePreferences = function () {
// Set background
var color = $$b('#bg_blocks div.cur_background').css('background-color') || '#FFF';
@@ -30353,10 +30394,16 @@
}
}, false);
/**
* Expose the uiStrings
*/
editor.canvas.getUIStrings = function () {
return uiStrings$1;
};
/**
* @param {Function} func Confirmation dialog callback
*/
editor.openPrep = function (func) {
$$b('#main_menu').hide();
if (undoMgr.getUndoStackSize() === 0) {
@@ -30497,6 +30544,10 @@
// revnums += svgCanvas.getVersion();
// $('#copyright')[0].setAttribute('title', revnums);
/**
* @param {String} lang The language code
* @param {Object} allStrings
*/
var setLang = editor.setLang = function (lang, allStrings) {
editor.langChanged = true;
$$b.pref('lang', lang);
@@ -30567,6 +30618,12 @@
}
};
/**
* Queues a callback to be invoked when the editor is ready (or
* to be invoked immediately if it is already ready)--i.e.,
* once all callbacks set by `svgEditor.runCallbacks` have been run
* @param {Function} cb Callback to be queued to invoke
*/
editor.ready = function (cb) {
if (!isReady) {
callbacks.push(cb);
@@ -30575,6 +30632,9 @@
}
};
/**
* Invokes the callbacks previous set by `svgEditor.ready`
*/
editor.runCallbacks = function () {
// Todo: See if there is any benefit to refactoring some
// of the existing `editor.ready()` calls to return Promises
@@ -30585,12 +30645,19 @@
});
};
/**
* @param {String} str The SVG string to load
*/
editor.loadFromString = function (str) {
editor.ready(function () {
loadSvgString(str);
});
};
/**
* Not presently in use
* @param featList
*/
editor.disableUI = function (featList) {
// $(function () {
// $('#tool_wireframe, #tool_image, #main_button, #tool_source, #sidepanels').remove();
@@ -30598,6 +30665,10 @@
// });
};
/**
* @param url URL from which to load an SVG string via Ajax
* @param {Object} [opts] May contain properties: `cache`, `callback` (invoked with `true` or `false` depending on success)
*/
editor.loadFromURL = function (url, opts) {
if (!opts) {
opts = {};
@@ -30633,6 +30704,9 @@
});
};
/**
* @param {String} str The Data URI to base64-decode (if relevant) and load
*/
editor.loadFromDataURI = function (str) {
editor.ready(function () {
var base64 = false;
@@ -30650,13 +30724,18 @@
});
};
/**
* @param {...*} args Arguments to pass to `svgCanvas.addExtension` (though invoked on `svgEditor`)
*/
editor.addExtension = function () {
var args = arguments;
// Note that we don't want this on editor.ready since some extensions
// may want to run before then (like server_opensave).
// $(function () {
if (svgCanvas) {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
svgCanvas.addExtension.apply(this, args);
}
// });

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long