@netless/fastboard 0.0.11 → 0.2.1

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.
Files changed (113) hide show
  1. package/LICENSE.txt +1 -1
  2. package/dist/index.js +32 -0
  3. package/dist/index.js.map +1 -0
  4. package/dist/index.mjs +7 -0
  5. package/dist/index.mjs.map +1 -0
  6. package/package.json +24 -85
  7. package/src/index.ts +2 -49
  8. package/README.md +0 -136
  9. package/dist/index.cjs.js +0 -14
  10. package/dist/index.cjs.js.map +0 -1
  11. package/dist/index.es.js +0 -2804
  12. package/dist/index.es.js.map +0 -1
  13. package/dist/svelte.cjs.js +0 -2
  14. package/dist/svelte.cjs.js.map +0 -1
  15. package/dist/svelte.es.js +0 -32
  16. package/dist/svelte.es.js.map +0 -1
  17. package/dist/vue.cjs.js +0 -2
  18. package/dist/vue.cjs.js.map +0 -1
  19. package/dist/vue.es.js +0 -43
  20. package/dist/vue.es.js.map +0 -1
  21. package/src/WhiteboardApp.ts +0 -146
  22. package/src/behaviors/register-apps.ts +0 -39
  23. package/src/behaviors/style.ts +0 -17
  24. package/src/components/PageControl/PageControl.scss +0 -80
  25. package/src/components/PageControl/PageControl.tsx +0 -110
  26. package/src/components/PageControl/hooks.ts +0 -70
  27. package/src/components/PageControl/index.ts +0 -2
  28. package/src/components/PlayerControl/PlayerControl.scss +0 -145
  29. package/src/components/PlayerControl/PlayerControl.tsx +0 -157
  30. package/src/components/PlayerControl/components/Button.tsx +0 -55
  31. package/src/components/PlayerControl/hooks.ts +0 -88
  32. package/src/components/PlayerControl/icons/Loading.tsx +0 -13
  33. package/src/components/PlayerControl/icons/Pause.tsx +0 -13
  34. package/src/components/PlayerControl/icons/Play.tsx +0 -13
  35. package/src/components/PlayerControl/icons/index.ts +0 -10
  36. package/src/components/PlayerControl/index.ts +0 -2
  37. package/src/components/RedoUndo/RedoUndo.scss +0 -56
  38. package/src/components/RedoUndo/RedoUndo.tsx +0 -79
  39. package/src/components/RedoUndo/hooks.ts +0 -50
  40. package/src/components/RedoUndo/index.ts +0 -2
  41. package/src/components/Root.scss +0 -55
  42. package/src/components/Root.tsx +0 -65
  43. package/src/components/Toolbar/Content.tsx +0 -94
  44. package/src/components/Toolbar/Toolbar.scss +0 -281
  45. package/src/components/Toolbar/Toolbar.tsx +0 -132
  46. package/src/components/Toolbar/components/ApplianceButtons.tsx +0 -132
  47. package/src/components/Toolbar/components/AppsButton.tsx +0 -106
  48. package/src/components/Toolbar/components/Button.tsx +0 -54
  49. package/src/components/Toolbar/components/ColorBox.tsx +0 -56
  50. package/src/components/Toolbar/components/CutLine.tsx +0 -8
  51. package/src/components/Toolbar/components/Mask.tsx +0 -44
  52. package/src/components/Toolbar/components/PencilButton.tsx +0 -70
  53. package/src/components/Toolbar/components/ShapesButton.tsx +0 -143
  54. package/src/components/Toolbar/components/Slider.tsx +0 -27
  55. package/src/components/Toolbar/components/TextButton.tsx +0 -66
  56. package/src/components/Toolbar/components/UpDownButtons.tsx +0 -49
  57. package/src/components/Toolbar/components/assets/cocos.png +0 -0
  58. package/src/components/Toolbar/components/assets/collapsed.png +0 -0
  59. package/src/components/Toolbar/components/assets/countdown.png +0 -0
  60. package/src/components/Toolbar/components/assets/expanded.png +0 -0
  61. package/src/components/Toolbar/components/assets/geogebra.png +0 -0
  62. package/src/components/Toolbar/components/assets/vscode.png +0 -0
  63. package/src/components/Toolbar/const.ts +0 -32
  64. package/src/components/Toolbar/hooks.ts +0 -112
  65. package/src/components/Toolbar/icons/Apps.tsx +0 -16
  66. package/src/components/Toolbar/icons/Arrow.tsx +0 -16
  67. package/src/components/Toolbar/icons/Circle.tsx +0 -21
  68. package/src/components/Toolbar/icons/Clean.tsx +0 -16
  69. package/src/components/Toolbar/icons/Clicker.tsx +0 -19
  70. package/src/components/Toolbar/icons/Collapse.tsx +0 -17
  71. package/src/components/Toolbar/icons/Diamond.tsx +0 -17
  72. package/src/components/Toolbar/icons/Down.tsx +0 -17
  73. package/src/components/Toolbar/icons/Eraser.tsx +0 -16
  74. package/src/components/Toolbar/icons/Expand.tsx +0 -17
  75. package/src/components/Toolbar/icons/Line.tsx +0 -13
  76. package/src/components/Toolbar/icons/Pencil.tsx +0 -16
  77. package/src/components/Toolbar/icons/Rectangle.tsx +0 -13
  78. package/src/components/Toolbar/icons/Selector.tsx +0 -16
  79. package/src/components/Toolbar/icons/SpeechBalloon.tsx +0 -17
  80. package/src/components/Toolbar/icons/Star.tsx +0 -17
  81. package/src/components/Toolbar/icons/Text.tsx +0 -16
  82. package/src/components/Toolbar/icons/Triangle.tsx +0 -17
  83. package/src/components/Toolbar/icons/Up.tsx +0 -17
  84. package/src/components/Toolbar/icons/index.ts +0 -42
  85. package/src/components/Toolbar/index.ts +0 -2
  86. package/src/components/ZoomControl/ZoomControl.scss +0 -80
  87. package/src/components/ZoomControl/ZoomControl.tsx +0 -109
  88. package/src/components/ZoomControl/hooks.ts +0 -111
  89. package/src/components/ZoomControl/index.ts +0 -2
  90. package/src/components/hooks.ts +0 -80
  91. package/src/i18n/en.json +0 -31
  92. package/src/i18n/index.ts +0 -22
  93. package/src/i18n/zh-CN.json +0 -32
  94. package/src/icons/ChevronLeft.tsx +0 -21
  95. package/src/icons/ChevronRight.tsx +0 -21
  96. package/src/icons/FilePlus.tsx +0 -18
  97. package/src/icons/Minus.tsx +0 -21
  98. package/src/icons/Plus.tsx +0 -21
  99. package/src/icons/Redo.tsx +0 -24
  100. package/src/icons/Reset.tsx +0 -23
  101. package/src/icons/Undo.tsx +0 -24
  102. package/src/icons/index.tsx +0 -11
  103. package/src/internal/Instance.tsx +0 -275
  104. package/src/internal/helpers.ts +0 -86
  105. package/src/internal/hooks.ts +0 -9
  106. package/src/internal/index.ts +0 -3
  107. package/src/internal/mount-whiteboard.ts +0 -90
  108. package/src/react.tsx +0 -52
  109. package/src/style.scss +0 -35
  110. package/src/svelte.ts +0 -45
  111. package/src/theme/index.ts +0 -36
  112. package/src/types/index.ts +0 -22
  113. package/src/vue.ts +0 -74
@@ -1,106 +0,0 @@
1
- import Tippy from "@tippyjs/react";
2
- import React, { useContext } from "react";
3
-
4
- import vscodePNG from "./assets/vscode.png";
5
- import geogebraPNG from "./assets/geogebra.png";
6
- import countdownPNG from "./assets/countdown.png";
7
-
8
- import { useInstance } from "../../../internal";
9
- import { Icon } from "../../../icons";
10
- import { RightOffset } from "../../../theme";
11
- import { Icons } from "../icons";
12
- import { ToolbarContext } from "../Toolbar";
13
- import { Button } from "./Button";
14
-
15
- export interface AppsButtonProps {
16
- content?: React.ReactNode;
17
- onClick?: () => void;
18
- }
19
-
20
- export function AppsButton({ content, onClick }: AppsButtonProps) {
21
- const { theme, icons, writable } = useContext(ToolbarContext);
22
-
23
- const disabled = !writable;
24
-
25
- const button = (
26
- <Button content="Apps" onClick={onClick}>
27
- <Icon
28
- fallback={<Icons.Apps theme={theme} />}
29
- src={disabled ? icons?.appsIconDisable : icons?.appsIcon}
30
- alt="[apps]"
31
- />
32
- </Button>
33
- );
34
-
35
- return content === false ? (
36
- button
37
- ) : (
38
- <span className="fastboard-toolbar-btn-interactive">
39
- <Tippy
40
- className="fastboard-tip"
41
- content={renderAppsButtonContent(content)}
42
- theme={theme}
43
- placement="right-end"
44
- trigger="click"
45
- offset={RightOffset}
46
- arrow={false}
47
- interactive
48
- >
49
- {button}
50
- </Tippy>
51
- </span>
52
- );
53
- }
54
-
55
- function renderAppsButtonContent(content?: React.ReactNode) {
56
- return (
57
- <div className="fastboard-toolbar-panel apps">
58
- <div className="fastboard-toolbar-apps">{content || <DefaultApps />}</div>
59
- </div>
60
- );
61
- }
62
-
63
- function DefaultApps() {
64
- const app = useInstance();
65
-
66
- return (
67
- <>
68
- <AppIcon
69
- title="Code Editor"
70
- src={vscodePNG}
71
- alt="[code editor]"
72
- onClick={app?.insertCodeEditor.bind(app)}
73
- />
74
- <AppIcon
75
- title="GeoGebra"
76
- src={geogebraPNG}
77
- alt="[geogebra]"
78
- onClick={app?.insertGeoGebra.bind(app)}
79
- />
80
- <AppIcon
81
- title="Countdown"
82
- src={countdownPNG}
83
- alt="[countdown]"
84
- onClick={app?.insertCountdown.bind(app)}
85
- />
86
- </>
87
- );
88
- }
89
-
90
- interface AppIconProps {
91
- title: string;
92
- src: string;
93
- alt: string;
94
- onClick?: () => void;
95
- }
96
-
97
- function AppIcon({ title, src, alt, onClick }: AppIconProps) {
98
- return (
99
- <span className="fastboard-toolbar-app-icon">
100
- <Button placement="top" content={title} onClick={onClick}>
101
- <img src={src} alt={alt} title={title} />
102
- </Button>
103
- <span className="fastboard-toolbar-app-icon-text">{title}</span>
104
- </span>
105
- );
106
- }
@@ -1,54 +0,0 @@
1
- import type { Placement } from "tippy.js";
2
-
3
- import clsx from "clsx";
4
- import React, { forwardRef, useContext, type PropsWithChildren } from "react";
5
- import Tippy from "@tippyjs/react";
6
-
7
- import { RightOffset } from "../../../theme";
8
- import { ToolbarContext } from "../Toolbar";
9
-
10
- type ButtonProps = PropsWithChildren<{
11
- content: React.ReactNode;
12
- disabled?: boolean;
13
- active?: boolean;
14
- onClick?: () => void;
15
- interactive?: boolean;
16
- placement?: Placement;
17
- }>;
18
-
19
- export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
20
- (props, ref) => {
21
- const {
22
- content,
23
- disabled,
24
- active,
25
- onClick,
26
- interactive,
27
- placement = "right",
28
- children,
29
- } = props;
30
- const { writable, theme } = useContext(ToolbarContext);
31
-
32
- return (
33
- <Tippy
34
- className="fastboard-tip"
35
- content={content}
36
- interactive={interactive}
37
- theme={theme}
38
- disabled={disabled || !writable}
39
- placement={placement}
40
- offset={placement.includes("right") ? RightOffset : undefined}
41
- duration={300}
42
- >
43
- <button
44
- ref={ref}
45
- className={clsx("fastboard-toolbar-btn", theme, { active })}
46
- onClick={onClick}
47
- disabled={disabled || !writable}
48
- >
49
- {children}
50
- </button>
51
- </Tippy>
52
- );
53
- }
54
- );
@@ -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,44 +0,0 @@
1
- import React, { useState, useEffect } from "react";
2
- import ReactDOM from "react-dom";
3
-
4
- type MaskProps = {
5
- toolbar: HTMLDivElement | null;
6
- children: React.ReactNode;
7
- };
8
-
9
- export const Mask = React.memo(({ toolbar, children }: MaskProps) => {
10
- const [rootElement] = useState<HTMLDivElement | null>(() => {
11
- const element = document.createElement("div");
12
- element.style.position = "absolute";
13
- return element;
14
- });
15
-
16
- useEffect(() => {
17
- if (toolbar && rootElement) {
18
- toolbar.appendChild(rootElement);
19
- }
20
- }, [rootElement, toolbar]);
21
-
22
- useEffect(() => {
23
- if (rootElement && toolbar) {
24
- toolbar.appendChild(rootElement);
25
-
26
- const toolbarRect = toolbar.getBoundingClientRect();
27
- const halfHeight = toolbarRect.height / 2 - 31;
28
- rootElement.style.top = halfHeight + "px";
29
- rootElement.style.left = "41px";
30
- rootElement.style.width = "17px";
31
- rootElement.style.height = "62px";
32
-
33
- return () => {
34
- toolbar.removeChild(rootElement);
35
- };
36
- }
37
- }, [rootElement, toolbar]);
38
-
39
- if (rootElement) {
40
- return ReactDOM.createPortal(children, rootElement);
41
- } else {
42
- return null;
43
- }
44
- });
@@ -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
- }
@@ -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;