svgedit-pl 7.3.6 → 7.3.7
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.
- package/dist/editor/Editor.js +2 -2
- package/dist/editor/Editor.js.map +1 -1
- package/dist/editor/extensions/ext-opensave/ext-opensave.js +1 -1
- package/dist/editor/extensions/ext-opensave/ext-opensave.js.map +1 -1
- package/dist/editor/extensions/ext-panning/ext-panning.js +1 -1
- package/dist/editor/extensions/ext-panning/ext-panning.js.map +1 -1
- package/dist/editor/extensions/ext-storage/ext-storage.js +1 -1
- package/dist/editor/extensions/ext-storage/ext-storage.js.map +1 -1
- package/dist/editor/iife-Editor.js +2 -2
- package/dist/editor/iife-Editor.js.map +1 -1
- package/dist/editor/xdomain-Editor.js +2 -2
- package/dist/editor/xdomain-Editor.js.map +1 -1
- package/docs/jsdoc/BottomPanel.html +1 -1
- package/docs/jsdoc/ConfigObj.js.html +1 -1
- package/docs/jsdoc/Dropdown.html +1 -1
- package/docs/jsdoc/Editor.js.html +54 -55
- package/docs/jsdoc/EditorStartup.html +5 -5
- package/docs/jsdoc/EditorStartup.js.html +12 -11
- package/docs/jsdoc/ElixMenuButton.html +1 -1
- package/docs/jsdoc/ElixNumberSpinBox.html +1 -1
- package/docs/jsdoc/ExplorerButton.html +1 -1
- package/docs/jsdoc/FlyingButton.html +1 -1
- package/docs/jsdoc/LayersPanel.html +1 -1
- package/docs/jsdoc/LeftPanel.html +1 -1
- package/docs/jsdoc/MainMenu.html +1 -1
- package/docs/jsdoc/MainMenu.js.html +1 -1
- package/docs/jsdoc/NumberSpinBox.html +1 -1
- package/docs/jsdoc/PaintBox.html +1 -1
- package/docs/jsdoc/PlainNumberSpinBox.html +1 -1
- package/docs/jsdoc/Rulers.html +1 -1
- package/docs/jsdoc/Rulers.js.html +1 -1
- package/docs/jsdoc/SEInput.html +1 -1
- package/docs/jsdoc/SEPalette.html +1 -1
- package/docs/jsdoc/SESpinInput.html +1 -1
- package/docs/jsdoc/SeCMenuDialog.html +1 -1
- package/docs/jsdoc/SeCMenuLayerDialog.html +1 -1
- package/docs/jsdoc/SeColorPicker.html +1 -1
- package/docs/jsdoc/SeEditPrefsDialog.html +1 -1
- package/docs/jsdoc/SeExportDialog.html +1 -1
- package/docs/jsdoc/SeImgPropDialog.html +1 -1
- package/docs/jsdoc/SeList.html +1 -1
- package/docs/jsdoc/SeMenu.html +1 -1
- package/docs/jsdoc/SeMenuItem.html +1 -1
- package/docs/jsdoc/SePlainAlertDialog.html +1 -1
- package/docs/jsdoc/SePlainBorderButton.html +1 -1
- package/docs/jsdoc/SePromptDialog.html +1 -1
- package/docs/jsdoc/SeStorageDialog.html +1 -1
- package/docs/jsdoc/SeSvgSourceEditorDialog.html +1 -1
- package/docs/jsdoc/SeText.html +1 -1
- package/docs/jsdoc/ToolButton.html +1 -1
- package/docs/jsdoc/TopPanel.html +1 -1
- package/docs/jsdoc/components_PaintBox.js.html +1 -1
- package/docs/jsdoc/components_jgraduate_ColorValuePicker.js.html +1 -1
- package/docs/jsdoc/components_jgraduate_Slider.js.html +1 -1
- package/docs/jsdoc/components_jgraduate_jQuery.jGraduate.js.html +1 -1
- package/docs/jsdoc/components_jgraduate_jQuery.jPicker.js.html +1 -1
- package/docs/jsdoc/components_seButton.js.html +1 -1
- package/docs/jsdoc/components_seColorPicker.js.html +1 -1
- package/docs/jsdoc/components_seDropdown.js.html +1 -1
- package/docs/jsdoc/components_seExplorerButton.js.html +1 -1
- package/docs/jsdoc/components_seFlyingButton.js.html +1 -1
- package/docs/jsdoc/components_seInput.js.html +1 -1
- package/docs/jsdoc/components_seList.js.html +1 -1
- package/docs/jsdoc/components_seListItem.js.html +1 -1
- package/docs/jsdoc/components_seMenu.js.html +1 -1
- package/docs/jsdoc/components_seMenuItem.js.html +1 -1
- package/docs/jsdoc/components_sePalette.js.html +1 -1
- package/docs/jsdoc/components_sePlainBorderButton.js.html +1 -1
- package/docs/jsdoc/components_sePlainMenuButton.js.html +1 -1
- package/docs/jsdoc/components_seSelect.js.html +1 -1
- package/docs/jsdoc/components_seSpinInput.js.html +1 -1
- package/docs/jsdoc/components_seText.js.html +1 -1
- package/docs/jsdoc/components_seZoom.js.html +1 -1
- package/docs/jsdoc/configObj.html +1 -1
- package/docs/jsdoc/contextmenu.js.html +1 -1
- package/docs/jsdoc/dialogs_SePlainAlertDialog.js.html +1 -1
- package/docs/jsdoc/dialogs_cmenuDialog.js.html +1 -1
- package/docs/jsdoc/dialogs_cmenuLayersDialog.js.html +1 -1
- package/docs/jsdoc/dialogs_editorPreferencesDialog.js.html +1 -1
- package/docs/jsdoc/dialogs_exportDialog.js.html +1 -1
- package/docs/jsdoc/dialogs_imagePropertiesDialog.js.html +1 -1
- package/docs/jsdoc/dialogs_se-elix_define_NumberSpinBox.js.html +1 -1
- package/docs/jsdoc/dialogs_se-elix_src_base_NumberSpinBox.js.html +1 -1
- package/docs/jsdoc/dialogs_se-elix_src_plain_PlainNumberSpinBox.js.html +1 -1
- package/docs/jsdoc/dialogs_sePromptDialog.js.html +1 -1
- package/docs/jsdoc/dialogs_svgSourceDialog.js.html +1 -1
- package/docs/jsdoc/extensions_ext-connector_ext-connector.js.html +1 -1
- package/docs/jsdoc/extensions_ext-eyedropper_ext-eyedropper.js.html +1 -1
- package/docs/jsdoc/extensions_ext-grid_ext-grid.js.html +1 -1
- package/docs/jsdoc/extensions_ext-helloworld_ext-helloworld.js.html +1 -1
- package/docs/jsdoc/extensions_ext-layer_view_ext-layer_view.js.html +1 -1
- package/docs/jsdoc/extensions_ext-markers_ext-markers.js.html +1 -1
- package/docs/jsdoc/extensions_ext-opensave_ext-opensave.js.html +5 -5
- package/docs/jsdoc/extensions_ext-overview_window_ext-overview_window.js.html +1 -1
- package/docs/jsdoc/extensions_ext-panning_ext-panning.js.html +6 -6
- package/docs/jsdoc/extensions_ext-polystar_ext-polystar.js.html +1 -1
- package/docs/jsdoc/extensions_ext-shapes_ext-shapes.js.html +1 -1
- package/docs/jsdoc/extensions_ext-storage_ext-storage.js.html +7 -4
- package/docs/jsdoc/extensions_ext-storage_storageDialog.js.html +1 -1
- package/docs/jsdoc/external-JamilihArray.html +1 -1
- package/docs/jsdoc/external-Math.html +1 -1
- package/docs/jsdoc/external-Window.html +1 -1
- package/docs/jsdoc/external-jQuery.fn.$.fn.jPicker.defaults.html +1 -1
- package/docs/jsdoc/external-jQuery.fn.exports.jPickerMethod.html +1 -1
- package/docs/jsdoc/external-jQuery.fn.html +1 -1
- package/docs/jsdoc/external-jQuery.fn.jGraduateDefaults.html +1 -1
- package/docs/jsdoc/external-jQuery.fn.jGraduateDefaults.images.html +1 -1
- package/docs/jsdoc/external-jQuery.fn.jGraduateDefaults.window.html +1 -1
- package/docs/jsdoc/external-jQuery.html +1 -1
- package/docs/jsdoc/external-jQuery.jGraduate.Paint.html +1 -1
- package/docs/jsdoc/external-jQuery.jGraduate.html +1 -1
- package/docs/jsdoc/external-jQuery.jPicker.Color.html +1 -1
- package/docs/jsdoc/external-jQuery.jPicker.ColorMethods.html +1 -1
- package/docs/jsdoc/external-jQuery.jPicker.html +1 -1
- package/docs/jsdoc/global.html +1 -1
- package/docs/jsdoc/index.html +1 -1
- package/docs/jsdoc/locale.js.html +1 -1
- package/docs/jsdoc/module-SVGEditor-Editor.html +30 -30
- package/docs/jsdoc/module-SVGEditor.Config.html +1 -1
- package/docs/jsdoc/module-SVGEditor.Prefs.html +1 -1
- package/docs/jsdoc/module-SVGEditor.html +3 -3
- package/docs/jsdoc/module-SVGthis.CustomHandler.html +1 -1
- package/docs/jsdoc/module-contextmenu.html +1 -1
- package/docs/jsdoc/module-jGraduate.html +1 -1
- package/docs/jsdoc/module-jPicker.html +1 -1
- package/docs/jsdoc/module-jPicker.module.exports.html +1 -1
- package/docs/jsdoc/module-locale.LocaleEditorInit.html +1 -1
- package/docs/jsdoc/module-locale.html +1 -1
- package/docs/jsdoc/module.exports.html +1 -1
- package/docs/jsdoc/module.exports_module.exports.html +1 -1
- package/docs/jsdoc/panels_BottomPanel.js.html +1 -1
- package/docs/jsdoc/panels_LayersPanel.js.html +1 -1
- package/docs/jsdoc/panels_LeftPanel.js.html +1 -1
- package/docs/jsdoc/panels_TopPanel.js.html +1 -1
- package/docs/jsdoc/tutorial-CanvasAPI.html +1 -1
- package/docs/jsdoc/tutorial-ConfigOptions.html +1 -1
- package/docs/jsdoc/tutorial-Editor.html +1 -1
- package/docs/jsdoc/tutorial-EditorAPI.html +1 -1
- package/docs/jsdoc/tutorial-Events.html +1 -1
- package/docs/jsdoc/tutorial-ExtensionDocs.html +1 -1
- package/docs/jsdoc/tutorial-FrequentlyAskedQuestions.html +1 -1
- package/docs/jsdoc/tutorial-LocaleDocs.html +1 -1
- package/docs/jsdoc/typedefs.js.html +1 -1
- package/package.json +1 -1
- package/src/editor/Editor.js +53 -54
- package/src/editor/EditorStartup.js +11 -10
- package/src/editor/extensions/ext-opensave/ext-opensave.js +4 -4
- package/src/editor/extensions/ext-panning/ext-panning.js +5 -5
- package/src/editor/extensions/ext-storage/ext-storage.js +6 -3
- package/src/editor/panels/TopPanel.html +1 -1
package/src/editor/Editor.js
CHANGED
|
@@ -37,7 +37,7 @@ class Editor extends EditorStartup {
|
|
|
37
37
|
/**
|
|
38
38
|
*
|
|
39
39
|
*/
|
|
40
|
-
constructor
|
|
40
|
+
constructor(div = null) {
|
|
41
41
|
super(div)
|
|
42
42
|
/**
|
|
43
43
|
* @type {boolean}
|
|
@@ -55,7 +55,7 @@ class Editor extends EditorStartup {
|
|
|
55
55
|
/**
|
|
56
56
|
* document title
|
|
57
57
|
*/
|
|
58
|
-
this.title = '
|
|
58
|
+
this.title = 'bez_tytulu.svg'
|
|
59
59
|
|
|
60
60
|
this.svgCanvas = null
|
|
61
61
|
this.$click = $click
|
|
@@ -332,7 +332,7 @@ class Editor extends EditorStartup {
|
|
|
332
332
|
* @throws {Error} Upon failure to load SVG
|
|
333
333
|
* @returns {void}
|
|
334
334
|
*/
|
|
335
|
-
loadSvgString
|
|
335
|
+
loadSvgString(str, { noAlert } = {}) {
|
|
336
336
|
const success = this.svgCanvas.setSvgString(str) !== false
|
|
337
337
|
if (success) {
|
|
338
338
|
this.updateCanvas()
|
|
@@ -393,7 +393,7 @@ class Editor extends EditorStartup {
|
|
|
393
393
|
* @param {boolean} arg
|
|
394
394
|
* @returns {void}
|
|
395
395
|
*/
|
|
396
|
-
randomizeIds
|
|
396
|
+
randomizeIds(arg) {
|
|
397
397
|
this.svgCanvas.randomizeIds(arg)
|
|
398
398
|
}
|
|
399
399
|
|
|
@@ -403,7 +403,7 @@ class Editor extends EditorStartup {
|
|
|
403
403
|
* editor shortcuts init
|
|
404
404
|
* @returns {void}
|
|
405
405
|
*/
|
|
406
|
-
setAll
|
|
406
|
+
setAll() {
|
|
407
407
|
const keyHandler = {} // will contain the action for each pressed key
|
|
408
408
|
|
|
409
409
|
this.shortcuts.forEach((shortcut) => {
|
|
@@ -431,9 +431,8 @@ class Editor extends EditorStartup {
|
|
|
431
431
|
// only track keyboard shortcuts for the body containing the SVG-Editor
|
|
432
432
|
if (e.target.nodeName !== 'BODY') return
|
|
433
433
|
// normalize key
|
|
434
|
-
const key = `${e.altKey ? 'alt+' : ''}${e.shiftKey ? 'shift+' : ''}${
|
|
435
|
-
e.
|
|
436
|
-
}${e.ctrlKey ? 'ctrl+' : ''}${e.key.toLowerCase()}`
|
|
434
|
+
const key = `${e.altKey ? 'alt+' : ''}${e.shiftKey ? 'shift+' : ''}${e.metaKey ? 'meta+' : ''
|
|
435
|
+
}${e.ctrlKey ? 'ctrl+' : ''}${e.key.toLowerCase()}`
|
|
437
436
|
// return if no shortcut defined for this key
|
|
438
437
|
if (!keyHandler[key]) return
|
|
439
438
|
// launch associated handler and preventDefault if necessary
|
|
@@ -460,7 +459,7 @@ class Editor extends EditorStartup {
|
|
|
460
459
|
}
|
|
461
460
|
|
|
462
461
|
// parents() https://stackoverflow.com/a/12981248
|
|
463
|
-
getParents
|
|
462
|
+
getParents(el, parentSelector /* optional */) {
|
|
464
463
|
// If no parentSelector defined will bubble up all the way to *document*
|
|
465
464
|
if (parentSelector === undefined) {
|
|
466
465
|
parentSelector = document
|
|
@@ -483,7 +482,7 @@ class Editor extends EditorStartup {
|
|
|
483
482
|
* @param {string} sel Selector to match
|
|
484
483
|
* @returns {module:SVGthis.ToolButton}
|
|
485
484
|
*/
|
|
486
|
-
getButtonData
|
|
485
|
+
getButtonData(sel) {
|
|
487
486
|
return Object.values(this.shortcuts).find((btn) => {
|
|
488
487
|
return btn.sel === sel
|
|
489
488
|
})
|
|
@@ -495,7 +494,7 @@ class Editor extends EditorStartup {
|
|
|
495
494
|
* @listens module:svgcanvas.SvgCanvas#event:exported
|
|
496
495
|
* @returns {void}
|
|
497
496
|
*/
|
|
498
|
-
exportHandler
|
|
497
|
+
exportHandler(win, data) {
|
|
499
498
|
const { issues, exportWindowName } = data
|
|
500
499
|
this.exportWindow = window.open('', exportWindowName) // A hack to get the window via JSON-able name without opening a new one
|
|
501
500
|
if (!this.exportWindow || this.exportWindow.closed) {
|
|
@@ -532,7 +531,7 @@ class Editor extends EditorStartup {
|
|
|
532
531
|
* @param {string} url
|
|
533
532
|
* @returns {void}
|
|
534
533
|
*/
|
|
535
|
-
setBackground
|
|
534
|
+
setBackground(color, url) {
|
|
536
535
|
// if (color == this.configObj.pref('bkgd_color') && url == this.configObj.pref('bkgd_url')) { return; }
|
|
537
536
|
this.configObj.pref('bkgd_color', color)
|
|
538
537
|
this.configObj.pref('bkgd_url', url, true)
|
|
@@ -547,7 +546,7 @@ class Editor extends EditorStartup {
|
|
|
547
546
|
* @param {module:math.XYObject} newCtr
|
|
548
547
|
* @returns {void}
|
|
549
548
|
*/
|
|
550
|
-
updateCanvas
|
|
549
|
+
updateCanvas(center, newCtr) {
|
|
551
550
|
const zoom = this.svgCanvas.getZoom()
|
|
552
551
|
const { workarea } = this
|
|
553
552
|
const cnvs = $id('svgcanvas')
|
|
@@ -641,7 +640,7 @@ class Editor extends EditorStartup {
|
|
|
641
640
|
*
|
|
642
641
|
* @returns {void}
|
|
643
642
|
*/
|
|
644
|
-
updateWireFrame
|
|
643
|
+
updateWireFrame() {
|
|
645
644
|
const rule = `
|
|
646
645
|
#workarea.wireframe #svgcontent * {
|
|
647
646
|
stroke-width: ${1 / this.svgCanvas.getZoom()}px;
|
|
@@ -662,7 +661,7 @@ class Editor extends EditorStartup {
|
|
|
662
661
|
* @fires module:svgcanvas.SvgCanvas#event:ext_selectedChanged
|
|
663
662
|
* @returns {void}
|
|
664
663
|
*/
|
|
665
|
-
selectedChanged
|
|
664
|
+
selectedChanged(win, elems) {
|
|
666
665
|
const mode = this.svgCanvas.getMode()
|
|
667
666
|
if (mode === 'select') {
|
|
668
667
|
this.leftPanel.clickSelect()
|
|
@@ -697,7 +696,7 @@ class Editor extends EditorStartup {
|
|
|
697
696
|
* @fires module:svgcanvas.SvgCanvas#event:ext_elementTransition
|
|
698
697
|
* @returns {void}
|
|
699
698
|
*/
|
|
700
|
-
elementTransition
|
|
699
|
+
elementTransition(win, elems) {
|
|
701
700
|
const mode = this.svgCanvas.getMode()
|
|
702
701
|
const elem = elems[0]
|
|
703
702
|
|
|
@@ -735,7 +734,7 @@ class Editor extends EditorStartup {
|
|
|
735
734
|
* @fires module:svgcanvas.SvgCanvas#event:ext_elementChanged
|
|
736
735
|
* @returns {void}
|
|
737
736
|
*/
|
|
738
|
-
elementChanged
|
|
737
|
+
elementChanged(win, elems) {
|
|
739
738
|
const mode = this.svgCanvas.getMode()
|
|
740
739
|
if (mode === 'select') {
|
|
741
740
|
this.leftPanel.clickSelect()
|
|
@@ -783,7 +782,7 @@ class Editor extends EditorStartup {
|
|
|
783
782
|
/**
|
|
784
783
|
* @returns {void}
|
|
785
784
|
*/
|
|
786
|
-
elementRenamed
|
|
785
|
+
elementRenamed(win, renameObj) {
|
|
787
786
|
this.svgCanvas.runExtensions(
|
|
788
787
|
'elementRenamed',
|
|
789
788
|
/** @type {module:svgcanvas.SvgCanvas#event:ext_elementRenamed} */ {
|
|
@@ -795,21 +794,21 @@ class Editor extends EditorStartup {
|
|
|
795
794
|
/**
|
|
796
795
|
* @returns {void}
|
|
797
796
|
*/
|
|
798
|
-
afterClear
|
|
797
|
+
afterClear(win) {
|
|
799
798
|
this.svgCanvas.runExtensions('afterClear')
|
|
800
799
|
}
|
|
801
800
|
|
|
802
801
|
/**
|
|
803
802
|
* @returns {void}
|
|
804
803
|
*/
|
|
805
|
-
beforeClear
|
|
804
|
+
beforeClear(win) {
|
|
806
805
|
this.svgCanvas.runExtensions('beforeClear')
|
|
807
806
|
}
|
|
808
807
|
|
|
809
808
|
/**
|
|
810
809
|
* @returns {void}
|
|
811
810
|
*/
|
|
812
|
-
zoomDone
|
|
811
|
+
zoomDone() {
|
|
813
812
|
for (const el of this.svgCanvas.selectedElements) {
|
|
814
813
|
this.svgCanvas.selectorManager.requestSelector(el).resize()
|
|
815
814
|
}
|
|
@@ -836,7 +835,7 @@ class Editor extends EditorStartup {
|
|
|
836
835
|
* @fires module:svgcanvas.SvgCanvas#event:ext_zoomChanged
|
|
837
836
|
* @returns {void}
|
|
838
837
|
*/
|
|
839
|
-
zoomChanged
|
|
838
|
+
zoomChanged(win, bbox, autoCenter) {
|
|
840
839
|
const scrbar = 15
|
|
841
840
|
const zInfo = this.svgCanvas.setBBoxZoom(
|
|
842
841
|
bbox,
|
|
@@ -888,7 +887,7 @@ class Editor extends EditorStartup {
|
|
|
888
887
|
* @listens module:svgcanvas.SvgCanvas#event:contextset
|
|
889
888
|
* @returns {void}
|
|
890
889
|
*/
|
|
891
|
-
contextChanged
|
|
890
|
+
contextChanged(win, context) {
|
|
892
891
|
let linkStr = ''
|
|
893
892
|
if (context) {
|
|
894
893
|
let str = ''
|
|
@@ -921,7 +920,7 @@ class Editor extends EditorStartup {
|
|
|
921
920
|
* @param {string|external:jQuery} iconId
|
|
922
921
|
* @returns {void}
|
|
923
922
|
*/
|
|
924
|
-
setIcon
|
|
923
|
+
setIcon(elem, iconId) {
|
|
925
924
|
const img = document.createElement('img')
|
|
926
925
|
img.src = this.configObj.curConfig.imgPath + iconId
|
|
927
926
|
const icon = typeof iconId === 'string' ? img : iconId.cloneNode(true)
|
|
@@ -943,7 +942,7 @@ class Editor extends EditorStartup {
|
|
|
943
942
|
* @listens module:svgcanvas.SvgCanvas#event:extension_added
|
|
944
943
|
* @returns {Promise<void>|void} Resolves to `undefined`
|
|
945
944
|
*/
|
|
946
|
-
async extAdded
|
|
945
|
+
async extAdded(win, ext) {
|
|
947
946
|
if (!ext) {
|
|
948
947
|
return undefined
|
|
949
948
|
}
|
|
@@ -970,7 +969,7 @@ class Editor extends EditorStartup {
|
|
|
970
969
|
* @param {Float} multiplier
|
|
971
970
|
* @returns {void}
|
|
972
971
|
*/
|
|
973
|
-
zoomImage
|
|
972
|
+
zoomImage(multiplier) {
|
|
974
973
|
const resolution = this.svgCanvas.getResolution()
|
|
975
974
|
multiplier = multiplier ? resolution.zoom * multiplier : 1
|
|
976
975
|
// setResolution(res.w * multiplier, res.h * multiplier, true);
|
|
@@ -984,7 +983,7 @@ class Editor extends EditorStartup {
|
|
|
984
983
|
*
|
|
985
984
|
* @returns {void}
|
|
986
985
|
*/
|
|
987
|
-
cutSelected
|
|
986
|
+
cutSelected() {
|
|
988
987
|
if (this.selectedElement || this.multiselected) {
|
|
989
988
|
this.svgCanvas.cutSelectedElements()
|
|
990
989
|
}
|
|
@@ -994,7 +993,7 @@ class Editor extends EditorStartup {
|
|
|
994
993
|
* @function copySelected
|
|
995
994
|
* @returns {void}
|
|
996
995
|
*/
|
|
997
|
-
copySelected
|
|
996
|
+
copySelected() {
|
|
998
997
|
if (this.selectedElement || this.multiselected) {
|
|
999
998
|
this.svgCanvas.copySelectedElements()
|
|
1000
999
|
}
|
|
@@ -1004,20 +1003,20 @@ class Editor extends EditorStartup {
|
|
|
1004
1003
|
*
|
|
1005
1004
|
* @returns {void}
|
|
1006
1005
|
*/
|
|
1007
|
-
pasteInCenter
|
|
1006
|
+
pasteInCenter() {
|
|
1008
1007
|
const { workarea } = this
|
|
1009
1008
|
const zoom = this.svgCanvas.getZoom()
|
|
1010
1009
|
const x =
|
|
1011
1010
|
(workarea.scrollLeft +
|
|
1012
1011
|
parseFloat(getComputedStyle(workarea, null).width.replace('px', '')) /
|
|
1013
|
-
|
|
1014
|
-
|
|
1012
|
+
2) /
|
|
1013
|
+
zoom -
|
|
1015
1014
|
this.svgCanvas.contentW
|
|
1016
1015
|
const y =
|
|
1017
1016
|
(workarea.scrollTop +
|
|
1018
1017
|
parseFloat(getComputedStyle(workarea, null).height.replace('px', '')) /
|
|
1019
|
-
|
|
1020
|
-
|
|
1018
|
+
2) /
|
|
1019
|
+
zoom -
|
|
1021
1020
|
this.svgCanvas.contentH
|
|
1022
1021
|
this.svgCanvas.pasteElements('point', x, y)
|
|
1023
1022
|
}
|
|
@@ -1026,7 +1025,7 @@ class Editor extends EditorStartup {
|
|
|
1026
1025
|
* @param {"Up"|"Down"} dir
|
|
1027
1026
|
* @returns {void}
|
|
1028
1027
|
*/
|
|
1029
|
-
moveUpDownSelected
|
|
1028
|
+
moveUpDownSelected(dir) {
|
|
1030
1029
|
if (this.selectedElement) {
|
|
1031
1030
|
this.svgCanvas.moveUpDownSelected(dir)
|
|
1032
1031
|
}
|
|
@@ -1037,7 +1036,7 @@ class Editor extends EditorStartup {
|
|
|
1037
1036
|
* @param {Float} dy
|
|
1038
1037
|
* @returns {void}
|
|
1039
1038
|
*/
|
|
1040
|
-
moveSelected
|
|
1039
|
+
moveSelected(dx, dy) {
|
|
1041
1040
|
if (this.selectedElement || this.multiselected) {
|
|
1042
1041
|
if (this.configObj.curConfig.gridSnapping) {
|
|
1043
1042
|
// Use grid snap value regardless of zoom level
|
|
@@ -1054,7 +1053,7 @@ class Editor extends EditorStartup {
|
|
|
1054
1053
|
*
|
|
1055
1054
|
* @returns {void}
|
|
1056
1055
|
*/
|
|
1057
|
-
selectNext
|
|
1056
|
+
selectNext() {
|
|
1058
1057
|
this.svgCanvas.cycleElement(1)
|
|
1059
1058
|
}
|
|
1060
1059
|
|
|
@@ -1062,7 +1061,7 @@ class Editor extends EditorStartup {
|
|
|
1062
1061
|
*
|
|
1063
1062
|
* @returns {void}
|
|
1064
1063
|
*/
|
|
1065
|
-
selectPrev
|
|
1064
|
+
selectPrev() {
|
|
1066
1065
|
this.svgCanvas.cycleElement(0)
|
|
1067
1066
|
}
|
|
1068
1067
|
|
|
@@ -1071,7 +1070,7 @@ class Editor extends EditorStartup {
|
|
|
1071
1070
|
* @param {Integer} step
|
|
1072
1071
|
* @returns {void}
|
|
1073
1072
|
*/
|
|
1074
|
-
rotateSelected
|
|
1073
|
+
rotateSelected(cw, step) {
|
|
1075
1074
|
if (!this.selectedElement || this.multiselected) {
|
|
1076
1075
|
return
|
|
1077
1076
|
}
|
|
@@ -1087,7 +1086,7 @@ class Editor extends EditorStartup {
|
|
|
1087
1086
|
*
|
|
1088
1087
|
* @returns {void}
|
|
1089
1088
|
*/
|
|
1090
|
-
hideSourceEditor
|
|
1089
|
+
hideSourceEditor() {
|
|
1091
1090
|
const $editorDialog = $id('se-svg-editor-dialog')
|
|
1092
1091
|
$editorDialog.setAttribute('dialog', 'closed')
|
|
1093
1092
|
}
|
|
@@ -1096,7 +1095,7 @@ class Editor extends EditorStartup {
|
|
|
1096
1095
|
* @param {Event} e
|
|
1097
1096
|
* @returns {void} Resolves to `undefined`
|
|
1098
1097
|
*/
|
|
1099
|
-
async saveSourceEditor
|
|
1098
|
+
async saveSourceEditor(e) {
|
|
1100
1099
|
const $editorDialog = $id('se-svg-editor-dialog')
|
|
1101
1100
|
if ($editorDialog.getAttribute('dialog') !== 'open') return
|
|
1102
1101
|
const saveChanges = () => {
|
|
@@ -1124,7 +1123,7 @@ class Editor extends EditorStartup {
|
|
|
1124
1123
|
* @param {Event} e
|
|
1125
1124
|
* @returns {void} Resolves to `undefined`
|
|
1126
1125
|
*/
|
|
1127
|
-
cancelOverlays
|
|
1126
|
+
cancelOverlays(e) {
|
|
1128
1127
|
if ($id('dialog_box') != null) $id('dialog_box').style.display = 'none'
|
|
1129
1128
|
const $editorDialog = $id('se-svg-editor-dialog')
|
|
1130
1129
|
const editingsource = $editorDialog.getAttribute('dialog') === 'open'
|
|
@@ -1153,7 +1152,7 @@ class Editor extends EditorStartup {
|
|
|
1153
1152
|
/**
|
|
1154
1153
|
* @returns {void}
|
|
1155
1154
|
*/
|
|
1156
|
-
toggleDynamicOutput
|
|
1155
|
+
toggleDynamicOutput(e) {
|
|
1157
1156
|
this.configObj.curConfig.dynamicOutput = e.detail.dynamic
|
|
1158
1157
|
this.svgCanvas.setConfig(this.configObj.curConfig)
|
|
1159
1158
|
const $editorDialog = document.getElementById('se-svg-editor-dialog')
|
|
@@ -1165,7 +1164,7 @@ class Editor extends EditorStartup {
|
|
|
1165
1164
|
/**
|
|
1166
1165
|
* @returns {void}
|
|
1167
1166
|
*/
|
|
1168
|
-
enableOrDisableClipboard
|
|
1167
|
+
enableOrDisableClipboard() {
|
|
1169
1168
|
let svgeditClipboard
|
|
1170
1169
|
try {
|
|
1171
1170
|
svgeditClipboard = this.localStorage.getItem('svgedit_clipboard')
|
|
@@ -1183,7 +1182,7 @@ class Editor extends EditorStartup {
|
|
|
1183
1182
|
* @returns {boolean|Promise<boolean>} Resolves to boolean indicating `true` if there were no changes
|
|
1184
1183
|
* and `false` after the user confirms.
|
|
1185
1184
|
*/
|
|
1186
|
-
async openPrep
|
|
1185
|
+
async openPrep() {
|
|
1187
1186
|
if (this.svgCanvas.undoMgr.getUndoStackSize() === 0) {
|
|
1188
1187
|
return true
|
|
1189
1188
|
}
|
|
@@ -1195,7 +1194,7 @@ class Editor extends EditorStartup {
|
|
|
1195
1194
|
* @param {Event} e
|
|
1196
1195
|
* @returns {void}
|
|
1197
1196
|
*/
|
|
1198
|
-
onDragEnter
|
|
1197
|
+
onDragEnter(e) {
|
|
1199
1198
|
e.stopPropagation()
|
|
1200
1199
|
e.preventDefault()
|
|
1201
1200
|
// and indicator should be displayed here, such as "drop files here"
|
|
@@ -1206,7 +1205,7 @@ class Editor extends EditorStartup {
|
|
|
1206
1205
|
* @param {Event} e
|
|
1207
1206
|
* @returns {void}
|
|
1208
1207
|
*/
|
|
1209
|
-
onDragOver
|
|
1208
|
+
onDragOver(e) {
|
|
1210
1209
|
e.stopPropagation()
|
|
1211
1210
|
e.preventDefault()
|
|
1212
1211
|
}
|
|
@@ -1216,7 +1215,7 @@ class Editor extends EditorStartup {
|
|
|
1216
1215
|
* @param {Event} e
|
|
1217
1216
|
* @returns {void}
|
|
1218
1217
|
*/
|
|
1219
|
-
onDragLeave
|
|
1218
|
+
onDragLeave(e) {
|
|
1220
1219
|
e.stopPropagation()
|
|
1221
1220
|
e.preventDefault()
|
|
1222
1221
|
// hypothetical indicator should be removed here
|
|
@@ -1230,7 +1229,7 @@ class Editor extends EditorStartup {
|
|
|
1230
1229
|
* @fires module:svgcanvas.SvgCanvas#event:ext_langChanged
|
|
1231
1230
|
* @returns {void} A Promise which resolves to `undefined`
|
|
1232
1231
|
*/
|
|
1233
|
-
setLang
|
|
1232
|
+
setLang(lang) {
|
|
1234
1233
|
this.langChanged = true
|
|
1235
1234
|
this.configObj.pref('lang', lang)
|
|
1236
1235
|
const $editDialog = $id('se-edit-prefs')
|
|
@@ -1268,7 +1267,7 @@ class Editor extends EditorStartup {
|
|
|
1268
1267
|
* @param {module:SVGthis.ReadyCallback} cb Callback to be queued to invoke
|
|
1269
1268
|
* @returns {Promise<ArbitraryCallbackResult>} Resolves when all callbacks, including the supplied have resolved
|
|
1270
1269
|
*/
|
|
1271
|
-
ready
|
|
1270
|
+
ready(cb) {
|
|
1272
1271
|
return new Promise((resolve, reject) => {
|
|
1273
1272
|
if (this.isReady) {
|
|
1274
1273
|
resolve(cb())
|
|
@@ -1283,7 +1282,7 @@ class Editor extends EditorStartup {
|
|
|
1283
1282
|
* @function module:SVGthis.runCallbacks
|
|
1284
1283
|
* @returns {Promise<void>} Resolves to `undefined` if all callbacks succeeded and rejects otherwise
|
|
1285
1284
|
*/
|
|
1286
|
-
async runCallbacks
|
|
1285
|
+
async runCallbacks() {
|
|
1287
1286
|
try {
|
|
1288
1287
|
await Promise.all(
|
|
1289
1288
|
this.callbacks.map(([cb]) => {
|
|
@@ -1309,7 +1308,7 @@ class Editor extends EditorStartup {
|
|
|
1309
1308
|
* @param {boolean} [opts.noAlert=false] Option to avoid alert to user and instead get rejected promise
|
|
1310
1309
|
* @returns {Promise<void>}
|
|
1311
1310
|
*/
|
|
1312
|
-
loadFromString
|
|
1311
|
+
loadFromString(str, { noAlert } = {}) {
|
|
1313
1312
|
return this.ready(async () => {
|
|
1314
1313
|
try {
|
|
1315
1314
|
await this.loadSvgString(str, { noAlert })
|
|
@@ -1336,7 +1335,7 @@ class Editor extends EditorStartup {
|
|
|
1336
1335
|
* the SVG (or upon failure to parse the loaded string) when `noAlert` is
|
|
1337
1336
|
* enabled
|
|
1338
1337
|
*/
|
|
1339
|
-
loadFromURL
|
|
1338
|
+
loadFromURL(url, { cache, noAlert } = {}) {
|
|
1340
1339
|
return this.ready(() => {
|
|
1341
1340
|
return new Promise((resolve, reject) => {
|
|
1342
1341
|
fetch(url, { cache: cache ? 'force-cache' : 'no-cache' })
|
|
@@ -1376,7 +1375,7 @@ class Editor extends EditorStartup {
|
|
|
1376
1375
|
* @param {boolean} [opts.noAlert]
|
|
1377
1376
|
* @returns {Promise<void>} Resolves to `undefined` and rejects if loading SVG string fails and `noAlert` is enabled
|
|
1378
1377
|
*/
|
|
1379
|
-
loadFromDataURI
|
|
1378
|
+
loadFromDataURI(str, { noAlert } = {}) {
|
|
1380
1379
|
return this.ready(() => {
|
|
1381
1380
|
let base64 = false
|
|
1382
1381
|
let pre = str.match(/^data:image\/svg\+xml;base64,/)
|
|
@@ -1404,7 +1403,7 @@ class Editor extends EditorStartup {
|
|
|
1404
1403
|
* @throws {Error} If called too early
|
|
1405
1404
|
* @returns {Promise<void>} Resolves to `undefined`
|
|
1406
1405
|
*/
|
|
1407
|
-
addExtension
|
|
1406
|
+
addExtension(name, initfn, initArgs) {
|
|
1408
1407
|
// Note that we don't want this on this.ready since some extensions
|
|
1409
1408
|
// may want to run before then (like server_opensave).
|
|
1410
1409
|
if (!this.svgCanvas) {
|
|
@@ -48,7 +48,7 @@ class EditorStartup {
|
|
|
48
48
|
/**
|
|
49
49
|
*
|
|
50
50
|
*/
|
|
51
|
-
constructor
|
|
51
|
+
constructor(div) {
|
|
52
52
|
this.extensionsAdded = false
|
|
53
53
|
this.messageQueue = []
|
|
54
54
|
this.$container = div ?? $id('svg_editor')
|
|
@@ -59,7 +59,7 @@ class EditorStartup {
|
|
|
59
59
|
* @function module:SVGthis.init
|
|
60
60
|
* @returns {void}
|
|
61
61
|
*/
|
|
62
|
-
async init
|
|
62
|
+
async init() {
|
|
63
63
|
if ('localStorage' in window) {
|
|
64
64
|
this.storage = window.localStorage
|
|
65
65
|
}
|
|
@@ -409,7 +409,7 @@ class EditorStartup {
|
|
|
409
409
|
})
|
|
410
410
|
})
|
|
411
411
|
// ref: https://stackoverflow.com/a/1038781
|
|
412
|
-
function getWidth
|
|
412
|
+
function getWidth() {
|
|
413
413
|
return Math.max(
|
|
414
414
|
document.body.scrollWidth,
|
|
415
415
|
document.documentElement.scrollWidth,
|
|
@@ -419,7 +419,7 @@ class EditorStartup {
|
|
|
419
419
|
)
|
|
420
420
|
}
|
|
421
421
|
|
|
422
|
-
function getHeight
|
|
422
|
+
function getHeight() {
|
|
423
423
|
return Math.max(
|
|
424
424
|
document.body.scrollHeight,
|
|
425
425
|
document.documentElement.scrollHeight,
|
|
@@ -604,14 +604,15 @@ class EditorStartup {
|
|
|
604
604
|
}.bind(this))
|
|
605
605
|
|
|
606
606
|
window.addEventListener('beforeunload', function (e) {
|
|
607
|
-
|
|
607
|
+
return;
|
|
608
|
+
// Suppress warning if page is empty
|
|
608
609
|
if (undoMgr.getUndoStackSize() === 0) {
|
|
609
610
|
this.showSaveWarning = false
|
|
610
611
|
}
|
|
611
612
|
|
|
612
613
|
// showSaveWarning is set to 'false' when the page is saved.
|
|
613
614
|
if (!this.configObj.curConfig.no_save_warning && this.showSaveWarning) {
|
|
614
|
-
|
|
615
|
+
// Browser already asks question about closing the page
|
|
615
616
|
e.returnValue = this.i18next.t('notification.unsavedChanges') // Firefox needs this when beforeunload set by addEventListener (even though message is not used)
|
|
616
617
|
return this.i18next.t('notification.unsavedChanges')
|
|
617
618
|
}
|
|
@@ -646,7 +647,7 @@ class EditorStartup {
|
|
|
646
647
|
* @fires module:svgcanvas.SvgCanvas#event:extensions_added
|
|
647
648
|
* @returns {Promise<module:locale.LangAndData>} Resolves to result of {@link module:locale.readLang}
|
|
648
649
|
*/
|
|
649
|
-
async extAndLocaleFunc
|
|
650
|
+
async extAndLocaleFunc() {
|
|
650
651
|
this.$svgEditor.style.visibility = 'visible'
|
|
651
652
|
try {
|
|
652
653
|
// load standard extensions
|
|
@@ -735,7 +736,7 @@ class EditorStartup {
|
|
|
735
736
|
* Listens to the mode change, listener is to be added on document
|
|
736
737
|
* @param {Event} evt custom modeChange event
|
|
737
738
|
*/
|
|
738
|
-
modeListener
|
|
739
|
+
modeListener(evt) {
|
|
739
740
|
const mode = this.svgCanvas.getMode()
|
|
740
741
|
|
|
741
742
|
this.setCursorStyle(mode)
|
|
@@ -745,7 +746,7 @@ class EditorStartup {
|
|
|
745
746
|
* sets cursor styling for workarea depending on the current mode
|
|
746
747
|
* @param {string} mode
|
|
747
748
|
*/
|
|
748
|
-
setCursorStyle
|
|
749
|
+
setCursorStyle(mode) {
|
|
749
750
|
let cs = 'auto'
|
|
750
751
|
switch (mode) {
|
|
751
752
|
case 'ext-panning':
|
|
@@ -777,7 +778,7 @@ class EditorStartup {
|
|
|
777
778
|
/**
|
|
778
779
|
* Listens for Esc key to be pressed to cancel active mode, sets mode to Select
|
|
779
780
|
*/
|
|
780
|
-
cancelTool
|
|
781
|
+
cancelTool() {
|
|
781
782
|
const mode = this.svgCanvas.getMode()
|
|
782
783
|
// list of modes that are currently save to cancel
|
|
783
784
|
const modesToCancel = ['zoom', 'rect', 'square', 'circle', 'ellipse', 'line', 'text', 'star', 'polygon', 'shapelib', 'image']
|
|
@@ -34,7 +34,7 @@ const loadExtensionTranslation = async function (svgEditor) {
|
|
|
34
34
|
|
|
35
35
|
export default {
|
|
36
36
|
name,
|
|
37
|
-
async init
|
|
37
|
+
async init(_S) {
|
|
38
38
|
const svgEditor = this
|
|
39
39
|
const { svgCanvas } = svgEditor
|
|
40
40
|
const { $id, $click } = svgCanvas
|
|
@@ -136,7 +136,7 @@ export default {
|
|
|
136
136
|
svgEditor.zoomImage()
|
|
137
137
|
svgEditor.layersPanel.populateLayers()
|
|
138
138
|
svgEditor.topPanel.updateContextPanel()
|
|
139
|
-
svgEditor.topPanel.updateTitle('
|
|
139
|
+
svgEditor.topPanel.updateTitle('bez_tytulu.svg')
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
/**
|
|
@@ -222,7 +222,7 @@ export default {
|
|
|
222
222
|
if (type === 'save' && handle !== null) {
|
|
223
223
|
const throwIfExistingHandleNotGood = false
|
|
224
224
|
handle = await fileSave(blob, {
|
|
225
|
-
fileName: '
|
|
225
|
+
fileName: 'bez_tytulu.svg',
|
|
226
226
|
extensions: ['.svg']
|
|
227
227
|
}, handle, throwIfExistingHandleNotGood)
|
|
228
228
|
} else {
|
|
@@ -247,7 +247,7 @@ export default {
|
|
|
247
247
|
return {
|
|
248
248
|
name: svgEditor.i18next.t(`${name}:name`),
|
|
249
249
|
// The callback should be used to load the DOM with the appropriate UI items
|
|
250
|
-
callback
|
|
250
|
+
callback() {
|
|
251
251
|
const buttonTemplate = `
|
|
252
252
|
<se-menu-item id="tool_clear" label="opensave.new_doc" shortcut="N" src="new.svg"></se-menu-item>`
|
|
253
253
|
svgCanvas.insertChildAtIndex($id('main_button'), buttonTemplate, 0)
|
|
@@ -26,7 +26,7 @@ const loadExtensionTranslation = async function (svgEditor) {
|
|
|
26
26
|
|
|
27
27
|
export default {
|
|
28
28
|
name,
|
|
29
|
-
async init
|
|
29
|
+
async init() {
|
|
30
30
|
const svgEditor = this
|
|
31
31
|
await loadExtensionTranslation(svgEditor)
|
|
32
32
|
const {
|
|
@@ -38,8 +38,8 @@ export default {
|
|
|
38
38
|
}
|
|
39
39
|
return {
|
|
40
40
|
name: svgEditor.i18next.t(`${name}:name`),
|
|
41
|
-
callback
|
|
42
|
-
const btitle =
|
|
41
|
+
callback() {
|
|
42
|
+
const btitle = `Przesuwanie [Spacja / kółko myszki + przeciąganie]`
|
|
43
43
|
// Add the button and its handler(s)
|
|
44
44
|
const buttonTemplate = document.createElement('template')
|
|
45
45
|
buttonTemplate.innerHTML = `
|
|
@@ -52,7 +52,7 @@ export default {
|
|
|
52
52
|
}
|
|
53
53
|
})
|
|
54
54
|
},
|
|
55
|
-
mouseDown
|
|
55
|
+
mouseDown() {
|
|
56
56
|
if (svgCanvas.getMode() === 'ext-panning') {
|
|
57
57
|
svgEditor.setPanning(true)
|
|
58
58
|
return {
|
|
@@ -61,7 +61,7 @@ export default {
|
|
|
61
61
|
}
|
|
62
62
|
return undefined
|
|
63
63
|
},
|
|
64
|
-
mouseUp
|
|
64
|
+
mouseUp() {
|
|
65
65
|
if (svgCanvas.getMode() === 'ext-panning') {
|
|
66
66
|
svgEditor.setPanning(false)
|
|
67
67
|
return {
|
|
@@ -61,7 +61,7 @@ const replaceStoragePrompt = val => {
|
|
|
61
61
|
|
|
62
62
|
export default {
|
|
63
63
|
name: 'storage',
|
|
64
|
-
init
|
|
64
|
+
init() {
|
|
65
65
|
const svgEditor = this
|
|
66
66
|
const { svgCanvas, storage } = svgEditor
|
|
67
67
|
|
|
@@ -96,7 +96,7 @@ export default {
|
|
|
96
96
|
const cached = storage.getItem(key)
|
|
97
97
|
if (cached) {
|
|
98
98
|
svgEditor.loadFromString(cached)
|
|
99
|
-
const name = storage.getItem(`title-${key}`) ?? '
|
|
99
|
+
const name = storage.getItem(`title-${key}`) ?? 'bez_tytulu.svg'
|
|
100
100
|
svgEditor.topPanel.updateTitle(name)
|
|
101
101
|
svgEditor.layersPanel.populateLayers()
|
|
102
102
|
}
|
|
@@ -180,6 +180,7 @@ export default {
|
|
|
180
180
|
* @returns {void}
|
|
181
181
|
*/
|
|
182
182
|
const setupBeforeUnloadListener = () => {
|
|
183
|
+
return;
|
|
183
184
|
window.addEventListener('beforeunload', function () {
|
|
184
185
|
// Don't save anything unless the user opted in to storage
|
|
185
186
|
if (
|
|
@@ -222,7 +223,9 @@ export default {
|
|
|
222
223
|
let loaded = false
|
|
223
224
|
return {
|
|
224
225
|
name: 'storage',
|
|
225
|
-
callback
|
|
226
|
+
callback() {
|
|
227
|
+
// Prevent from showing storage dialog
|
|
228
|
+
return;
|
|
226
229
|
const storagePrompt = new URL(top.location).searchParams.get(
|
|
227
230
|
'storagePrompt'
|
|
228
231
|
)
|