@netless/fastboard 0.0.10 → 0.2.0
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/LICENSE.txt +1 -1
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +7 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +26 -79
- package/src/index.ts +2 -34
- package/README.md +0 -126
- package/dist/index.cjs.js +0 -14
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.es.js +0 -2642
- package/dist/index.es.js.map +0 -1
- package/dist/svelte.cjs.js +0 -2
- package/dist/svelte.cjs.js.map +0 -1
- package/dist/svelte.es.js +0 -31
- package/dist/svelte.es.js.map +0 -1
- package/dist/vue.cjs.js +0 -2
- package/dist/vue.cjs.js.map +0 -1
- package/dist/vue.es.js +0 -42
- package/dist/vue.es.js.map +0 -1
- package/src/WhiteboardApp.ts +0 -146
- package/src/behaviors/register-apps.ts +0 -39
- package/src/behaviors/style.ts +0 -17
- package/src/components/PageControl.scss +0 -80
- package/src/components/PageControl.tsx +0 -181
- package/src/components/PlayerControl/PlayerControl.scss +0 -145
- package/src/components/PlayerControl/PlayerControl.tsx +0 -158
- package/src/components/PlayerControl/components/Button.tsx +0 -55
- package/src/components/PlayerControl/hooks.ts +0 -88
- package/src/components/PlayerControl/icons/Loading.tsx +0 -13
- package/src/components/PlayerControl/icons/Pause.tsx +0 -13
- package/src/components/PlayerControl/icons/Play.tsx +0 -13
- package/src/components/PlayerControl/icons/index.ts +0 -10
- package/src/components/PlayerControl/index.ts +0 -1
- package/src/components/RedoUndo.scss +0 -56
- package/src/components/RedoUndo.tsx +0 -95
- package/src/components/Root.scss +0 -55
- package/src/components/Root.tsx +0 -61
- package/src/components/Toolbar/Content.tsx +0 -93
- package/src/components/Toolbar/Toolbar.scss +0 -247
- package/src/components/Toolbar/Toolbar.tsx +0 -82
- package/src/components/Toolbar/components/ApplianceButtons.tsx +0 -132
- package/src/components/Toolbar/components/AppsButton.tsx +0 -106
- package/src/components/Toolbar/components/Button.tsx +0 -54
- package/src/components/Toolbar/components/ColorBox.tsx +0 -56
- package/src/components/Toolbar/components/CutLine.tsx +0 -8
- package/src/components/Toolbar/components/PencilButton.tsx +0 -70
- package/src/components/Toolbar/components/ShapesButton.tsx +0 -143
- package/src/components/Toolbar/components/Slider.tsx +0 -27
- package/src/components/Toolbar/components/TextButton.tsx +0 -66
- package/src/components/Toolbar/components/UpDownButtons.tsx +0 -49
- package/src/components/Toolbar/components/assets/cocos.png +0 -0
- package/src/components/Toolbar/components/assets/countdown.png +0 -0
- package/src/components/Toolbar/components/assets/geogebra.png +0 -0
- package/src/components/Toolbar/components/assets/vscode.png +0 -0
- package/src/components/Toolbar/const.ts +0 -32
- package/src/components/Toolbar/hooks.ts +0 -113
- package/src/components/Toolbar/icons/Apps.tsx +0 -16
- package/src/components/Toolbar/icons/Arrow.tsx +0 -16
- package/src/components/Toolbar/icons/Circle.tsx +0 -21
- package/src/components/Toolbar/icons/Clean.tsx +0 -16
- package/src/components/Toolbar/icons/Clicker.tsx +0 -19
- package/src/components/Toolbar/icons/Collapse.tsx +0 -17
- package/src/components/Toolbar/icons/Diamond.tsx +0 -17
- package/src/components/Toolbar/icons/Down.tsx +0 -17
- package/src/components/Toolbar/icons/Eraser.tsx +0 -16
- package/src/components/Toolbar/icons/Expand.tsx +0 -17
- package/src/components/Toolbar/icons/Line.tsx +0 -13
- package/src/components/Toolbar/icons/Pencil.tsx +0 -16
- package/src/components/Toolbar/icons/Rectangle.tsx +0 -13
- package/src/components/Toolbar/icons/Selector.tsx +0 -16
- package/src/components/Toolbar/icons/SpeechBalloon.tsx +0 -17
- package/src/components/Toolbar/icons/Star.tsx +0 -17
- package/src/components/Toolbar/icons/Text.tsx +0 -16
- package/src/components/Toolbar/icons/Triangle.tsx +0 -17
- package/src/components/Toolbar/icons/Up.tsx +0 -17
- package/src/components/Toolbar/icons/index.ts +0 -42
- package/src/components/Toolbar/index.ts +0 -1
- package/src/components/ZoomControl.scss +0 -80
- package/src/components/ZoomControl.tsx +0 -221
- package/src/i18n/en.json +0 -31
- package/src/i18n/index.ts +0 -22
- package/src/i18n/zh-CN.json +0 -32
- package/src/icons/ChevronLeft.tsx +0 -21
- package/src/icons/ChevronRight.tsx +0 -21
- package/src/icons/FilePlus.tsx +0 -18
- package/src/icons/Minus.tsx +0 -21
- package/src/icons/Plus.tsx +0 -21
- package/src/icons/Redo.tsx +0 -24
- package/src/icons/Reset.tsx +0 -23
- package/src/icons/Undo.tsx +0 -24
- package/src/icons/index.tsx +0 -11
- package/src/internal/Instance.tsx +0 -275
- package/src/internal/helpers.ts +0 -86
- package/src/internal/hooks.ts +0 -9
- package/src/internal/index.ts +0 -3
- package/src/internal/mount-whiteboard.ts +0 -90
- package/src/react.tsx +0 -52
- package/src/style.scss +0 -35
- package/src/svelte.ts +0 -45
- package/src/theme/index.ts +0 -36
- package/src/types/index.ts +0 -22
- package/src/vue.ts +0 -74
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { Color } from "white-web-sdk";
|
|
2
|
-
|
|
3
|
-
import clsx from "clsx";
|
|
4
|
-
import React, { useContext } from "react";
|
|
5
|
-
|
|
6
|
-
import { isEqualArray } from "../../../internal";
|
|
7
|
-
import { ToolbarContext } from "../Toolbar";
|
|
8
|
-
|
|
9
|
-
const colors: Record<string, Color> = {
|
|
10
|
-
"#E02020": [224, 32, 32],
|
|
11
|
-
"#F7B500": [247, 181, 0],
|
|
12
|
-
"#6DD400": [109, 212, 0],
|
|
13
|
-
"#32C5FF": [50, 197, 255],
|
|
14
|
-
"#0091FF": [0, 145, 255],
|
|
15
|
-
"#6236FF": [98, 54, 255],
|
|
16
|
-
"#B620E0": [182, 32, 224],
|
|
17
|
-
"#6D7278": [109, 114, 120],
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const colorKeys = Object.keys(colors);
|
|
21
|
-
|
|
22
|
-
export function ColorBox() {
|
|
23
|
-
const { theme, memberState, setStrokeColor, writable } =
|
|
24
|
-
useContext(ToolbarContext);
|
|
25
|
-
|
|
26
|
-
const strokeColor = memberState?.strokeColor;
|
|
27
|
-
const disabled = !writable;
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<div className={clsx("fastboard-toolbar-color-box", theme)}>
|
|
31
|
-
{colorKeys.map((key: string) => (
|
|
32
|
-
<div
|
|
33
|
-
key={key}
|
|
34
|
-
className={clsx("fastboard-toolbar-color-item", theme)}
|
|
35
|
-
onClick={() => setStrokeColor(colors[key])}
|
|
36
|
-
>
|
|
37
|
-
<div
|
|
38
|
-
className={clsx("fastboard-toolbar-color-border", theme, {
|
|
39
|
-
active: strokeColor && isEqualArray(strokeColor, colors[key]),
|
|
40
|
-
})}
|
|
41
|
-
>
|
|
42
|
-
<button
|
|
43
|
-
className={clsx("fastboard-toolbar-color-btn")}
|
|
44
|
-
style={{ background: key }}
|
|
45
|
-
disabled={disabled}
|
|
46
|
-
onClick={ev => {
|
|
47
|
-
ev.stopPropagation();
|
|
48
|
-
setStrokeColor(colors[key]);
|
|
49
|
-
}}
|
|
50
|
-
/>
|
|
51
|
-
</div>
|
|
52
|
-
</div>
|
|
53
|
-
))}
|
|
54
|
-
</div>
|
|
55
|
-
);
|
|
56
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import clsx from "clsx";
|
|
2
|
-
import React, { useContext } from "react";
|
|
3
|
-
import { ToolbarContext, name } from "../Toolbar";
|
|
4
|
-
|
|
5
|
-
export function CutLine() {
|
|
6
|
-
const { theme } = useContext(ToolbarContext);
|
|
7
|
-
return <span className={clsx(`${name}-cut-line`, theme)} />;
|
|
8
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import Tippy from "@tippyjs/react";
|
|
2
|
-
import React, { useCallback } from "react";
|
|
3
|
-
import { useContext } from "react";
|
|
4
|
-
import { ApplianceNames } from "white-web-sdk";
|
|
5
|
-
|
|
6
|
-
import { defaultHotKeys, useInstance } from "../../../internal";
|
|
7
|
-
import { Icon } from "../../../icons";
|
|
8
|
-
import { RightOffset } from "../../../theme";
|
|
9
|
-
import { Icons } from "../icons";
|
|
10
|
-
import { ToolbarContext } from "../Toolbar";
|
|
11
|
-
import { Button } from "./Button";
|
|
12
|
-
import { ColorBox } from "./ColorBox";
|
|
13
|
-
import { CutLine } from "./CutLine";
|
|
14
|
-
import { Slider } from "./Slider";
|
|
15
|
-
import { renderToolTip } from "./ApplianceButtons";
|
|
16
|
-
|
|
17
|
-
export function PencilButton() {
|
|
18
|
-
const app = useInstance();
|
|
19
|
-
|
|
20
|
-
const { theme, icons, writable, setAppliance, memberState, i18n } =
|
|
21
|
-
useContext(ToolbarContext);
|
|
22
|
-
|
|
23
|
-
const changeAppliance = useCallback(() => {
|
|
24
|
-
setAppliance(ApplianceNames.pencil);
|
|
25
|
-
}, [setAppliance]);
|
|
26
|
-
|
|
27
|
-
const appliance = memberState?.currentApplianceName;
|
|
28
|
-
const active = appliance === ApplianceNames.pencil;
|
|
29
|
-
const disabled = !writable;
|
|
30
|
-
const shortcut = (app?.config.joinRoom.hotKeys || defaultHotKeys)
|
|
31
|
-
.changeToPencil;
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<span className="fastboard-toolbar-btn-interactive">
|
|
35
|
-
<Tippy
|
|
36
|
-
className="fastboard-tip"
|
|
37
|
-
content={renderPencilButtonContent()}
|
|
38
|
-
theme={theme}
|
|
39
|
-
placement="right-start"
|
|
40
|
-
trigger="click"
|
|
41
|
-
offset={RightOffset}
|
|
42
|
-
arrow={false}
|
|
43
|
-
interactive
|
|
44
|
-
>
|
|
45
|
-
<Button
|
|
46
|
-
content={renderToolTip(i18n?.t("pencil"), shortcut)}
|
|
47
|
-
active={active}
|
|
48
|
-
onClick={changeAppliance}
|
|
49
|
-
>
|
|
50
|
-
<Icon
|
|
51
|
-
fallback={<Icons.Pencil theme={theme} active={active} />}
|
|
52
|
-
src={disabled ? icons?.pencilIconDisable : icons?.pencilIcon}
|
|
53
|
-
alt="[pencil]"
|
|
54
|
-
/>
|
|
55
|
-
<span className="fastboard-toolbar-triangle" />
|
|
56
|
-
</Button>
|
|
57
|
-
</Tippy>
|
|
58
|
-
</span>
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function renderPencilButtonContent() {
|
|
63
|
-
return (
|
|
64
|
-
<div className="fastboard-toolbar-panel pencil">
|
|
65
|
-
<Slider />
|
|
66
|
-
<CutLine />
|
|
67
|
-
<ColorBox />
|
|
68
|
-
</div>
|
|
69
|
-
);
|
|
70
|
-
}
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import type { IconProps } from "../../../types";
|
|
2
|
-
|
|
3
|
-
import Tippy from "@tippyjs/react";
|
|
4
|
-
import React, { useContext } from "react";
|
|
5
|
-
import type { ShapeType } from "white-web-sdk";
|
|
6
|
-
import { ApplianceNames } from "white-web-sdk";
|
|
7
|
-
|
|
8
|
-
import { RightOffset } from "../../../theme";
|
|
9
|
-
import { ApplianceShapes, Shapes, ShapesMap } from "../const";
|
|
10
|
-
import { Icons } from "../icons";
|
|
11
|
-
import { ToolbarContext } from "../Toolbar";
|
|
12
|
-
import { Button } from "./Button";
|
|
13
|
-
import { CutLine } from "./CutLine";
|
|
14
|
-
import { Slider } from "./Slider";
|
|
15
|
-
import { ColorBox } from "./ColorBox";
|
|
16
|
-
|
|
17
|
-
const ShapeTypes = new Set([...ApplianceShapes, ...Shapes]);
|
|
18
|
-
|
|
19
|
-
export function ShapesButton() {
|
|
20
|
-
const { theme, memberState, i18n } = useContext(ToolbarContext);
|
|
21
|
-
|
|
22
|
-
const appliance = memberState?.currentApplianceName;
|
|
23
|
-
const shape = memberState?.shapeType;
|
|
24
|
-
|
|
25
|
-
const key = (
|
|
26
|
-
appliance === ApplianceNames.shape ? shape : appliance
|
|
27
|
-
) as keyof typeof ShapesMap;
|
|
28
|
-
|
|
29
|
-
const active = ShapeTypes.has(key);
|
|
30
|
-
|
|
31
|
-
const CurrentIcon = ShapesMap[key] || Icons.Rectangle;
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<span className="fastboard-toolbar-btn-interactive">
|
|
35
|
-
<Tippy
|
|
36
|
-
className="fastboard-tip"
|
|
37
|
-
content={renderShapesButtonContent()}
|
|
38
|
-
theme={theme}
|
|
39
|
-
placement="right-start"
|
|
40
|
-
trigger="click"
|
|
41
|
-
offset={RightOffset}
|
|
42
|
-
arrow={false}
|
|
43
|
-
interactive
|
|
44
|
-
>
|
|
45
|
-
<Button content={i18n?.t("shape")} active={active}>
|
|
46
|
-
<CurrentIcon theme={theme} active={active} />
|
|
47
|
-
<span className="fastboard-toolbar-triangle" />
|
|
48
|
-
</Button>
|
|
49
|
-
</Tippy>
|
|
50
|
-
</span>
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function renderShapesButtonContent() {
|
|
55
|
-
return (
|
|
56
|
-
<div className="fastboard-toolbar-panel shapes">
|
|
57
|
-
<ShapesBox />
|
|
58
|
-
<CutLine />
|
|
59
|
-
<Slider />
|
|
60
|
-
<CutLine />
|
|
61
|
-
<ColorBox />
|
|
62
|
-
</div>
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function ShapesBox() {
|
|
67
|
-
const { i18n } = useContext(ToolbarContext);
|
|
68
|
-
return (
|
|
69
|
-
<div className="fastboard-toolbar-shapes">
|
|
70
|
-
{ApplianceShapes.map(Appliance => (
|
|
71
|
-
<ApplianceShapeButton
|
|
72
|
-
key={Appliance}
|
|
73
|
-
content={i18n?.t(Appliance)}
|
|
74
|
-
Appliance={Appliance}
|
|
75
|
-
Icon={ShapesMap[Appliance]}
|
|
76
|
-
/>
|
|
77
|
-
))}
|
|
78
|
-
{Shapes.map(shape => (
|
|
79
|
-
<ShapeShapeButton
|
|
80
|
-
key={shape}
|
|
81
|
-
content={i18n?.t(shape)}
|
|
82
|
-
shape={shape}
|
|
83
|
-
Icon={ShapesMap[shape]}
|
|
84
|
-
/>
|
|
85
|
-
))}
|
|
86
|
-
</div>
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
interface ApplianceShapeButtonProps {
|
|
91
|
-
content?: string;
|
|
92
|
-
Appliance: ApplianceNames;
|
|
93
|
-
Icon: React.ComponentType<IconProps>;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function ApplianceShapeButton({
|
|
97
|
-
content,
|
|
98
|
-
Appliance,
|
|
99
|
-
Icon,
|
|
100
|
-
}: ApplianceShapeButtonProps) {
|
|
101
|
-
const { theme, writable, setAppliance, memberState } =
|
|
102
|
-
useContext(ToolbarContext);
|
|
103
|
-
|
|
104
|
-
const current = memberState?.currentApplianceName;
|
|
105
|
-
const disabled = !writable;
|
|
106
|
-
|
|
107
|
-
return (
|
|
108
|
-
<Button
|
|
109
|
-
content={content}
|
|
110
|
-
disabled={disabled}
|
|
111
|
-
placement="top"
|
|
112
|
-
onClick={() => setAppliance(Appliance)}
|
|
113
|
-
>
|
|
114
|
-
<Icon theme={theme} active={current === Appliance} />
|
|
115
|
-
</Button>
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
interface ShapeShapeButtonProps {
|
|
120
|
-
content?: string;
|
|
121
|
-
shape: ShapeType;
|
|
122
|
-
Icon: React.ComponentType<IconProps>;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function ShapeShapeButton({ content, shape, Icon }: ShapeShapeButtonProps) {
|
|
126
|
-
const { theme, writable, setAppliance, memberState } =
|
|
127
|
-
useContext(ToolbarContext);
|
|
128
|
-
|
|
129
|
-
const appliance = memberState?.currentApplianceName;
|
|
130
|
-
const current = appliance === ApplianceNames.shape && memberState?.shapeType;
|
|
131
|
-
const disabled = !writable;
|
|
132
|
-
|
|
133
|
-
return (
|
|
134
|
-
<Button
|
|
135
|
-
content={content}
|
|
136
|
-
disabled={disabled}
|
|
137
|
-
placement="top"
|
|
138
|
-
onClick={() => setAppliance(ApplianceNames.shape, shape)}
|
|
139
|
-
>
|
|
140
|
-
<Icon theme={theme} active={current === shape} />
|
|
141
|
-
</Button>
|
|
142
|
-
);
|
|
143
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import clsx from "clsx";
|
|
2
|
-
import RcSlider from "rc-slider";
|
|
3
|
-
import React, { useContext } from "react";
|
|
4
|
-
|
|
5
|
-
import { themes } from "../../../theme";
|
|
6
|
-
import { ToolbarContext } from "../Toolbar";
|
|
7
|
-
|
|
8
|
-
export function Slider() {
|
|
9
|
-
const { theme, writable, memberState, setStrokeWidth } =
|
|
10
|
-
useContext(ToolbarContext);
|
|
11
|
-
const { activeColor } = themes[theme];
|
|
12
|
-
|
|
13
|
-
const strokeWidth = memberState?.strokeWidth || 0;
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<RcSlider
|
|
17
|
-
disabled={!writable}
|
|
18
|
-
className={clsx("fastboard-toolbar-slider", theme)}
|
|
19
|
-
trackStyle={{ background: activeColor }}
|
|
20
|
-
handleStyle={{ border: `1px solid ${activeColor}` }}
|
|
21
|
-
value={strokeWidth}
|
|
22
|
-
onChange={setStrokeWidth}
|
|
23
|
-
min={1}
|
|
24
|
-
max={32}
|
|
25
|
-
/>
|
|
26
|
-
);
|
|
27
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import Tippy from "@tippyjs/react";
|
|
2
|
-
import React, { useCallback } from "react";
|
|
3
|
-
import { useContext } from "react";
|
|
4
|
-
import { ApplianceNames } from "white-web-sdk";
|
|
5
|
-
|
|
6
|
-
import { defaultHotKeys, useInstance } from "../../../internal";
|
|
7
|
-
import { Icon } from "../../../icons";
|
|
8
|
-
import { RightOffset } from "../../../theme";
|
|
9
|
-
import { Icons } from "../icons";
|
|
10
|
-
import { ToolbarContext } from "../Toolbar";
|
|
11
|
-
import { Button } from "./Button";
|
|
12
|
-
import { ColorBox } from "./ColorBox";
|
|
13
|
-
import { renderToolTip } from "./ApplianceButtons";
|
|
14
|
-
|
|
15
|
-
export function TextButton() {
|
|
16
|
-
const app = useInstance();
|
|
17
|
-
|
|
18
|
-
const { theme, icons, writable, setAppliance, memberState, i18n } =
|
|
19
|
-
useContext(ToolbarContext);
|
|
20
|
-
|
|
21
|
-
const changeAppliance = useCallback(() => {
|
|
22
|
-
setAppliance(ApplianceNames.text);
|
|
23
|
-
}, [setAppliance]);
|
|
24
|
-
|
|
25
|
-
const appliance = memberState?.currentApplianceName;
|
|
26
|
-
const active = appliance === ApplianceNames.text;
|
|
27
|
-
const disabled = !writable;
|
|
28
|
-
const shortcut = (app?.config.joinRoom.hotKeys || defaultHotKeys)
|
|
29
|
-
.changeToText;
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<span className="fastboard-toolbar-btn-interactive">
|
|
33
|
-
<Tippy
|
|
34
|
-
className="fastboard-tip"
|
|
35
|
-
content={renderTextButtonContent()}
|
|
36
|
-
theme={theme}
|
|
37
|
-
placement="right-start"
|
|
38
|
-
trigger="click"
|
|
39
|
-
offset={RightOffset}
|
|
40
|
-
arrow={false}
|
|
41
|
-
interactive
|
|
42
|
-
>
|
|
43
|
-
<Button
|
|
44
|
-
content={renderToolTip(i18n?.t("text"), shortcut)}
|
|
45
|
-
active={active}
|
|
46
|
-
onClick={changeAppliance}
|
|
47
|
-
>
|
|
48
|
-
<Icon
|
|
49
|
-
fallback={<Icons.Text theme={theme} active={active} />}
|
|
50
|
-
src={disabled ? icons?.textIconDisable : icons?.textIcon}
|
|
51
|
-
alt="[text]"
|
|
52
|
-
/>
|
|
53
|
-
<span className="fastboard-toolbar-triangle" />
|
|
54
|
-
</Button>
|
|
55
|
-
</Tippy>
|
|
56
|
-
</span>
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function renderTextButtonContent() {
|
|
61
|
-
return (
|
|
62
|
-
<div className="fastboard-toolbar-panel text">
|
|
63
|
-
<ColorBox />
|
|
64
|
-
</div>
|
|
65
|
-
);
|
|
66
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import React, { useCallback, useContext } from "react";
|
|
2
|
-
|
|
3
|
-
import { Icon } from "../../../icons";
|
|
4
|
-
import { Icons } from "../icons";
|
|
5
|
-
import { Button } from "./Button";
|
|
6
|
-
import { CutLine } from "./CutLine";
|
|
7
|
-
import { ToolbarContext } from "../Toolbar";
|
|
8
|
-
import { ItemHeight } from "../const";
|
|
9
|
-
|
|
10
|
-
export interface UpButtonProps {
|
|
11
|
-
disabled: boolean;
|
|
12
|
-
scrollTo: (height: number) => void;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function UpButton({ disabled, scrollTo }: UpButtonProps) {
|
|
16
|
-
const { theme, icons } = useContext(ToolbarContext);
|
|
17
|
-
const scrollUp = useCallback(() => scrollTo(-ItemHeight), [scrollTo]);
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<>
|
|
21
|
-
<Button content="Up" disabled={disabled} onClick={scrollUp}>
|
|
22
|
-
<Icon
|
|
23
|
-
fallback={<Icons.Up theme={theme} />}
|
|
24
|
-
src={disabled ? icons?.upIconDisable : icons?.upIcon}
|
|
25
|
-
alt="[up]"
|
|
26
|
-
/>
|
|
27
|
-
</Button>
|
|
28
|
-
<CutLine />
|
|
29
|
-
</>
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function DownButton({ disabled, scrollTo }: UpButtonProps) {
|
|
34
|
-
const { theme, icons } = useContext(ToolbarContext);
|
|
35
|
-
const scrollDown = useCallback(() => scrollTo(ItemHeight), [scrollTo]);
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<>
|
|
39
|
-
<CutLine />
|
|
40
|
-
<Button content="Down" disabled={disabled} onClick={scrollDown}>
|
|
41
|
-
<Icon
|
|
42
|
-
fallback={<Icons.Down theme={theme} />}
|
|
43
|
-
src={disabled ? icons?.downIconDisable : icons?.downIcon}
|
|
44
|
-
alt="[down]"
|
|
45
|
-
/>
|
|
46
|
-
</Button>
|
|
47
|
-
</>
|
|
48
|
-
);
|
|
49
|
-
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { ApplianceNames, ShapeType } from "white-web-sdk";
|
|
2
|
-
import { Icons } from "./icons";
|
|
3
|
-
|
|
4
|
-
export const ShapesMap = {
|
|
5
|
-
[ApplianceNames.rectangle]: Icons.Rectangle,
|
|
6
|
-
[ApplianceNames.ellipse]: Icons.Circle,
|
|
7
|
-
[ApplianceNames.straight]: Icons.Line,
|
|
8
|
-
[ApplianceNames.arrow]: Icons.Arrow,
|
|
9
|
-
[ShapeType.Pentagram]: Icons.Star,
|
|
10
|
-
[ShapeType.Rhombus]: Icons.Diamond,
|
|
11
|
-
[ShapeType.Triangle]: Icons.Triangle,
|
|
12
|
-
[ShapeType.SpeechBalloon]: Icons.SpeechBalloon,
|
|
13
|
-
} as const;
|
|
14
|
-
|
|
15
|
-
export const ApplianceShapes = [
|
|
16
|
-
ApplianceNames.rectangle,
|
|
17
|
-
ApplianceNames.ellipse,
|
|
18
|
-
ApplianceNames.straight,
|
|
19
|
-
ApplianceNames.arrow,
|
|
20
|
-
] as const;
|
|
21
|
-
|
|
22
|
-
export const Shapes = [
|
|
23
|
-
ShapeType.Pentagram,
|
|
24
|
-
ShapeType.Rhombus,
|
|
25
|
-
ShapeType.Triangle,
|
|
26
|
-
ShapeType.SpeechBalloon,
|
|
27
|
-
] as const;
|
|
28
|
-
|
|
29
|
-
export const ItemHeight = 32 + 4;
|
|
30
|
-
export const ItemsCount = 8;
|
|
31
|
-
export const MaxHeight = ItemHeight * ItemsCount - 4;
|
|
32
|
-
export const MinHeight = ItemHeight * 2 - 4;
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ApplianceNames,
|
|
3
|
-
Color,
|
|
4
|
-
MemberState,
|
|
5
|
-
Room,
|
|
6
|
-
RoomState,
|
|
7
|
-
ShapeType,
|
|
8
|
-
} from "white-web-sdk";
|
|
9
|
-
|
|
10
|
-
import { useCallback, useEffect, useState } from "react";
|
|
11
|
-
import { noop } from "../../internal";
|
|
12
|
-
|
|
13
|
-
export function useWritable(room?: Room | null) {
|
|
14
|
-
const [value, setValue] = useState(false);
|
|
15
|
-
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
if (room) {
|
|
18
|
-
const setWritable = () => setValue(room.isWritable);
|
|
19
|
-
setWritable();
|
|
20
|
-
room.callbacks.on("onEnableWriteNowChanged", setWritable);
|
|
21
|
-
return () => room.callbacks.off("onEnableWriteNowChanged", setWritable);
|
|
22
|
-
}
|
|
23
|
-
}, [room]);
|
|
24
|
-
|
|
25
|
-
return value;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function useRoomState(room?: Room | null) {
|
|
29
|
-
const [memberState, setMemberState] = useState<MemberState | undefined>(
|
|
30
|
-
undefined
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
if (room) {
|
|
35
|
-
setMemberState(room.state.memberState);
|
|
36
|
-
const onRoomStateChanged = (diff: Partial<RoomState>) => {
|
|
37
|
-
if (diff.memberState) setMemberState(diff.memberState);
|
|
38
|
-
};
|
|
39
|
-
room.callbacks.on("onRoomStateChanged", onRoomStateChanged);
|
|
40
|
-
return () => room.callbacks.off("onRoomStateChanged", onRoomStateChanged);
|
|
41
|
-
}
|
|
42
|
-
}, [room]);
|
|
43
|
-
|
|
44
|
-
return { memberState };
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface ToolbarHook {
|
|
48
|
-
readonly writable: boolean;
|
|
49
|
-
readonly memberState: MemberState | undefined;
|
|
50
|
-
cleanCurrentScene(): void;
|
|
51
|
-
setAppliance(appliance: ApplianceNames, shape?: ShapeType): void;
|
|
52
|
-
setStrokeWidth(width: number): void;
|
|
53
|
-
setStrokeColor(color: Color): void;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function useToolbar(room?: Room | null): ToolbarHook {
|
|
57
|
-
const writable = useWritable(room);
|
|
58
|
-
const { memberState } = useRoomState(room);
|
|
59
|
-
|
|
60
|
-
const cleanCurrentScene = useCallback(() => {
|
|
61
|
-
if (room?.isWritable) {
|
|
62
|
-
room.cleanCurrentScene();
|
|
63
|
-
}
|
|
64
|
-
}, [room]);
|
|
65
|
-
|
|
66
|
-
const setAppliance = useCallback(
|
|
67
|
-
(appliance: ApplianceNames, shape?: ShapeType) => {
|
|
68
|
-
if (room?.isWritable) {
|
|
69
|
-
room.setMemberState({
|
|
70
|
-
currentApplianceName: appliance,
|
|
71
|
-
shapeType: shape,
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
[room]
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
const setStrokeWidth = useCallback(
|
|
79
|
-
(strokeWidth: number) => {
|
|
80
|
-
if (room?.isWritable) {
|
|
81
|
-
room.setMemberState({ strokeWidth });
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
[room]
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
const setStrokeColor = useCallback(
|
|
88
|
-
(strokeColor: Color) => {
|
|
89
|
-
if (room?.isWritable) {
|
|
90
|
-
room.setMemberState({ strokeColor });
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
[room]
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
return {
|
|
97
|
-
writable,
|
|
98
|
-
memberState,
|
|
99
|
-
cleanCurrentScene,
|
|
100
|
-
setAppliance,
|
|
101
|
-
setStrokeWidth,
|
|
102
|
-
setStrokeColor,
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export const EmptyToolbarHook: ToolbarHook = {
|
|
107
|
-
writable: false,
|
|
108
|
-
memberState: undefined,
|
|
109
|
-
cleanCurrentScene: noop,
|
|
110
|
-
setAppliance: noop,
|
|
111
|
-
setStrokeWidth: noop,
|
|
112
|
-
setStrokeColor: noop,
|
|
113
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { IconProps } from "../../../types";
|
|
2
|
-
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { getStroke } from "../../../theme";
|
|
5
|
-
|
|
6
|
-
export const Apps = (props: IconProps) => {
|
|
7
|
-
const stroke = getStroke(props);
|
|
8
|
-
return (
|
|
9
|
-
<svg viewBox="0 0 24 24">
|
|
10
|
-
<g fill={stroke}>
|
|
11
|
-
<path d="M17.667 4.5h-3.334c-1.012 0-1.833.82-1.833 1.833V11.5h5.167c1.012 0 1.833-.82 1.833-1.833V6.333c0-1.012-.82-1.833-1.833-1.833Zm-3.334 1h3.334c.46 0 .833.373.833.833v3.334l-.006.104a.833.833 0 0 1-.827.729H13.5V6.333c0-.46.373-.833.833-.833Z" />
|
|
12
|
-
<path d="M6.333 19.5A1.833 1.833 0 0 1 4.5 17.667v-3.334c0-.525.221-1 .576-1.334a1.822 1.822 0 0 1-.576-1.332V8.333c0-1.012.82-1.833 1.833-1.833H10A1.5 1.5 0 0 1 11.5 8v4.5h4.167c.962 0 1.75.74 1.827 1.683l.006.15v3.334c0 1.012-.82 1.833-1.833 1.833Zm4.167-6H6.333a.833.833 0 0 0-.827.729l-.006.104v3.334c0 .46.373.833.833.833H10.5v-5Zm5.167 0H11.5v5h4.167c.46 0 .833-.373.833-.833v-3.334a.833.833 0 0 0-.833-.833ZM10 7.5H6.333a.833.833 0 0 0-.833.833v3.334c0 .46.373.833.833.833H10.5V8a.5.5 0 0 0-.41-.492L10 7.5Z" />
|
|
13
|
-
</g>
|
|
14
|
-
</svg>
|
|
15
|
-
);
|
|
16
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { IconProps } from "../../../types";
|
|
2
|
-
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { getStroke } from "../../../theme";
|
|
5
|
-
|
|
6
|
-
export const Arrow = (props: IconProps) => {
|
|
7
|
-
const stroke = getStroke(props);
|
|
8
|
-
return (
|
|
9
|
-
<svg viewBox="0 0 24 24">
|
|
10
|
-
<path
|
|
11
|
-
fill={stroke}
|
|
12
|
-
d="M19 5v6l-2.647-2.646L5.99 18.718l-.708-.708L15.645 7.646 13 5h6Z"
|
|
13
|
-
/>
|
|
14
|
-
</svg>
|
|
15
|
-
);
|
|
16
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { IconProps } from "../../../types";
|
|
2
|
-
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { getStroke } from "../../../theme";
|
|
5
|
-
|
|
6
|
-
export const Circle = (props: IconProps) => {
|
|
7
|
-
const stroke = getStroke(props);
|
|
8
|
-
return (
|
|
9
|
-
<svg viewBox="0 0 24 24">
|
|
10
|
-
<rect
|
|
11
|
-
width="15"
|
|
12
|
-
height="15"
|
|
13
|
-
x="4.5"
|
|
14
|
-
y="4.5"
|
|
15
|
-
fill="none"
|
|
16
|
-
stroke={stroke}
|
|
17
|
-
rx="7.5"
|
|
18
|
-
/>
|
|
19
|
-
</svg>
|
|
20
|
-
);
|
|
21
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { IconProps } from "../../../types";
|
|
2
|
-
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { getStroke } from "../../../theme";
|
|
5
|
-
|
|
6
|
-
export const Clean = (props: IconProps) => {
|
|
7
|
-
const stroke = getStroke(props);
|
|
8
|
-
return (
|
|
9
|
-
<svg viewBox="0 0 24 24">
|
|
10
|
-
<path
|
|
11
|
-
fill={stroke}
|
|
12
|
-
d="M9.754 11.99c0 1.856-.711 3.62-1.96 4.951l-.151.155h1.403l.855-.853h.707l.853.853h2.635l.094-.064a6.237 6.237 0 0 0 2.559-4.781l.005-.26h1a7.237 7.237 0 0 1-2.994 5.862l-.229.16-.277.083h-3l-.353-.146-.647-.647-.646.647-.354.146h-3l-.286-.91.214-.148a6.237 6.237 0 0 0 2.567-4.787l.005-.26h1Zm4.772-6.502v2l.35.039a2.98 2.98 0 0 1 2.644 2.78l.006.181h-8a2.98 2.98 0 0 1 2.65-2.961l.35-.039v-2h2Z"
|
|
13
|
-
/>
|
|
14
|
-
</svg>
|
|
15
|
-
);
|
|
16
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { IconProps } from "../../../types";
|
|
2
|
-
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { getStroke } from "../../../theme";
|
|
5
|
-
|
|
6
|
-
export const Clicker = (props: IconProps) => {
|
|
7
|
-
const stroke = getStroke(props);
|
|
8
|
-
return (
|
|
9
|
-
<svg viewBox="0 0 24 24">
|
|
10
|
-
<g fill="none">
|
|
11
|
-
<path d="M0 0h24v24H0z" />
|
|
12
|
-
<path
|
|
13
|
-
fill={stroke}
|
|
14
|
-
d="m7 5.072 10.33 7.892-4.879.549 3.232 5.598-.866.5-3.233-5.597-2.914 3.95L7 5.072Z"
|
|
15
|
-
/>
|
|
16
|
-
</g>
|
|
17
|
-
</svg>
|
|
18
|
-
);
|
|
19
|
-
};
|