@gorpacrate/core-graphics
Version:
A core library for creating shape-based graphic editors
47 lines • 1.68 kB
JavaScript
"use strict";
exports.__esModule = true;
var i = require("icepick");
var declarations_1 = require("../declarations");
var history_reducer_1 = require("../history/history-reducer");
exports.initialGridState = {
on: false,
size: 16
};
function getInitialEditorState(params) {
var shapesDeclarations = params.shapesDeclarations, author = params.author, viewport = params.viewport, _a = params.graphicalContextData, graphicalContextData = _a === void 0 ? {} : _a, _b = params.persistedHistory, persistedHistory = _b === void 0 ? [] : _b, _c = params.grid, grid = _c === void 0 ? exports.initialGridState : _c;
var scene = { shapes: {}, shapesOrder: [] };
if (persistedHistory && persistedHistory.length > 0) {
scene = history_reducer_1["default"](persistedHistory, scene);
}
return (i.freeze({
mode: declarations_1.modeSelect(),
viewport: viewport || { x: 0, y: 0 },
grid: grid,
contextMenu: {
open: false,
x: 0,
y: 0,
target: undefined
},
mouse: {
ignoreCursorUp: false,
down: false,
inside: false,
x: 0,
y: 0,
lastDownX: 0,
lastDownY: 0
},
modifierKeys: {},
shapesDeclarations: shapesDeclarations,
author: author,
graphicalContextData: graphicalContextData,
persistedHistory: persistedHistory,
persistedScene: scene,
scene: scene,
previewedHistoryEvents: [],
editorActionsQueue: []
}));
}
exports.getInitialEditorState = getInitialEditorState;
//# sourceMappingURL=editor-state.js.map