svgedit-pl 7.4.4 → 7.4.6
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 +18 -6
- package/dist/editor/Editor.js.map +1 -1
- package/dist/editor/extensions/ext-opensave/ext-opensave.js +19 -2
- package/dist/editor/extensions/ext-opensave/ext-opensave.js.map +1 -1
- package/dist/editor/iife-Editor.js +3 -3
- package/dist/editor/iife-Editor.js.map +1 -1
- package/package.json +1 -1
- package/src/editor/Editor.js +2 -0
- package/src/editor/extensions/ext-opensave/ext-opensave.js +24 -2
- package/src/editor/panels/TopPanel.js +19 -7
package/package.json
CHANGED
package/src/editor/Editor.js
CHANGED
|
@@ -336,6 +336,8 @@ class Editor extends EditorStartup {
|
|
|
336
336
|
const success = this.svgCanvas.setSvgString(str) !== false
|
|
337
337
|
if (success) {
|
|
338
338
|
this.updateCanvas()
|
|
339
|
+
// Fit the loaded document to the workarea so it fills most of the screen.
|
|
340
|
+
this.zoomChanged(window, 'canvas', true)
|
|
339
341
|
return
|
|
340
342
|
}
|
|
341
343
|
if (!noAlert) seAlert(this.i18next.t('notification.errorLoadingSVG'))
|
|
@@ -74,6 +74,28 @@ export default {
|
|
|
74
74
|
if (file.type.includes('svg')) {
|
|
75
75
|
reader = new FileReader()
|
|
76
76
|
reader.onloadend = (ev) => {
|
|
77
|
+
// First drop onto a pristine document loads (replaces) the SVG and
|
|
78
|
+
// zooms to fit. Later drops / Import still insert into the current doc.
|
|
79
|
+
const isDrop = e.type === 'drop'
|
|
80
|
+
const isPristine = this.svgCanvas.undoMgr.getUndoStackSize() === 0
|
|
81
|
+
if (isDrop && isPristine) {
|
|
82
|
+
try {
|
|
83
|
+
this.loadSvgString(ev.target.result)
|
|
84
|
+
this.topPanel.updateTitle(file.name)
|
|
85
|
+
this.layersPanel.populateLayers()
|
|
86
|
+
this.svgCanvas.runExtensions('onOpenedDocument', {
|
|
87
|
+
name: file.name,
|
|
88
|
+
lastModified: file.lastModified,
|
|
89
|
+
size: file.size,
|
|
90
|
+
type: file.type
|
|
91
|
+
})
|
|
92
|
+
} catch (_err) {
|
|
93
|
+
// loadSvgString already alerts on failure
|
|
94
|
+
}
|
|
95
|
+
$id('se-prompt-dialog').setAttribute('close', true)
|
|
96
|
+
resetFileInput()
|
|
97
|
+
return
|
|
98
|
+
}
|
|
77
99
|
// imgImport.shiftKey (shift key pressed or not) will determine if import should preserve dimension)
|
|
78
100
|
const newElement = this.svgCanvas.importSvgString(ev.target.result, imgImport.shiftKey)
|
|
79
101
|
this.svgCanvas.alignSelectedElements('m', 'page')
|
|
@@ -146,7 +168,8 @@ export default {
|
|
|
146
168
|
svgEditor.svgCanvas.clear()
|
|
147
169
|
svgEditor.svgCanvas.setResolution(x, y)
|
|
148
170
|
svgEditor.updateCanvas(true)
|
|
149
|
-
|
|
171
|
+
// Same as load: fit the blank canvas to the workarea.
|
|
172
|
+
svgEditor.zoomChanged(window, 'canvas', true)
|
|
150
173
|
svgEditor.layersPanel.populateLayers()
|
|
151
174
|
svgEditor.topPanel.updateContextPanel()
|
|
152
175
|
svgEditor.topPanel.updateTitle('bez_tytulu.svg')
|
|
@@ -169,7 +192,6 @@ export default {
|
|
|
169
192
|
})
|
|
170
193
|
const svgContent = await blob.text()
|
|
171
194
|
await svgEditor.loadSvgString(svgContent)
|
|
172
|
-
svgEditor.updateCanvas()
|
|
173
195
|
handle = blob.handle
|
|
174
196
|
svgEditor.topPanel.updateTitle(blob.name)
|
|
175
197
|
svgEditor.svgCanvas.runExtensions('onOpenedDocument', {
|
|
@@ -23,18 +23,30 @@ class TopPanel {
|
|
|
23
23
|
/**
|
|
24
24
|
* @type {module}
|
|
25
25
|
*/
|
|
26
|
-
displayTool (
|
|
27
|
-
//
|
|
28
|
-
$qa(`.${
|
|
26
|
+
displayTool (name) {
|
|
27
|
+
// Panels use CSS classes; individual tools (e.g. tool_topath) use element ids.
|
|
28
|
+
const byClass = $qa(`.${name}`)
|
|
29
|
+
if (byClass.length) {
|
|
30
|
+
byClass.forEach(el => el.style.removeProperty('display'))
|
|
31
|
+
return
|
|
32
|
+
}
|
|
33
|
+
const byId = $id(name)
|
|
34
|
+
if (byId) byId.style.removeProperty('display')
|
|
29
35
|
}
|
|
30
36
|
|
|
31
37
|
/**
|
|
32
38
|
* @type {module}
|
|
33
39
|
*/
|
|
34
|
-
hideTool (
|
|
35
|
-
$qa(`.${
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
hideTool (name) {
|
|
41
|
+
const byClass = $qa(`.${name}`)
|
|
42
|
+
if (byClass.length) {
|
|
43
|
+
byClass.forEach(el => {
|
|
44
|
+
el.style.display = 'none'
|
|
45
|
+
})
|
|
46
|
+
return
|
|
47
|
+
}
|
|
48
|
+
const byId = $id(name)
|
|
49
|
+
if (byId) byId.style.display = 'none'
|
|
38
50
|
}
|
|
39
51
|
|
|
40
52
|
/**
|