@gedit/editor-2d 0.2.46 → 0.2.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/model/editor2d-document.d.ts +11 -2
- package/lib/browser/model/editor2d-document.d.ts.map +1 -1
- package/lib/browser/model/editor2d-document.js +44 -8
- package/lib/browser/model/editor2d-document.js.map +1 -1
- package/lib/browser/model/editor2d-model-container.d.ts.map +1 -1
- package/lib/browser/model/editor2d-model-container.js +1 -1
- package/lib/browser/model/editor2d-model-container.js.map +1 -1
- package/lib/browser/model/editor2d-model.d.ts +2 -0
- package/lib/browser/model/editor2d-model.d.ts.map +1 -1
- package/lib/browser/model/editor2d-model.js +5 -0
- package/lib/browser/model/editor2d-model.js.map +1 -1
- package/lib/browser/model/editor2d.d.ts +2 -0
- package/lib/browser/model/editor2d.d.ts.map +1 -1
- package/lib/browser/model/editor2d.js +4 -2
- package/lib/browser/model/editor2d.js.map +1 -1
- package/lib/browser/playground/canvas-draw.d.ts.map +1 -1
- package/lib/browser/playground/canvas-draw.js +30 -27
- package/lib/browser/playground/canvas-draw.js.map +1 -1
- package/lib/browser/playground/canvas-layer.d.ts +14 -2
- package/lib/browser/playground/canvas-layer.d.ts.map +1 -1
- package/lib/browser/playground/canvas-layer.js +96 -50
- package/lib/browser/playground/canvas-layer.js.map +1 -1
- package/lib/browser/playground/index.d.ts +2 -0
- package/lib/browser/playground/index.d.ts.map +1 -1
- package/lib/browser/playground/index.js +2 -0
- package/lib/browser/playground/index.js.map +1 -1
- package/lib/browser/playground/path-edit/index.d.ts +4 -0
- package/lib/browser/playground/path-edit/index.d.ts.map +1 -0
- package/lib/browser/playground/path-edit/index.js +20 -0
- package/lib/browser/playground/path-edit/index.js.map +1 -0
- package/lib/browser/playground/path-edit/path-edit-layer-move-point.d.ts +18 -0
- package/lib/browser/playground/path-edit/path-edit-layer-move-point.d.ts.map +1 -0
- package/lib/browser/playground/path-edit/path-edit-layer-move-point.js +52 -0
- package/lib/browser/playground/path-edit/path-edit-layer-move-point.js.map +1 -0
- package/lib/browser/playground/path-edit/path-edit-layer-svg-path.d.ts +21 -0
- package/lib/browser/playground/path-edit/path-edit-layer-svg-path.d.ts.map +1 -0
- package/lib/browser/playground/path-edit/path-edit-layer-svg-path.js +158 -0
- package/lib/browser/playground/path-edit/path-edit-layer-svg-path.js.map +1 -0
- package/lib/browser/playground/path-edit/utils.d.ts +37 -0
- package/lib/browser/playground/path-edit/utils.d.ts.map +1 -0
- package/lib/browser/playground/path-edit/utils.js +236 -0
- package/lib/browser/playground/path-edit/utils.js.map +1 -0
- package/lib/browser/playground/path-edit-layer.d.ts +32 -12
- package/lib/browser/playground/path-edit-layer.d.ts.map +1 -1
- package/lib/browser/playground/path-edit-layer.js +460 -146
- package/lib/browser/playground/path-edit-layer.js.map +1 -1
- package/lib/browser/playground/playground-context.d.ts +5 -2
- package/lib/browser/playground/playground-context.d.ts.map +1 -1
- package/lib/browser/playground/playground-context.js +13 -2
- package/lib/browser/playground/playground-context.js.map +1 -1
- package/lib/browser/playground/playground-contribution.d.ts +2 -1
- package/lib/browser/playground/playground-contribution.d.ts.map +1 -1
- package/lib/browser/playground/playground-contribution.js +4 -21
- package/lib/browser/playground/playground-contribution.js.map +1 -1
- package/lib/browser/playground/selection-entity-manager.d.ts.map +1 -1
- package/lib/browser/playground/selection-entity-manager.js +24 -8
- package/lib/browser/playground/selection-entity-manager.js.map +1 -1
- package/lib/browser/playground/selector-extend-renderer.d.ts +2 -1
- package/lib/browser/playground/selector-extend-renderer.d.ts.map +1 -1
- package/lib/browser/playground/selector-extend-renderer.js +50 -21
- package/lib/browser/playground/selector-extend-renderer.js.map +1 -1
- package/lib/browser/utils/snapshot.d.ts +1 -0
- package/lib/browser/utils/snapshot.d.ts.map +1 -1
- package/lib/browser/utils/snapshot.js +11 -0
- package/lib/browser/utils/snapshot.js.map +1 -1
- package/package.json +9 -7
- package/src/browser/model/editor2d-document.ts +44 -6
- package/src/browser/model/editor2d-model-container.ts +2 -0
- package/src/browser/model/editor2d-model.ts +2 -0
- package/src/browser/model/editor2d.ts +4 -1
- package/src/browser/playground/canvas-draw.ts +30 -25
- package/src/browser/playground/canvas-layer.ts +97 -52
- package/src/browser/playground/index.ts +2 -0
- package/src/browser/playground/path-edit/index.ts +3 -0
- package/src/browser/playground/path-edit/path-edit-layer-move-point.tsx +108 -0
- package/src/browser/playground/path-edit/path-edit-layer-svg-path.tsx +283 -0
- package/src/browser/playground/path-edit/utils.tsx +285 -0
- package/src/browser/playground/path-edit-layer.tsx +563 -216
- package/src/browser/playground/playground-context.ts +7 -1
- package/src/browser/playground/playground-contribution.ts +2 -21
- package/src/browser/playground/selection-entity-manager.tsx +34 -6
- package/src/browser/playground/selector-extend-renderer.tsx +69 -37
- package/src/browser/style/path-edit-layer.less +17 -30
- package/src/browser/svg/pen_close.svg +24 -0
- package/src/browser/utils/snapshot.ts +11 -0
- package/lib/browser/playground/path-edit-layer-move-point.d.ts +0 -15
- package/lib/browser/playground/path-edit-layer-move-point.d.ts.map +0 -1
- package/lib/browser/playground/path-edit-layer-move-point.js +0 -47
- package/lib/browser/playground/path-edit-layer-move-point.js.map +0 -1
- package/lib/browser/playground/path-edit-layer-svg-path.d.ts +0 -11
- package/lib/browser/playground/path-edit-layer-svg-path.d.ts.map +0 -1
- package/lib/browser/playground/path-edit-layer-svg-path.js +0 -21
- package/lib/browser/playground/path-edit-layer-svg-path.js.map +0 -1
- package/src/browser/playground/path-edit-layer-move-point.tsx +0 -71
- package/src/browser/playground/path-edit-layer-svg-path.tsx +0 -50
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { asVec, getLineWidth, PathChild } from '@gedit/canvas-draw';
|
|
3
|
-
import { PositionSchema } from '@gedit/playground';
|
|
4
|
-
|
|
5
|
-
export interface PointSchema extends PositionSchema {
|
|
6
|
-
id?: string;
|
|
7
|
-
}
|
|
8
|
-
export const PointDefault = ({
|
|
9
|
-
getPosFromMouseEvent,
|
|
10
|
-
paths,
|
|
11
|
-
scale,
|
|
12
|
-
}: {
|
|
13
|
-
getPosFromMouseEvent: (
|
|
14
|
-
event: {
|
|
15
|
-
clientX: number;
|
|
16
|
-
clientY: number;
|
|
17
|
-
},
|
|
18
|
-
addScale?: boolean
|
|
19
|
-
) => PointSchema;
|
|
20
|
-
paths: PathChild[];
|
|
21
|
-
scale: number;
|
|
22
|
-
}) => {
|
|
23
|
-
const domRef = React.useRef<HTMLDivElement>(null);
|
|
24
|
-
const lineRef = React.useRef<HTMLDivElement>(null);
|
|
25
|
-
const pathsRef = React.useRef(paths);
|
|
26
|
-
const onMove = (e: MouseEvent) => {
|
|
27
|
-
const dom = domRef.current;
|
|
28
|
-
const line = lineRef.current;
|
|
29
|
-
if (!dom || !line) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const pos = getPosFromMouseEvent(e);
|
|
33
|
-
dom.style.transform = `translate(${pos.x}px, ${pos.y}px) scale(${
|
|
34
|
-
1 / scale
|
|
35
|
-
})`;
|
|
36
|
-
const endPoint = pathsRef.current[pathsRef.current.length - 1];
|
|
37
|
-
if (endPoint) {
|
|
38
|
-
const width = getLineWidth(endPoint, pos);
|
|
39
|
-
const { ang } = asVec(endPoint, pos);
|
|
40
|
-
line.style.width = `${width}px`;
|
|
41
|
-
line.style.height = `${1 / scale}px`;
|
|
42
|
-
line.style.transform = `translate(${endPoint.x}px, ${
|
|
43
|
-
endPoint.y
|
|
44
|
-
}px) rotate(${(ang / Math.PI) * 180}deg)`;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
React.useEffect(() => {
|
|
48
|
-
pathsRef.current = paths;
|
|
49
|
-
}, [paths]);
|
|
50
|
-
React.useEffect(() => {
|
|
51
|
-
const dom = domRef.current;
|
|
52
|
-
const line = lineRef.current;
|
|
53
|
-
if (dom && line) {
|
|
54
|
-
window.addEventListener('mousemove', onMove);
|
|
55
|
-
}
|
|
56
|
-
return () => {
|
|
57
|
-
if (dom && line) {
|
|
58
|
-
window.removeEventListener('mousemove', onMove);
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
}, []);
|
|
62
|
-
return (
|
|
63
|
-
<>
|
|
64
|
-
<div className="gedit-path-edit-layer-line" ref={lineRef} />
|
|
65
|
-
<div
|
|
66
|
-
className="gedit-path-edit-layer-point gedit-path-edit-layer-point-move gedit-path-edit-layer-pen"
|
|
67
|
-
ref={domRef}
|
|
68
|
-
/>
|
|
69
|
-
</>
|
|
70
|
-
);
|
|
71
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { getPointsToPaths, PathChild } from '@gedit/canvas-draw';
|
|
3
|
-
|
|
4
|
-
export interface PathSVGProps {
|
|
5
|
-
width: number;
|
|
6
|
-
height: number;
|
|
7
|
-
scale: number;
|
|
8
|
-
paths: PathChild[];
|
|
9
|
-
pathProps?: any;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const SvgPath = ({
|
|
13
|
-
width,
|
|
14
|
-
height,
|
|
15
|
-
paths,
|
|
16
|
-
scale,
|
|
17
|
-
pathProps,
|
|
18
|
-
}: PathSVGProps) => {
|
|
19
|
-
// const bezier = getXYToPath(paths);
|
|
20
|
-
const pathsStringArray = getPointsToPaths(paths);
|
|
21
|
-
console.log(getPointsToPaths(paths));
|
|
22
|
-
return (
|
|
23
|
-
<svg
|
|
24
|
-
width={width || 300}
|
|
25
|
-
height={height || 300}
|
|
26
|
-
className="gedit-path-edit-layer-svg"
|
|
27
|
-
>
|
|
28
|
-
{pathsStringArray.map((p, i) => (
|
|
29
|
-
<path
|
|
30
|
-
className="gedit-path-edit-layer-path"
|
|
31
|
-
key={i.toString()}
|
|
32
|
-
{...pathProps}
|
|
33
|
-
strokeLinecap="round"
|
|
34
|
-
strokeWidth={1.5 / scale}
|
|
35
|
-
d={p}
|
|
36
|
-
onMouseDown={e => {
|
|
37
|
-
e.preventDefault();
|
|
38
|
-
e.stopPropagation();
|
|
39
|
-
}}
|
|
40
|
-
onDoubleClick={e => {
|
|
41
|
-
e.preventDefault();
|
|
42
|
-
e.stopPropagation();
|
|
43
|
-
// this.onPathDoubleClick(i, p);
|
|
44
|
-
console.log(3123);
|
|
45
|
-
}}
|
|
46
|
-
/>
|
|
47
|
-
))}
|
|
48
|
-
</svg>
|
|
49
|
-
);
|
|
50
|
-
};
|