save canvas content restored
parent
ef667b78ad
commit
2d0e4fab27
|
@ -141,8 +141,9 @@ MD.Editor = function(){
|
||||||
function escapeMode(){
|
function escapeMode(){
|
||||||
for (key in editor.modal) editor.modal[key].close();
|
for (key in editor.modal) editor.modal[key].close();
|
||||||
state.set("canvasMode", "select");
|
state.set("canvasMode", "select");
|
||||||
if ($("#cur_context_panel").is(":visible"))
|
if ($("#cur_context_panel").is(":visible")) {
|
||||||
svgCanvas.leaveContext()
|
svgCanvas.leaveContext()
|
||||||
|
}
|
||||||
else
|
else
|
||||||
state.set("canvasContent", svgCanvas.getSvgString())
|
state.set("canvasContent", svgCanvas.getSvgString())
|
||||||
}
|
}
|
||||||
|
@ -194,8 +195,7 @@ MD.Editor = function(){
|
||||||
elems: elems
|
elems: elems
|
||||||
});
|
});
|
||||||
|
|
||||||
// todo svgCanvas.getCurrentContext is needed
|
if (!svgCanvas.getContext())
|
||||||
if (!$("#cur_context_panel").is(":visible"))
|
|
||||||
state.set("canvasContent", svgCanvas.getSvgString())
|
state.set("canvasContent", svgCanvas.getSvgString())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ MD.Editor = function(){
|
||||||
if (attr === "opacity") value *= 0.01;
|
if (attr === "opacity") value *= 0.01;
|
||||||
if (completed) {
|
if (completed) {
|
||||||
svgCanvas.changeSelectedAttribute(attr, value);
|
svgCanvas.changeSelectedAttribute(attr, value);
|
||||||
state.set("canvasContent", serializer.serializeToString(svgCanvas.getContentElem()));
|
state.set("canvasContent", svgCanvas.getSvgString());
|
||||||
}
|
}
|
||||||
else svgCanvas.changeSelectedAttributeNoUndo(attr, value);
|
else svgCanvas.changeSelectedAttributeNoUndo(attr, value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// globals
|
// globals
|
||||||
const svgCanvas = new $.SvgCanvas(document.getElementById("svgcanvas"));
|
const svgCanvas = new $.SvgCanvas(document.getElementById("svgcanvas"));
|
||||||
const editor = new MD.Editor();
|
const editor = new MD.Editor();
|
||||||
|
const state = new State();
|
||||||
|
|
||||||
editor.modal = {
|
editor.modal = {
|
||||||
about: new MD.Modal({
|
about: new MD.Modal({
|
||||||
|
@ -113,10 +114,8 @@ svgCanvas.bind("extension_added", editor.extensionAdded);
|
||||||
svgCanvas.textActions.setInputElem($("#text")[0]);
|
svgCanvas.textActions.setInputElem($("#text")[0]);
|
||||||
const shapeLib = svgCanvas.addExtension.apply(this, ["shapes", MD.Shapelib]);
|
const shapeLib = svgCanvas.addExtension.apply(this, ["shapes", MD.Shapelib]);
|
||||||
const eyedropper = svgCanvas.addExtension.apply(this, ["eyedropper", MD.Eyedropper]);
|
const eyedropper = svgCanvas.addExtension.apply(this, ["eyedropper", MD.Eyedropper]);
|
||||||
const state = new State();
|
|
||||||
state.set("canvasId", t("Untitled"));
|
state.set("canvasId", t("Untitled"));
|
||||||
state.set("canvasMode", state.get("canvasMode"));
|
state.set("canvasMode", state.get("canvasMode"));
|
||||||
state.set("canvasSize", state.get("canvasSize"));
|
|
||||||
svgCanvas.setSvgString(state.get("canvasContent"));
|
svgCanvas.setSvgString(state.get("canvasContent"));
|
||||||
editor.paintBox.fill.setPaint(state.get("canvasFill"));
|
editor.paintBox.fill.setPaint(state.get("canvasFill"));
|
||||||
editor.paintBox.stroke.setPaint(state.get("canvasStroke"));
|
editor.paintBox.stroke.setPaint(state.get("canvasStroke"));
|
||||||
|
|
|
@ -6461,6 +6461,13 @@ var leaveContext = this.leaveContext = function() {
|
||||||
current_group = null;
|
current_group = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Function: getContext
|
||||||
|
// Get the current context (in-group editing)
|
||||||
|
var getContext = this.getContext = function() {
|
||||||
|
return current_group;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Function: setContext
|
// Function: setContext
|
||||||
// Set the current context (for in-group editing)
|
// Set the current context (for in-group editing)
|
||||||
var setContext = this.setContext = function(elem) {
|
var setContext = this.setContext = function(elem) {
|
||||||
|
|
Loading…
Reference in New Issue