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