Add yet-another-react-lightbox package and update .gitignore to exclude node_modules
This commit is contained in:
21
frontend/node_modules/@svgdotjs/svg.select.js/LICENSE
generated
vendored
21
frontend/node_modules/@svgdotjs/svg.select.js/LICENSE
generated
vendored
@@ -1,21 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Fuzzy
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
105
frontend/node_modules/@svgdotjs/svg.select.js/README.md
generated
vendored
105
frontend/node_modules/@svgdotjs/svg.select.js/README.md
generated
vendored
@@ -1,105 +0,0 @@
|
||||
# svg.select.js
|
||||
|
||||
An extension of [svg.js](https://github.com/svgdotjs/svg.js) which allows to select elements with mouse
|
||||
|
||||
## Demo
|
||||
|
||||
For a demo see http://svgjs.dev/svg.resize.js/
|
||||
|
||||
## Get Started
|
||||
|
||||
- Install `svg.js` and `svg.select.js` using npm:
|
||||
|
||||
```bash
|
||||
npm i @svgdotjs/svg.js @svgdotjs/svg.select.js
|
||||
```
|
||||
|
||||
- Or get it from a cnd:
|
||||
|
||||
```html
|
||||
<script src="https://unpkg.com/@svgdotjs/svg.js"></script>
|
||||
<script src="https://unpkg.com/@svgdotjs/svg.select.js"></script>
|
||||
```
|
||||
|
||||
- Select a rectangle using this simple piece of code:
|
||||
|
||||
```ts
|
||||
var canvas = new SVG().addTo('body').size(500, 500)
|
||||
canvas.rect(50, 50).fill('red').select()
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Select
|
||||
|
||||
```ts
|
||||
var canvas = SVG().addTo('body')
|
||||
var rect = canvas.rect(100, 100)
|
||||
var polygon = canvas.polygon([
|
||||
[100, 100],
|
||||
[200, 100],
|
||||
[200, 200],
|
||||
[100, 200],
|
||||
])
|
||||
rect.select()
|
||||
polygon.pointSelect()
|
||||
|
||||
// both also works
|
||||
polygon.select().pointSelect()
|
||||
```
|
||||
|
||||
Unselect
|
||||
|
||||
```ts
|
||||
rect.select(false)
|
||||
```
|
||||
|
||||
## Adaptation
|
||||
|
||||
Sometimes, the default shape is not to your liking. Therefore, you can create your own handles by passing in a create and update function:
|
||||
|
||||
```ts
|
||||
rect.select({
|
||||
createHandle: (group, p, index, pointArr, handleName) => group.circle(10).css({ stroke: '#666', fill: 'blue' }),
|
||||
updateHandle: (group, p, index, pointArr, handleName) => group.center(p[0], p[1]),
|
||||
createRot: (group) => group.circle(10).css({ stroke: '#666', fill: 'blue' }),
|
||||
updateRot: (group, rotPoint, handlePoints) => group.center(p[0], p[1]),
|
||||
})
|
||||
|
||||
polygon.pointSelect({
|
||||
createHandle: (group, p, index, pointArr, handleName) => group.circle(10).css({ stroke: '#666', fill: 'blue' }),
|
||||
updateHandle: (group, p, index, pointArr, handleName) => group.center(p[0], p[1]),
|
||||
})
|
||||
```
|
||||
|
||||
You can style the selection with the classes
|
||||
|
||||
- `svg_select_shape` - _normal selection_
|
||||
- `svg_select_shape_pointSelection` - _point selection_
|
||||
- `svg_select_handle`- _any normal selection handles_
|
||||
- `svg_select_handle_lt` - _left top_
|
||||
- `svg_select_handle_rt` - _right top_
|
||||
- `svg_select_handle_rb` - _right bottom_
|
||||
- `svg_select_handle_lb` - _left bottom_
|
||||
- `svg_select_handle_t` - _top_
|
||||
- `svg_select_handle_r` - _right_
|
||||
- `svg_select_handle_b` - _bottom_
|
||||
- `svg_select_handle_l` - _left_
|
||||
- `svg_select_handle_rot` - _rotation point_
|
||||
- `svg_select_handle_point` - _point select point_
|
||||
|
||||
## Contributing
|
||||
|
||||
```bash
|
||||
git clone https://github.com/svgdotjs/svg.select.js.git
|
||||
cd svg.select.js
|
||||
npm install
|
||||
npm run dev
|
||||
```
|
||||
|
||||
## Migration from svg.js v2
|
||||
|
||||
- The css classes changed. In case you used your own styling, you'll need to adapt
|
||||
- A lot of options got dropped in favor of the `create` and `update` functions
|
||||
- In case you want to hide certain handles, just create an element without any size and pass a noop to update
|
||||
- the deepSelect option was moved to its own function and renamed to `pointSelect`
|
||||
1
frontend/node_modules/@svgdotjs/svg.select.js/dist/svg.select.css
generated
vendored
1
frontend/node_modules/@svgdotjs/svg.select.js/dist/svg.select.css
generated
vendored
@@ -1 +0,0 @@
|
||||
.svg_select_shape{stroke-width:1;stroke-dasharray:10 10;stroke:#000;stroke-opacity:.1;pointer-events:none;fill:none}.svg_select_shape_pointSelect{stroke-width:1;fill:none;stroke-dasharray:10 10;stroke:#000;stroke-opacity:.8;pointer-events:none}.svg_select_handle{stroke-width:3;stroke:#000;fill:none}.svg_select_handle_rot{fill:#fff;stroke:#000;stroke-width:1;cursor:move}.svg_select_handle_lt{cursor:nw-resize}.svg_select_handle_rt{cursor:ne-resize}.svg_select_handle_rb{cursor:se-resize}.svg_select_handle_lb{cursor:sw-resize}.svg_select_handle_t{cursor:n-resize}.svg_select_handle_r{cursor:e-resize}.svg_select_handle_b{cursor:s-resize}.svg_select_handle_l{cursor:w-resize}.svg_select_handle_point{stroke:#000;stroke-width:1;cursor:move;fill:#fff}
|
||||
3
frontend/node_modules/@svgdotjs/svg.select.js/dist/svg.select.iife.js
generated
vendored
3
frontend/node_modules/@svgdotjs/svg.select.js/dist/svg.select.iife.js
generated
vendored
File diff suppressed because one or more lines are too long
1
frontend/node_modules/@svgdotjs/svg.select.js/dist/svg.select.iife.js.map
generated
vendored
1
frontend/node_modules/@svgdotjs/svg.select.js/dist/svg.select.iife.js.map
generated
vendored
File diff suppressed because one or more lines are too long
239
frontend/node_modules/@svgdotjs/svg.select.js/dist/svg.select.js
generated
vendored
239
frontend/node_modules/@svgdotjs/svg.select.js/dist/svg.select.js
generated
vendored
@@ -1,239 +0,0 @@
|
||||
/*!
|
||||
* @svgdotjs/svg.select.js - An extension of svg.js which allows to select elements with mouse
|
||||
* @version 4.0.2
|
||||
* https://github.com/svgdotjs/svg.select.js
|
||||
*
|
||||
* @copyright Ulrich-Matthias Schäfer
|
||||
* @license MIT
|
||||
*
|
||||
* BUILT: Wed Nov 20 2024 23:17:23 GMT+0100 (Central European Standard Time)
|
||||
*/
|
||||
;
|
||||
import { G, getWindow, extend, Element, Polygon, Polyline, Line } from "@svgdotjs/svg.js";
|
||||
function getMoseDownFunc(eventName, el, points, index = null) {
|
||||
return function(ev) {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
var x = ev.pageX || ev.touches[0].pageX;
|
||||
var y = ev.pageY || ev.touches[0].pageY;
|
||||
el.fire(eventName, { x, y, event: ev, index, points });
|
||||
};
|
||||
}
|
||||
function transformPoint([x, y], { a, b, c, d, e, f }) {
|
||||
return [x * a + y * c + e, x * b + y * d + f];
|
||||
}
|
||||
class SelectHandler {
|
||||
constructor(el) {
|
||||
this.el = el;
|
||||
el.remember("_selectHandler", this);
|
||||
this.selection = new G();
|
||||
this.order = ["lt", "t", "rt", "r", "rb", "b", "lb", "l", "rot"];
|
||||
this.mutationHandler = this.mutationHandler.bind(this);
|
||||
const win = getWindow();
|
||||
this.observer = new win.MutationObserver(this.mutationHandler);
|
||||
}
|
||||
init(options) {
|
||||
this.createHandle = options.createHandle || this.createHandleFn;
|
||||
this.createRot = options.createRot || this.createRotFn;
|
||||
this.updateHandle = options.updateHandle || this.updateHandleFn;
|
||||
this.updateRot = options.updateRot || this.updateRotFn;
|
||||
this.el.root().put(this.selection);
|
||||
this.updatePoints();
|
||||
this.createSelection();
|
||||
this.createResizeHandles();
|
||||
this.updateResizeHandles();
|
||||
this.createRotationHandle();
|
||||
this.updateRotationHandle();
|
||||
this.observer.observe(this.el.node, { attributes: true });
|
||||
}
|
||||
active(val, options) {
|
||||
if (!val) {
|
||||
this.selection.clear().remove();
|
||||
this.observer.disconnect();
|
||||
return;
|
||||
}
|
||||
this.init(options);
|
||||
}
|
||||
createSelection() {
|
||||
this.selection.polygon(this.handlePoints).addClass("svg_select_shape");
|
||||
}
|
||||
updateSelection() {
|
||||
this.selection.get(0).plot(this.handlePoints);
|
||||
}
|
||||
createResizeHandles() {
|
||||
this.handlePoints.forEach((p, index, arr) => {
|
||||
const name = this.order[index];
|
||||
this.createHandle.call(this, this.selection, p, index, arr, name);
|
||||
this.selection.get(index + 1).addClass("svg_select_handle svg_select_handle_" + name).on("mousedown.selection touchstart.selection", getMoseDownFunc(name, this.el, this.handlePoints, index));
|
||||
});
|
||||
}
|
||||
createHandleFn(group) {
|
||||
group.polyline();
|
||||
}
|
||||
updateHandleFn(shape, point, index, arr) {
|
||||
const before = arr.at(index - 1);
|
||||
const next = arr[(index + 1) % arr.length];
|
||||
const p = point;
|
||||
const diff1 = [p[0] - before[0], p[1] - before[1]];
|
||||
const diff2 = [p[0] - next[0], p[1] - next[1]];
|
||||
const len1 = Math.sqrt(diff1[0] * diff1[0] + diff1[1] * diff1[1]);
|
||||
const len2 = Math.sqrt(diff2[0] * diff2[0] + diff2[1] * diff2[1]);
|
||||
const normalized1 = [diff1[0] / len1, diff1[1] / len1];
|
||||
const normalized2 = [diff2[0] / len2, diff2[1] / len2];
|
||||
const beforeNew = [p[0] - normalized1[0] * 10, p[1] - normalized1[1] * 10];
|
||||
const nextNew = [p[0] - normalized2[0] * 10, p[1] - normalized2[1] * 10];
|
||||
shape.plot([beforeNew, p, nextNew]);
|
||||
}
|
||||
updateResizeHandles() {
|
||||
this.handlePoints.forEach((p, index, arr) => {
|
||||
const name = this.order[index];
|
||||
this.updateHandle.call(this, this.selection.get(index + 1), p, index, arr, name);
|
||||
});
|
||||
}
|
||||
createRotFn(group) {
|
||||
group.line();
|
||||
group.circle(5);
|
||||
}
|
||||
getPoint(name) {
|
||||
return this.handlePoints[this.order.indexOf(name)];
|
||||
}
|
||||
getPointHandle(name) {
|
||||
return this.selection.get(this.order.indexOf(name) + 1);
|
||||
}
|
||||
updateRotFn(group, rotPoint) {
|
||||
const topPoint = this.getPoint("t");
|
||||
group.get(0).plot(topPoint[0], topPoint[1], rotPoint[0], rotPoint[1]);
|
||||
group.get(1).center(rotPoint[0], rotPoint[1]);
|
||||
}
|
||||
createRotationHandle() {
|
||||
const handle = this.selection.group().addClass("svg_select_handle_rot").on("mousedown.selection touchstart.selection", getMoseDownFunc("rot", this.el, this.handlePoints));
|
||||
this.createRot.call(this, handle);
|
||||
}
|
||||
updateRotationHandle() {
|
||||
const group = this.selection.findOne("g.svg_select_handle_rot");
|
||||
this.updateRot(group, this.rotationPoint, this.handlePoints);
|
||||
}
|
||||
// gets new bounding box points and transform them into the elements space
|
||||
updatePoints() {
|
||||
const bbox = this.el.bbox();
|
||||
const fromShapeToUiMatrix = this.el.root().screenCTM().inverseO().multiplyO(this.el.screenCTM());
|
||||
this.handlePoints = this.getHandlePoints(bbox).map((p) => transformPoint(p, fromShapeToUiMatrix));
|
||||
this.rotationPoint = transformPoint(this.getRotationPoint(bbox), fromShapeToUiMatrix);
|
||||
}
|
||||
// A collection of all the points we need to draw our ui
|
||||
getHandlePoints({ x, x2, y, y2, cx, cy } = this.el.bbox()) {
|
||||
return [
|
||||
[x, y],
|
||||
[cx, y],
|
||||
[x2, y],
|
||||
[x2, cy],
|
||||
[x2, y2],
|
||||
[cx, y2],
|
||||
[x, y2],
|
||||
[x, cy]
|
||||
];
|
||||
}
|
||||
// A collection of all the points we need to draw our ui
|
||||
getRotationPoint({ y, cx } = this.el.bbox()) {
|
||||
return [cx, y - 20];
|
||||
}
|
||||
mutationHandler() {
|
||||
this.updatePoints();
|
||||
this.updateSelection();
|
||||
this.updateResizeHandles();
|
||||
this.updateRotationHandle();
|
||||
}
|
||||
}
|
||||
class PointSelectHandler {
|
||||
constructor(el) {
|
||||
this.el = el;
|
||||
el.remember("_pointSelectHandler", this);
|
||||
this.selection = new G();
|
||||
this.order = ["lt", "t", "rt", "r", "rb", "b", "lb", "l", "rot"];
|
||||
this.mutationHandler = this.mutationHandler.bind(this);
|
||||
const win = getWindow();
|
||||
this.observer = new win.MutationObserver(this.mutationHandler);
|
||||
}
|
||||
init(options) {
|
||||
this.createHandle = options.createHandle || this.createHandleFn;
|
||||
this.updateHandle = options.updateHandle || this.updateHandleFn;
|
||||
this.el.root().put(this.selection);
|
||||
this.updatePoints();
|
||||
this.createSelection();
|
||||
this.createPointHandles();
|
||||
this.updatePointHandles();
|
||||
this.observer.observe(this.el.node, { attributes: true });
|
||||
}
|
||||
active(val, options) {
|
||||
if (!val) {
|
||||
this.selection.clear().remove();
|
||||
this.observer.disconnect();
|
||||
return;
|
||||
}
|
||||
this.init(options);
|
||||
}
|
||||
createSelection() {
|
||||
this.selection.polygon(this.points).addClass("svg_select_shape_pointSelect");
|
||||
}
|
||||
updateSelection() {
|
||||
this.selection.get(0).plot(this.points);
|
||||
}
|
||||
createPointHandles() {
|
||||
this.points.forEach((p, index, arr) => {
|
||||
this.createHandle.call(this, this.selection, p, index, arr);
|
||||
this.selection.get(index + 1).addClass("svg_select_handle_point").on("mousedown.selection touchstart.selection", getMoseDownFunc("point", this.el, this.points, index));
|
||||
});
|
||||
}
|
||||
createHandleFn(group) {
|
||||
group.circle(5);
|
||||
}
|
||||
updateHandleFn(shape, point) {
|
||||
shape.center(point[0], point[1]);
|
||||
}
|
||||
updatePointHandles() {
|
||||
this.points.forEach((p, index, arr) => {
|
||||
this.updateHandle.call(this, this.selection.get(index + 1), p, index, arr);
|
||||
});
|
||||
}
|
||||
// gets new bounding box points and transform them into the elements space
|
||||
updatePoints() {
|
||||
const fromShapeToUiMatrix = this.el.parent().screenCTM().inverseO().multiplyO(this.el.screenCTM());
|
||||
this.points = this.el.array().map((p) => transformPoint(p, fromShapeToUiMatrix));
|
||||
}
|
||||
mutationHandler() {
|
||||
this.updatePoints();
|
||||
this.updateSelection();
|
||||
this.updatePointHandles();
|
||||
}
|
||||
}
|
||||
const getSelectFn = (handleClass) => {
|
||||
return function(enabled = true, options = {}) {
|
||||
if (typeof enabled === "object") {
|
||||
options = enabled;
|
||||
enabled = true;
|
||||
}
|
||||
let selectHandler = this.remember("_" + handleClass.name);
|
||||
if (!selectHandler) {
|
||||
if (enabled.prototype instanceof SelectHandler) {
|
||||
selectHandler = new enabled(this);
|
||||
enabled = true;
|
||||
} else {
|
||||
selectHandler = new handleClass(this);
|
||||
}
|
||||
this.remember("_" + handleClass.name, selectHandler);
|
||||
}
|
||||
selectHandler.active(enabled, options);
|
||||
return this;
|
||||
};
|
||||
};
|
||||
extend(Element, {
|
||||
select: getSelectFn(SelectHandler)
|
||||
});
|
||||
extend([Polygon, Polyline, Line], {
|
||||
pointSelect: getSelectFn(PointSelectHandler)
|
||||
});
|
||||
export {
|
||||
PointSelectHandler,
|
||||
SelectHandler
|
||||
};
|
||||
//# sourceMappingURL=svg.select.js.map
|
||||
1
frontend/node_modules/@svgdotjs/svg.select.js/dist/svg.select.js.map
generated
vendored
1
frontend/node_modules/@svgdotjs/svg.select.js/dist/svg.select.js.map
generated
vendored
File diff suppressed because one or more lines are too long
3
frontend/node_modules/@svgdotjs/svg.select.js/dist/svg.select.umd.cjs
generated
vendored
3
frontend/node_modules/@svgdotjs/svg.select.js/dist/svg.select.umd.cjs
generated
vendored
File diff suppressed because one or more lines are too long
1
frontend/node_modules/@svgdotjs/svg.select.js/dist/svg.select.umd.cjs.map
generated
vendored
1
frontend/node_modules/@svgdotjs/svg.select.js/dist/svg.select.umd.cjs.map
generated
vendored
File diff suppressed because one or more lines are too long
61
frontend/node_modules/@svgdotjs/svg.select.js/package.json
generated
vendored
61
frontend/node_modules/@svgdotjs/svg.select.js/package.json
generated
vendored
@@ -1,61 +0,0 @@
|
||||
{
|
||||
"name": "@svgdotjs/svg.select.js",
|
||||
"version": "4.0.2",
|
||||
"description": "An extension of svg.js which allows to select elements with mouse",
|
||||
"type": "module",
|
||||
"keywords": [
|
||||
"svg.js",
|
||||
"select",
|
||||
"mouse"
|
||||
],
|
||||
"bugs": "https://github.com/svgdotjs/svg.select.js/issues",
|
||||
"license": "MIT",
|
||||
"author": "Ulrich-Matthias Schäfer",
|
||||
"homepage": "https://github.com/svgdotjs/svg.select.js",
|
||||
"main": "dist/svg.select.umd.cjs",
|
||||
"unpkg": "dist/svg.select.iife.js",
|
||||
"jsdelivr": "dist/svg.select.iife.js",
|
||||
"browser": "dist/svg.select.js",
|
||||
"module": "dist/svg.select.js",
|
||||
"typings": "./svg.select.js.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./svg.select.js.d.ts",
|
||||
"import": "./dist/svg.select.js",
|
||||
"require": "./dist/svg.select.umd.cjs"
|
||||
},
|
||||
"./src/*": "./src/"
|
||||
},
|
||||
"files": [
|
||||
"/dist",
|
||||
"/src",
|
||||
"/svg.select.js.d.ts"
|
||||
],
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc && prettier --write . && eslint ./src && vite build",
|
||||
"zip": "zip -j dist/svg.select.js.zip -- LICENSE README.md dist/svg.select.css dist/svg.select.iife.js dist/svg.select.iife.js.map dist/svg.select.js dist/svg.select.js.map dist/svg.select.umd.cjs dist/svg.select.umd.cjs.map",
|
||||
"prepublishOnly": "rm -rf ./dist && npm run build",
|
||||
"postpublish": "npm run zip"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/svgdotjs/svg.select.js.git"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 14.18"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.14.7",
|
||||
"@vitejs/plugin-vue": "^5.0.5",
|
||||
"eslint-plugin-import-x": "^0.5.2",
|
||||
"prettier": "^3.3.2",
|
||||
"terser": "^5.31.1",
|
||||
"typescript": "^5.2.2",
|
||||
"vite": "^5.2.0",
|
||||
"eslint": "^9.6.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@svgdotjs/svg.js": "^3.2.4"
|
||||
}
|
||||
}
|
||||
87
frontend/node_modules/@svgdotjs/svg.select.js/src/PointSelectHandler.js
generated
vendored
87
frontend/node_modules/@svgdotjs/svg.select.js/src/PointSelectHandler.js
generated
vendored
@@ -1,87 +0,0 @@
|
||||
import { G, getWindow } from '@svgdotjs/svg.js'
|
||||
import { getMoseDownFunc, transformPoint } from './utils'
|
||||
|
||||
export class PointSelectHandler {
|
||||
constructor(el) {
|
||||
this.el = el
|
||||
el.remember('_pointSelectHandler', this)
|
||||
this.selection = new G()
|
||||
this.order = ['lt', 't', 'rt', 'r', 'rb', 'b', 'lb', 'l', 'rot']
|
||||
this.mutationHandler = this.mutationHandler.bind(this)
|
||||
|
||||
const win = getWindow()
|
||||
this.observer = new win.MutationObserver(this.mutationHandler)
|
||||
}
|
||||
|
||||
init(options) {
|
||||
this.createHandle = options.createHandle || this.createHandleFn
|
||||
this.updateHandle = options.updateHandle || this.updateHandleFn
|
||||
|
||||
// mount group
|
||||
this.el.root().put(this.selection)
|
||||
|
||||
this.updatePoints()
|
||||
this.createSelection()
|
||||
this.createPointHandles()
|
||||
this.updatePointHandles()
|
||||
this.observer.observe(this.el.node, { attributes: true })
|
||||
}
|
||||
|
||||
active(val, options) {
|
||||
// Disable selection
|
||||
if (!val) {
|
||||
this.selection.clear().remove()
|
||||
this.observer.disconnect()
|
||||
return
|
||||
}
|
||||
|
||||
// Enable selection
|
||||
this.init(options)
|
||||
}
|
||||
|
||||
createSelection() {
|
||||
this.selection.polygon(this.points).addClass('svg_select_shape_pointSelect')
|
||||
}
|
||||
|
||||
updateSelection() {
|
||||
this.selection.get(0).plot(this.points)
|
||||
}
|
||||
|
||||
createPointHandles() {
|
||||
this.points.forEach((p, index, arr) => {
|
||||
this.createHandle.call(this, this.selection, p, index, arr)
|
||||
|
||||
this.selection
|
||||
.get(index + 1)
|
||||
.addClass('svg_select_handle_point')
|
||||
.on('mousedown.selection touchstart.selection', getMoseDownFunc('point', this.el, this.points, index))
|
||||
})
|
||||
}
|
||||
|
||||
createHandleFn(group) {
|
||||
group.circle(5)
|
||||
}
|
||||
|
||||
updateHandleFn(shape, point) {
|
||||
shape.center(point[0], point[1])
|
||||
}
|
||||
|
||||
updatePointHandles() {
|
||||
this.points.forEach((p, index, arr) => {
|
||||
this.updateHandle.call(this, this.selection.get(index + 1), p, index, arr)
|
||||
})
|
||||
}
|
||||
|
||||
// gets new bounding box points and transform them into the elements space
|
||||
updatePoints() {
|
||||
const fromShapeToUiMatrix = this.el.parent().screenCTM().inverseO().multiplyO(this.el.screenCTM())
|
||||
this.points = this.el.array().map((p) => transformPoint(p, fromShapeToUiMatrix))
|
||||
}
|
||||
|
||||
mutationHandler() {
|
||||
this.updatePoints()
|
||||
|
||||
this.updateSelection()
|
||||
this.updatePointHandles()
|
||||
}
|
||||
}
|
||||
166
frontend/node_modules/@svgdotjs/svg.select.js/src/SelectHandler.js
generated
vendored
166
frontend/node_modules/@svgdotjs/svg.select.js/src/SelectHandler.js
generated
vendored
@@ -1,166 +0,0 @@
|
||||
import { G, getWindow } from '@svgdotjs/svg.js'
|
||||
import { getMoseDownFunc, transformPoint } from './utils'
|
||||
|
||||
export class SelectHandler {
|
||||
constructor(el) {
|
||||
this.el = el
|
||||
el.remember('_selectHandler', this)
|
||||
this.selection = new G()
|
||||
this.order = ['lt', 't', 'rt', 'r', 'rb', 'b', 'lb', 'l', 'rot']
|
||||
this.mutationHandler = this.mutationHandler.bind(this)
|
||||
|
||||
const win = getWindow()
|
||||
this.observer = new win.MutationObserver(this.mutationHandler)
|
||||
}
|
||||
|
||||
init(options) {
|
||||
this.createHandle = options.createHandle || this.createHandleFn
|
||||
this.createRot = options.createRot || this.createRotFn
|
||||
|
||||
this.updateHandle = options.updateHandle || this.updateHandleFn
|
||||
this.updateRot = options.updateRot || this.updateRotFn
|
||||
|
||||
// mount group
|
||||
this.el.root().put(this.selection)
|
||||
|
||||
this.updatePoints()
|
||||
this.createSelection()
|
||||
this.createResizeHandles()
|
||||
this.updateResizeHandles()
|
||||
this.createRotationHandle()
|
||||
this.updateRotationHandle()
|
||||
this.observer.observe(this.el.node, { attributes: true })
|
||||
}
|
||||
|
||||
active(val, options) {
|
||||
// Disable selection
|
||||
if (!val) {
|
||||
this.selection.clear().remove()
|
||||
this.observer.disconnect()
|
||||
return
|
||||
}
|
||||
|
||||
// Enable selection
|
||||
this.init(options)
|
||||
}
|
||||
|
||||
createSelection() {
|
||||
this.selection.polygon(this.handlePoints).addClass('svg_select_shape')
|
||||
}
|
||||
|
||||
updateSelection() {
|
||||
this.selection.get(0).plot(this.handlePoints)
|
||||
}
|
||||
|
||||
createResizeHandles() {
|
||||
this.handlePoints.forEach((p, index, arr) => {
|
||||
const name = this.order[index]
|
||||
this.createHandle.call(this, this.selection, p, index, arr, name)
|
||||
|
||||
this.selection
|
||||
.get(index + 1)
|
||||
.addClass('svg_select_handle svg_select_handle_' + name)
|
||||
.on('mousedown.selection touchstart.selection', getMoseDownFunc(name, this.el, this.handlePoints, index))
|
||||
})
|
||||
}
|
||||
|
||||
createHandleFn(group) {
|
||||
group.polyline()
|
||||
}
|
||||
|
||||
updateHandleFn(shape, point, index, arr) {
|
||||
const before = arr.at(index - 1)
|
||||
const next = arr[(index + 1) % arr.length]
|
||||
const p = point
|
||||
|
||||
const diff1 = [p[0] - before[0], p[1] - before[1]]
|
||||
const diff2 = [p[0] - next[0], p[1] - next[1]]
|
||||
|
||||
const len1 = Math.sqrt(diff1[0] * diff1[0] + diff1[1] * diff1[1])
|
||||
const len2 = Math.sqrt(diff2[0] * diff2[0] + diff2[1] * diff2[1])
|
||||
|
||||
const normalized1 = [diff1[0] / len1, diff1[1] / len1]
|
||||
const normalized2 = [diff2[0] / len2, diff2[1] / len2]
|
||||
|
||||
const beforeNew = [p[0] - normalized1[0] * 10, p[1] - normalized1[1] * 10]
|
||||
const nextNew = [p[0] - normalized2[0] * 10, p[1] - normalized2[1] * 10]
|
||||
|
||||
shape.plot([beforeNew, p, nextNew])
|
||||
}
|
||||
|
||||
updateResizeHandles() {
|
||||
this.handlePoints.forEach((p, index, arr) => {
|
||||
const name = this.order[index]
|
||||
this.updateHandle.call(this, this.selection.get(index + 1), p, index, arr, name)
|
||||
})
|
||||
}
|
||||
|
||||
createRotFn(group) {
|
||||
group.line()
|
||||
group.circle(5)
|
||||
}
|
||||
|
||||
getPoint(name) {
|
||||
return this.handlePoints[this.order.indexOf(name)]
|
||||
}
|
||||
|
||||
getPointHandle(name) {
|
||||
return this.selection.get(this.order.indexOf(name) + 1)
|
||||
}
|
||||
|
||||
updateRotFn(group, rotPoint) {
|
||||
const topPoint = this.getPoint('t')
|
||||
group.get(0).plot(topPoint[0], topPoint[1], rotPoint[0], rotPoint[1])
|
||||
group.get(1).center(rotPoint[0], rotPoint[1])
|
||||
}
|
||||
|
||||
createRotationHandle() {
|
||||
const handle = this.selection
|
||||
.group()
|
||||
.addClass('svg_select_handle_rot')
|
||||
.on('mousedown.selection touchstart.selection', getMoseDownFunc('rot', this.el, this.handlePoints))
|
||||
|
||||
this.createRot.call(this, handle)
|
||||
}
|
||||
|
||||
updateRotationHandle() {
|
||||
const group = this.selection.findOne('g.svg_select_handle_rot')
|
||||
this.updateRot(group, this.rotationPoint, this.handlePoints)
|
||||
}
|
||||
|
||||
// gets new bounding box points and transform them into the elements space
|
||||
updatePoints() {
|
||||
const bbox = this.el.bbox()
|
||||
const fromShapeToUiMatrix = this.el.root().screenCTM().inverseO().multiplyO(this.el.screenCTM())
|
||||
|
||||
this.handlePoints = this.getHandlePoints(bbox).map((p) => transformPoint(p, fromShapeToUiMatrix))
|
||||
this.rotationPoint = transformPoint(this.getRotationPoint(bbox), fromShapeToUiMatrix)
|
||||
}
|
||||
|
||||
// A collection of all the points we need to draw our ui
|
||||
getHandlePoints({ x, x2, y, y2, cx, cy } = this.el.bbox()) {
|
||||
return [
|
||||
[x, y],
|
||||
[cx, y],
|
||||
[x2, y],
|
||||
[x2, cy],
|
||||
[x2, y2],
|
||||
[cx, y2],
|
||||
[x, y2],
|
||||
[x, cy],
|
||||
]
|
||||
}
|
||||
|
||||
// A collection of all the points we need to draw our ui
|
||||
getRotationPoint({ y, cx } = this.el.bbox()) {
|
||||
return [cx, y - 20]
|
||||
}
|
||||
|
||||
mutationHandler() {
|
||||
this.updatePoints()
|
||||
|
||||
this.updateSelection()
|
||||
this.updateResizeHandles()
|
||||
this.updateRotationHandle()
|
||||
}
|
||||
}
|
||||
2
frontend/node_modules/@svgdotjs/svg.select.js/src/main.js
generated
vendored
2
frontend/node_modules/@svgdotjs/svg.select.js/src/main.js
generated
vendored
@@ -1,2 +0,0 @@
|
||||
import './svg.select.css'
|
||||
export * from './svg.select.js'
|
||||
62
frontend/node_modules/@svgdotjs/svg.select.js/src/svg.select.css
generated
vendored
62
frontend/node_modules/@svgdotjs/svg.select.js/src/svg.select.css
generated
vendored
@@ -1,62 +0,0 @@
|
||||
.svg_select_shape {
|
||||
stroke-width: 1;
|
||||
stroke-dasharray: 10 10;
|
||||
stroke: black;
|
||||
stroke-opacity: 0.1;
|
||||
pointer-events: none;
|
||||
fill: none;
|
||||
}
|
||||
|
||||
.svg_select_shape_pointSelect {
|
||||
stroke-width: 1;
|
||||
fill: none;
|
||||
stroke-dasharray: 10 10;
|
||||
stroke: black;
|
||||
stroke-opacity: 0.8;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.svg_select_handle {
|
||||
stroke-width: 3;
|
||||
stroke: black;
|
||||
fill: none;
|
||||
}
|
||||
|
||||
.svg_select_handle_rot {
|
||||
fill: white;
|
||||
stroke: black;
|
||||
stroke-width: 1;
|
||||
cursor: move;
|
||||
}
|
||||
|
||||
.svg_select_handle_lt {
|
||||
cursor: nw-resize;
|
||||
}
|
||||
.svg_select_handle_rt {
|
||||
cursor: ne-resize;
|
||||
}
|
||||
.svg_select_handle_rb {
|
||||
cursor: se-resize;
|
||||
}
|
||||
.svg_select_handle_lb {
|
||||
cursor: sw-resize;
|
||||
}
|
||||
.svg_select_handle_t {
|
||||
cursor: n-resize;
|
||||
}
|
||||
.svg_select_handle_r {
|
||||
cursor: e-resize;
|
||||
}
|
||||
.svg_select_handle_b {
|
||||
cursor: s-resize;
|
||||
}
|
||||
.svg_select_handle_l {
|
||||
cursor: w-resize;
|
||||
}
|
||||
|
||||
.svg_select_handle_point {
|
||||
stroke: black;
|
||||
stroke-width: 1;
|
||||
cursor: move;
|
||||
fill: white;
|
||||
}
|
||||
39
frontend/node_modules/@svgdotjs/svg.select.js/src/svg.select.js
generated
vendored
39
frontend/node_modules/@svgdotjs/svg.select.js/src/svg.select.js
generated
vendored
@@ -1,39 +0,0 @@
|
||||
import { Element, Line, Polygon, Polyline, extend } from '@svgdotjs/svg.js'
|
||||
import { SelectHandler } from './SelectHandler'
|
||||
import { PointSelectHandler } from './PointSelectHandler'
|
||||
|
||||
const getSelectFn = (handleClass) => {
|
||||
return function (enabled = true, options = {}) {
|
||||
if (typeof enabled === 'object') {
|
||||
options = enabled
|
||||
enabled = true
|
||||
}
|
||||
|
||||
let selectHandler = this.remember('_' + handleClass.name)
|
||||
|
||||
if (!selectHandler) {
|
||||
if (enabled.prototype instanceof SelectHandler) {
|
||||
selectHandler = new enabled(this)
|
||||
enabled = true
|
||||
} else {
|
||||
selectHandler = new handleClass(this)
|
||||
}
|
||||
|
||||
this.remember('_' + handleClass.name, selectHandler)
|
||||
}
|
||||
|
||||
selectHandler.active(enabled, options)
|
||||
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
extend(Element, {
|
||||
select: getSelectFn(SelectHandler),
|
||||
})
|
||||
|
||||
extend([Polygon, Polyline, Line], {
|
||||
pointSelect: getSelectFn(PointSelectHandler),
|
||||
})
|
||||
|
||||
export { SelectHandler, PointSelectHandler }
|
||||
20
frontend/node_modules/@svgdotjs/svg.select.js/src/utils.js
generated
vendored
20
frontend/node_modules/@svgdotjs/svg.select.js/src/utils.js
generated
vendored
@@ -1,20 +0,0 @@
|
||||
/**
|
||||
*
|
||||
* @param {string} eventName
|
||||
* @param {import('@svgdotjs/svg.js').Element} el
|
||||
* @param {number | null} index
|
||||
*/
|
||||
export function getMoseDownFunc(eventName, el, points, index = null) {
|
||||
return function (ev) {
|
||||
ev.preventDefault()
|
||||
ev.stopPropagation()
|
||||
|
||||
var x = ev.pageX || ev.touches[0].pageX
|
||||
var y = ev.pageY || ev.touches[0].pageY
|
||||
el.fire(eventName, { x: x, y: y, event: ev, index, points })
|
||||
}
|
||||
}
|
||||
|
||||
export function transformPoint([x, y], { a, b, c, d, e, f }) {
|
||||
return [x * a + y * c + e, x * b + y * d + f]
|
||||
}
|
||||
40
frontend/node_modules/@svgdotjs/svg.select.js/svg.select.js.d.ts
generated
vendored
40
frontend/node_modules/@svgdotjs/svg.select.js/svg.select.js.d.ts
generated
vendored
@@ -1,40 +0,0 @@
|
||||
import { SelectHandler, PointSelectHandler } from './src/SelectHandler.js'
|
||||
|
||||
interface SelectionOptions {
|
||||
createHandle?: (el: Element) => Element
|
||||
updateHandle?: (el: Element, point: number[]) => void
|
||||
createRot?: (el: Element) => Element
|
||||
updateRot?: (el: Element, rotPoint: number[], handlePoints: number[][]) => void
|
||||
}
|
||||
|
||||
declare module '@svgdotjs/svg.js' {
|
||||
interface Element {
|
||||
select(): this
|
||||
select(enable: boolean): this
|
||||
select(options: SelectionOptions): this
|
||||
select(handler: SelectHandler): this
|
||||
select(attr?: SelectHandler | SelectionOptions | boolean): this
|
||||
}
|
||||
|
||||
interface Polygon {
|
||||
pointSelect(): this
|
||||
pointSelect(enable: boolean): this
|
||||
pointSelect(options: SelectionOptions): this
|
||||
pointSelect(handler: PointSelectHandler): this
|
||||
pointSelect(attr?: PointSelectHandler | SelectionOptions | boolean): this
|
||||
}
|
||||
interface Polyline {
|
||||
pointSelect(): this
|
||||
pointSelect(enable: boolean): this
|
||||
pointSelect(options: SelectionOptions): this
|
||||
pointSelect(handler: PointSelectHandler): this
|
||||
pointSelect(attr?: PointSelectHandler | SelectionOptions | boolean): this
|
||||
}
|
||||
interface Line {
|
||||
pointSelect(): this
|
||||
pointSelect(enable: boolean): this
|
||||
pointSelect(options: SelectionOptions): this
|
||||
pointSelect(handler: PointSelectHandler): this
|
||||
pointSelect(attr?: PointSelectHandler | SelectionOptions | boolean): this
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user