diff --git a/src/editor/Editor.js b/src/editor/Editor.js index 2b3887e4..c5e58ff8 100644 --- a/src/editor/Editor.js +++ b/src/editor/Editor.js @@ -180,38 +180,6 @@ class Editor extends EditorStartup { * @returns {void} */ - /** - * Allows one to override default SVGEdit `open`, `save`, and - * `export` editor behaviors. - * @function module:SVGthis.setCustomHandlers - * @param {module:SVGthis.CustomHandler} opts Extension mechanisms may call `setCustomHandlers` with three functions: `opts.open`, `opts.save`, and `opts.exportImage` - * @returns {Promise} - */ - - /** - * @param {PlainObject} opts - * @returns {Promise} - */ - setCustomHandlers(opts) { - return this.ready(() => { - if (opts.open) { - this.svgCanvas.open = opts.open.bind(this); - } - if (opts.save) { - this.showSaveWarning = false; - this.svgCanvas.bind('saved', opts.save.bind(this)); - } - if (opts.exportImage) { - this.customExportImage = opts.exportImage.bind(this); - this.svgCanvas.bind('exported', this.customExportImage); // canvg and our RGBColor will be available to the method - } - if (opts.exportPDF) { - this.customExportPDF = opts.exportPDF.bind(this); - this.svgCanvas.bind('exportedPDF', this.customExportPDF); // jsPDF and our RGBColor will be available to the method - } - }); - } - /** * @function module:SVGthis.randomizeIds * @param {boolean} arg diff --git a/src/editor/extensions/ext-opensave/ext-opensave.js b/src/editor/extensions/ext-opensave/ext-opensave.js index f2a63654..673fe2da 100644 --- a/src/editor/extensions/ext-opensave/ext-opensave.js +++ b/src/editor/extensions/ext-opensave/ext-opensave.js @@ -163,13 +163,13 @@ export default { callback() { // eslint-disable-next-line no-unsanitized/property const buttonTemplate = ` - `; + `; svgCanvas.insertChildAtIndex($id('main_button'), buttonTemplate, 0); - const openButtonTemplate = ``; + const openButtonTemplate = ``; svgCanvas.insertChildAtIndex($id('main_button'), openButtonTemplate, 1); - const saveButtonTemplate = ``; + const saveButtonTemplate = ``; svgCanvas.insertChildAtIndex($id('main_button'), saveButtonTemplate, 2); - const saveAsButtonTemplate = ``; + const saveAsButtonTemplate = ``; svgCanvas.insertChildAtIndex($id('main_button'), saveAsButtonTemplate, 3); // handler $id("tool_clear").addEventListener("click", clickClear.bind(this)); diff --git a/src/editor/extensions/ext-opensave/locale/en.js b/src/editor/extensions/ext-opensave/locale/en.js index 97d17015..bedd8cf0 100644 --- a/src/editor/extensions/ext-opensave/locale/en.js +++ b/src/editor/extensions/ext-opensave/locale/en.js @@ -1,7 +1,7 @@ export default { - tools: { + opensave: { new_doc: 'New Image', - open_doc: 'Open SVG', + open_image_doc: 'Open SVG', save_doc: 'Save SVG', save_as_doc: 'Save as SVG' } diff --git a/src/editor/extensions/ext-opensave/locale/fr.js b/src/editor/extensions/ext-opensave/locale/fr.js index 3bd1f6b6..7704f6d6 100644 --- a/src/editor/extensions/ext-opensave/locale/fr.js +++ b/src/editor/extensions/ext-opensave/locale/fr.js @@ -1,7 +1,7 @@ export default { - tools: { + opensave: { new_doc: 'Nouvelle image', - open_doc: 'Ouvrir le SVG', + open_image_doc: 'Ouvrir le SVG', save_doc: 'Enregistrer l\'image', save_as_doc: 'Enregistrer en tant qu\'image' } diff --git a/src/editor/extensions/ext-opensave/locale/zh-CN.js b/src/editor/extensions/ext-opensave/locale/zh-CN.js index f476b903..c1f47c07 100755 --- a/src/editor/extensions/ext-opensave/locale/zh-CN.js +++ b/src/editor/extensions/ext-opensave/locale/zh-CN.js @@ -1,7 +1,7 @@ export default { - tools: { + opensave: { new_doc: '新图片', - open_doc: '打开 SVG', + open_image_doc: '打开 SVG', save_doc: '保存图像', save_as_doc: '另存为图像' } diff --git a/src/svgcanvas/svg-exec.js b/src/svgcanvas/svg-exec.js index a18daa43..53de4c22 100644 --- a/src/svgcanvas/svg-exec.js +++ b/src/svgcanvas/svg-exec.js @@ -678,31 +678,6 @@ export const embedImage = function (src) { }); }; -/** -* Serializes the current drawing into SVG XML text and passes it to the 'saved' handler. -* This function also includes the XML prolog. Clients of the `SvgCanvas` bind their save -* function to the 'saved' event. -* @function module:svgcanvas.SvgCanvas#save -* @param {module:svgcanvas.SaveOptions} opts -* @fires module:svgcanvas.SvgCanvas#event:saved -* @returns {void} -*/ -export const save = function (opts) { - // remove the selected outline before serializing - svgCanvas.clearSelection(); - // Update save options if provided - if (opts) { - const saveOptions = svgCanvas.mergeDeep(svgContext_.getSvgOption(), opts); - for (const [ key, value ] of Object.entries(saveOptions)) { - svgContext_.setSvgOption(key, value); - } - } - svgContext_.setSvgOption('apply', true); - - // no need for doctype, see https://jwatt.org/svg/authoring/#doctype-declaration - const str = svgCanvas.svgCanvasToString(); - svgContext_.call('saved', str); -}; /** * @typedef {PlainObject} module:svgcanvas.IssuesAndCodes * @property {string[]} issueCodes The locale-independent code names diff --git a/src/svgcanvas/svgcanvas.js b/src/svgcanvas/svgcanvas.js index 5a6bc41f..255df02a 100644 --- a/src/svgcanvas/svgcanvas.js +++ b/src/svgcanvas/svgcanvas.js @@ -80,7 +80,7 @@ import { convertToNum, getTypeMap, init as unitsInit } from '../common/units.js'; import { - svgCanvasToString, svgToString, setSvgString, save, exportPDF, setUseDataMethod, + svgCanvasToString, svgToString, setSvgString, exportPDF, setUseDataMethod, init as svgInit, importSvgString, embedImage, rasterExport, uniquifyElemsMethod, removeUnusedDefElemsMethod, convertGradientsMethod } from './svg-exec.js'; @@ -1452,26 +1452,6 @@ class SvgCanvas { lastGoodImgUrl = val; }; - /** -* Does nothing by default, handled by optional widget/extension. -* @function module:svgcanvas.SvgCanvas#open -* @returns {void} -*/ - this.open = function () { - /* empty fn */ - }; - - /** -* Serializes the current drawing into SVG XML text and passes it to the 'saved' handler. -* This function also includes the XML prolog. Clients of the `SvgCanvas` bind their save -* function to the 'saved' event. -* @function module:svgcanvas.SvgCanvas#save -* @param {module:svgcanvas.SaveOptions} opts -* @fires module:svgcanvas.SvgCanvas#event:saved -* @returns {void} -*/ - this.save = save; - /** * @typedef {PlainObject} module:svgcanvas.IssuesAndCodes * @property {string[]} issueCodes The locale-independent code names