#603 unwanted function removed and translate changes
parent
d2c6729d7b
commit
f908f9b8a1
|
@ -180,38 +180,6 @@ class Editor extends EditorStartup {
|
||||||
* @returns {void}
|
* @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<void>}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {PlainObject} opts
|
|
||||||
* @returns {Promise<PlainObject>}
|
|
||||||
*/
|
|
||||||
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
|
* @function module:SVGthis.randomizeIds
|
||||||
* @param {boolean} arg
|
* @param {boolean} arg
|
||||||
|
|
|
@ -163,13 +163,13 @@ export default {
|
||||||
callback() {
|
callback() {
|
||||||
// eslint-disable-next-line no-unsanitized/property
|
// eslint-disable-next-line no-unsanitized/property
|
||||||
const buttonTemplate = `
|
const buttonTemplate = `
|
||||||
<se-menu-item id="tool_clear" label="${svgEditor.i18next.t('tools.new_doc')}" shortcut="N" src="${imgPath}/new.svg"></se-menu-item>`;
|
<se-menu-item id="tool_clear" label="${svgEditor.i18next.t('opensave.new_doc')}" shortcut="N" src="${imgPath}/new.svg"></se-menu-item>`;
|
||||||
svgCanvas.insertChildAtIndex($id('main_button'), buttonTemplate, 0);
|
svgCanvas.insertChildAtIndex($id('main_button'), buttonTemplate, 0);
|
||||||
const openButtonTemplate = `<se-menu-item id="tool_open" label="${svgEditor.i18next.t('tools.open_doc')}" src="${imgPath}/open.svg"></se-menu-item>`;
|
const openButtonTemplate = `<se-menu-item id="tool_open" label="${svgEditor.i18next.t('opensave.open_image_doc')}" src="${imgPath}/open.svg"></se-menu-item>`;
|
||||||
svgCanvas.insertChildAtIndex($id('main_button'), openButtonTemplate, 1);
|
svgCanvas.insertChildAtIndex($id('main_button'), openButtonTemplate, 1);
|
||||||
const saveButtonTemplate = `<se-menu-item id="tool_save" label="${svgEditor.i18next.t('tools.save_doc')}" shortcut="S" src="${imgPath}/saveImg.svg"></se-menu-item>`;
|
const saveButtonTemplate = `<se-menu-item id="tool_save" label="${svgEditor.i18next.t('opensave.save_doc')}" shortcut="S" src="${imgPath}/saveImg.svg"></se-menu-item>`;
|
||||||
svgCanvas.insertChildAtIndex($id('main_button'), saveButtonTemplate, 2);
|
svgCanvas.insertChildAtIndex($id('main_button'), saveButtonTemplate, 2);
|
||||||
const saveAsButtonTemplate = `<se-menu-item id="tool_save_as" label="${svgEditor.i18next.t('tools.save_as_doc')}" src="${imgPath}/saveImg.svg"></se-menu-item>`;
|
const saveAsButtonTemplate = `<se-menu-item id="tool_save_as" label="${svgEditor.i18next.t('opensave.save_as_doc')}" src="${imgPath}/saveImg.svg"></se-menu-item>`;
|
||||||
svgCanvas.insertChildAtIndex($id('main_button'), saveAsButtonTemplate, 3);
|
svgCanvas.insertChildAtIndex($id('main_button'), saveAsButtonTemplate, 3);
|
||||||
// handler
|
// handler
|
||||||
$id("tool_clear").addEventListener("click", clickClear.bind(this));
|
$id("tool_clear").addEventListener("click", clickClear.bind(this));
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
export default {
|
export default {
|
||||||
tools: {
|
opensave: {
|
||||||
new_doc: 'New Image',
|
new_doc: 'New Image',
|
||||||
open_doc: 'Open SVG',
|
open_image_doc: 'Open SVG',
|
||||||
save_doc: 'Save SVG',
|
save_doc: 'Save SVG',
|
||||||
save_as_doc: 'Save as SVG'
|
save_as_doc: 'Save as SVG'
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
export default {
|
export default {
|
||||||
tools: {
|
opensave: {
|
||||||
new_doc: 'Nouvelle image',
|
new_doc: 'Nouvelle image',
|
||||||
open_doc: 'Ouvrir le SVG',
|
open_image_doc: 'Ouvrir le SVG',
|
||||||
save_doc: 'Enregistrer l\'image',
|
save_doc: 'Enregistrer l\'image',
|
||||||
save_as_doc: 'Enregistrer en tant qu\'image'
|
save_as_doc: 'Enregistrer en tant qu\'image'
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
export default {
|
export default {
|
||||||
tools: {
|
opensave: {
|
||||||
new_doc: '新图片',
|
new_doc: '新图片',
|
||||||
open_doc: '打开 SVG',
|
open_image_doc: '打开 SVG',
|
||||||
save_doc: '保存图像',
|
save_doc: '保存图像',
|
||||||
save_as_doc: '另存为图像'
|
save_as_doc: '另存为图像'
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
* @typedef {PlainObject} module:svgcanvas.IssuesAndCodes
|
||||||
* @property {string[]} issueCodes The locale-independent code names
|
* @property {string[]} issueCodes The locale-independent code names
|
||||||
|
|
|
@ -80,7 +80,7 @@ import {
|
||||||
convertToNum, getTypeMap, init as unitsInit
|
convertToNum, getTypeMap, init as unitsInit
|
||||||
} from '../common/units.js';
|
} from '../common/units.js';
|
||||||
import {
|
import {
|
||||||
svgCanvasToString, svgToString, setSvgString, save, exportPDF, setUseDataMethod,
|
svgCanvasToString, svgToString, setSvgString, exportPDF, setUseDataMethod,
|
||||||
init as svgInit, importSvgString, embedImage, rasterExport,
|
init as svgInit, importSvgString, embedImage, rasterExport,
|
||||||
uniquifyElemsMethod, removeUnusedDefElemsMethod, convertGradientsMethod
|
uniquifyElemsMethod, removeUnusedDefElemsMethod, convertGradientsMethod
|
||||||
} from './svg-exec.js';
|
} from './svg-exec.js';
|
||||||
|
@ -1452,26 +1452,6 @@ class SvgCanvas {
|
||||||
lastGoodImgUrl = val;
|
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
|
* @typedef {PlainObject} module:svgcanvas.IssuesAndCodes
|
||||||
* @property {string[]} issueCodes The locale-independent code names
|
* @property {string[]} issueCodes The locale-independent code names
|
||||||
|
|
Loading…
Reference in New Issue