progress
This commit is contained in:
@@ -28,7 +28,7 @@ export const init = function (canvas) {
|
|||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
export const pasteElementsMethod = function (type, x, y) {
|
export const pasteElementsMethod = function (type, x, y) {
|
||||||
let clipb = JSON.parse(sessionStorage.getItem(svgCanvas.getClipBoardID()));
|
let clipb = JSON.parse(sessionStorage.getItem(svgCanvas.getClipboardID()));
|
||||||
if (!clipb) return;
|
if (!clipb) return;
|
||||||
let len = clipb.length;
|
let len = clipb.length;
|
||||||
if (!len) return;
|
if (!len) return;
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import { getRotationAngle, getBBox, getStrokedBBox, isNullish } from './utilitie
|
|||||||
import { transformListToTransform, transformBox, transformPoint } from './math.js';
|
import { transformListToTransform, transformBox, transformPoint } from './math.js';
|
||||||
|
|
||||||
let svgCanvas;
|
let svgCanvas;
|
||||||
let config_;
|
|
||||||
let selectorManager_; // A Singleton
|
let selectorManager_; // A Singleton
|
||||||
const gripRadius = isTouch() ? 10 : 4;
|
const gripRadius = isTouch() ? 10 : 4;
|
||||||
|
|
||||||
@@ -364,7 +363,7 @@ export class SelectorManager {
|
|||||||
r: gripRadius,
|
r: gripRadius,
|
||||||
stroke: '#22C',
|
stroke: '#22C',
|
||||||
'stroke-width': 2,
|
'stroke-width': 2,
|
||||||
style: `cursor:url(${config_.imgPath}/rotate.svg) 12 12, auto;`
|
style: `cursor:url(${this.curConfig.imgPath}/rotate.svg) 12 12, auto;`
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.selectorGripsGroup.append(this.rotateGrip);
|
this.selectorGripsGroup.append(this.rotateGrip);
|
||||||
@@ -372,7 +371,7 @@ export class SelectorManager {
|
|||||||
|
|
||||||
if (document.getElementById('canvasBackground')) { return; }
|
if (document.getElementById('canvasBackground')) { return; }
|
||||||
|
|
||||||
const [ width, height ] = config_.dimensions;
|
const [ width, height ] = this.curConfig.dimensions;
|
||||||
const canvasbg = svgCanvas.createSVGElement({
|
const canvasbg = svgCanvas.createSVGElement({
|
||||||
element: 'svg',
|
element: 'svg',
|
||||||
attr: {
|
attr: {
|
||||||
@@ -531,8 +530,7 @@ export class SelectorManager {
|
|||||||
* @param {module:select.SVGFactory} svgFactory - An object implementing the SVGFactory interface.
|
* @param {module:select.SVGFactory} svgFactory - An object implementing the SVGFactory interface.
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
export const init = function (config, canvas) {
|
export const init = (canvas) => {
|
||||||
config_ = config;
|
|
||||||
svgCanvas = canvas;
|
svgCanvas = canvas;
|
||||||
selectorManager_ = new SelectorManager();
|
selectorManager_ = new SelectorManager();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ class SvgCanvas {
|
|||||||
utilsInit(this);
|
utilsInit(this);
|
||||||
coordsInit(this);
|
coordsInit(this);
|
||||||
recalculateInit(this);
|
recalculateInit(this);
|
||||||
selectInit(this.curConfig, this);
|
selectInit(this);
|
||||||
undoInit(this);
|
undoInit(this);
|
||||||
selectionInit(this);
|
selectionInit(this);
|
||||||
|
|
||||||
@@ -267,34 +267,23 @@ class SvgCanvas {
|
|||||||
blurInit(this);
|
blurInit(this);
|
||||||
selectedElemInit(this);
|
selectedElemInit(this);
|
||||||
|
|
||||||
/**
|
|
||||||
* Flash the clipboard data momentarily on localStorage so all tabs can see.
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
function flashStorage() {
|
|
||||||
const data = sessionStorage.getItem(CLIPBOARD_ID);
|
|
||||||
localStorage.setItem(CLIPBOARD_ID, data);
|
|
||||||
setTimeout(function () {
|
|
||||||
localStorage.removeItem(CLIPBOARD_ID);
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transfers sessionStorage from one tab to another.
|
* Transfers sessionStorage from one tab to another.
|
||||||
* @param {!Event} ev Storage event.
|
* @param {!Event} ev Storage event.
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
function storageChange(ev) {
|
const storageChange = (ev) => {
|
||||||
if (!ev.newValue) return; // This is a call from removeItem.
|
if (!ev.newValue) return; // This is a call from removeItem.
|
||||||
if (ev.key === CLIPBOARD_ID + '_startup') {
|
if (ev.key === CLIPBOARD_ID + '_startup') {
|
||||||
// Another tab asked for our sessionStorage.
|
// Another tab asked for our sessionStorage.
|
||||||
localStorage.removeItem(CLIPBOARD_ID + '_startup');
|
localStorage.removeItem(CLIPBOARD_ID + '_startup');
|
||||||
flashStorage();
|
this.flashStorage();
|
||||||
} else if (ev.key === CLIPBOARD_ID) {
|
} else if (ev.key === CLIPBOARD_ID) {
|
||||||
// Another tab sent data.
|
// Another tab sent data.
|
||||||
sessionStorage.setItem(CLIPBOARD_ID, ev.newValue);
|
sessionStorage.setItem(CLIPBOARD_ID, ev.newValue);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
// Listen for changes to localStorage.
|
// Listen for changes to localStorage.
|
||||||
window.addEventListener('storage', storageChange, false);
|
window.addEventListener('storage', storageChange, false);
|
||||||
@@ -418,6 +407,7 @@ class SvgCanvas {
|
|||||||
setInitBbox(value) { this.initBbox = value; }
|
setInitBbox(value) { this.initBbox = value; }
|
||||||
setRootSctm(value) { this.rootSctm = value; }
|
setRootSctm(value) { this.rootSctm = value; }
|
||||||
setCurrentResizeMode(value) { this.currentResizeMode = value; }
|
setCurrentResizeMode(value) { this.currentResizeMode = value; }
|
||||||
|
getLastClickPoint(key) { return this.lastClickPoint[key]; }
|
||||||
setLastClickPoint(value) { this.lastClickPoint = value; }
|
setLastClickPoint(value) { this.lastClickPoint = value; }
|
||||||
getId() { return this.getCurrentDrawing().getId(); }
|
getId() { return this.getCurrentDrawing().getId(); }
|
||||||
getUIStrings() { return this.uiStrings; }
|
getUIStrings() { return this.uiStrings; }
|
||||||
@@ -557,6 +547,17 @@ class SvgCanvas {
|
|||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
* Flash the clipboard data momentarily on localStorage so all tabs can see.
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
flashStorage() {
|
||||||
|
const data = sessionStorage.getItem(CLIPBOARD_ID);
|
||||||
|
localStorage.setItem(CLIPBOARD_ID, data);
|
||||||
|
setTimeout(function () {
|
||||||
|
localStorage.removeItem(CLIPBOARD_ID);
|
||||||
|
}, 1);
|
||||||
|
}
|
||||||
|
/**
|
||||||
* Selects only the given elements, shortcut for `clearSelection(); addToSelection()`.
|
* Selects only the given elements, shortcut for `clearSelection(); addToSelection()`.
|
||||||
* @function module:svgcanvas.SvgCanvas#selectOnly
|
* @function module:svgcanvas.SvgCanvas#selectOnly
|
||||||
* @param {Element[]} elems - an array of DOM elements to be selected
|
* @param {Element[]} elems - an array of DOM elements to be selected
|
||||||
|
|||||||
Reference in New Issue
Block a user