@netless/fastboard-ui 1.0.0-canary.9 → 1.0.1-beta.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/dist/full.d.ts +178 -0
- package/dist/index.d.ts +74 -75
- package/dist/index.js +4200 -3679
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +4188 -3650
- package/dist/index.mjs.map +1 -0
- package/dist/index.svelte.mjs +6102 -6540
- package/dist/index.svelte.mjs.map +1 -0
- package/dist/lite.d.ts +178 -0
- package/full.d.ts +1 -0
- package/lite.d.ts +1 -0
- package/package.json +24 -10
- package/src/actions/tippy.ts +6 -11
- package/src/behaviors/apps.ts +38 -4
- package/src/components/Button/Button.svelte +1 -4
- package/src/components/Button/Button.svelte.d.ts +1 -2
- package/src/components/Fastboard/Fastboard.scss +14 -2
- package/src/components/Fastboard/Fastboard.svelte +15 -5
- package/src/components/Fastboard/Fastboard.svelte.d.ts +6 -2
- package/src/components/Fastboard/ReplayFastboard.svelte +2 -2
- package/src/components/Fastboard/ReplayFastboard.svelte.d.ts +3 -3
- package/src/components/Icon/Icon.svelte.d.ts +1 -1
- package/src/components/Icons/{PencilEraser.svelte → Drag.svelte} +2 -2
- package/src/components/Icons/{PencilEraserFilled.svelte → DragFilled.svelte} +1 -3
- package/src/components/Icons/Eraser.svelte +1 -35
- package/src/components/Icons/EraserFilled.svelte +2 -2
- package/src/components/Icons/Laser.svelte +21 -0
- package/src/components/Icons/LaserFilled.svelte +14 -0
- package/src/components/Icons/LaserPen.svelte +20 -0
- package/src/components/Icons/LaserPenFilled.svelte +20 -0
- package/src/components/Icons/index.ts +12 -11
- package/src/components/PageControl/PageControl.svelte +4 -3
- package/src/components/PageControl/PageControl.svelte.d.ts +1 -1
- package/src/components/PlayerControl/PlayerControl.svelte.d.ts +1 -1
- package/src/components/RedoUndo/RedoUndo.svelte +2 -1
- package/src/components/RedoUndo/RedoUndo.svelte.d.ts +1 -1
- package/src/components/Toolbar/Toolbar.scss +14 -4
- package/src/components/Toolbar/Toolbar.svelte +34 -27
- package/src/components/Toolbar/Toolbar.svelte.d.ts +2 -19
- package/src/components/Toolbar/components/Contents.scss +19 -14
- package/src/components/Toolbar/components/Contents.svelte +98 -235
- package/src/components/Toolbar/components/Slider.scss +3 -1
- package/src/components/Toolbar/components/StrokeColor.svelte +12 -7
- package/src/components/Toolbar/components/TextColor.svelte +12 -7
- package/src/components/Toolbar/components/constants.ts +22 -36
- package/src/components/Toolbar/components/helper.ts +24 -2
- package/src/components/Toolbar/definitions/Clear.svelte +13 -0
- package/src/components/Toolbar/definitions/Clicker.svelte +19 -0
- package/src/components/Toolbar/definitions/Eraser.svelte +19 -0
- package/src/components/Toolbar/definitions/Hand.svelte +19 -0
- package/src/components/Toolbar/definitions/Laser.svelte +19 -0
- package/src/components/Toolbar/definitions/Pencil.svelte +23 -0
- package/src/components/Toolbar/definitions/Selector.svelte +19 -0
- package/src/components/Toolbar/definitions/Shapes.svelte +41 -0
- package/src/components/Toolbar/definitions/Text.svelte +20 -0
- package/src/components/ZoomControl/ZoomControl.svelte +5 -6
- package/src/components/ZoomControl/ZoomControl.svelte.d.ts +1 -1
- package/src/components/theme.scss +4 -11
- package/src/helpers/index.ts +60 -64
- package/src/typings.ts +42 -25
- package/dist/index.css +0 -888
- package/src/components/Icons/Curve.svelte +0 -10
- package/src/components/Icons/CurveDashed.svelte +0 -16
- package/src/components/Toolbar/components/PencilEraserSize.svelte +0 -27
- /package/src/components/Toolbar/components/{Shapes.svelte → SelectShapes.svelte} +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Theme } from "../../../typings";
|
|
3
|
+
import Button, { type ButtonProps } from "../../Button";
|
|
4
|
+
import Icons from "../../Icons";
|
|
5
|
+
|
|
6
|
+
export let btn_props: Partial<ButtonProps> = {};
|
|
7
|
+
export let content: ButtonProps["content"] | undefined;
|
|
8
|
+
export let theme: Theme = "light";
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<Button class="clear" {...btn_props} on:click {content}>
|
|
12
|
+
<Icons.Clear {theme} />
|
|
13
|
+
</Button>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ApplianceNames } from "@netless/fastboard-core";
|
|
3
|
+
import type { Theme } from "../../../typings";
|
|
4
|
+
import Button, { type ButtonProps } from "../../Button";
|
|
5
|
+
import Icons from "../../Icons";
|
|
6
|
+
|
|
7
|
+
export let btn_props: Partial<ButtonProps> = {};
|
|
8
|
+
export let content: ButtonProps["content"] | undefined;
|
|
9
|
+
export let appliance: ApplianceNames | undefined;
|
|
10
|
+
export let theme: Theme = "light";
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<Button class="clicker" {...btn_props} on:click {content}>
|
|
14
|
+
{#if appliance === "clicker"}
|
|
15
|
+
<Icons.ClickFilled {theme} active />
|
|
16
|
+
{:else}
|
|
17
|
+
<Icons.Click {theme} />
|
|
18
|
+
{/if}
|
|
19
|
+
</Button>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ApplianceNames } from "@netless/fastboard-core";
|
|
3
|
+
import type { Theme } from "../../../typings";
|
|
4
|
+
import Button, { type ButtonProps } from "../../Button";
|
|
5
|
+
import Icons from "../../Icons";
|
|
6
|
+
|
|
7
|
+
export let btn_props: Partial<ButtonProps> = {};
|
|
8
|
+
export let content: ButtonProps["content"] | undefined;
|
|
9
|
+
export let appliance: ApplianceNames | undefined;
|
|
10
|
+
export let theme: Theme = "light";
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<Button class="eraser" {...btn_props} on:click {content}>
|
|
14
|
+
{#if appliance === "eraser"}
|
|
15
|
+
<Icons.EraserFilled {theme} active />
|
|
16
|
+
{:else}
|
|
17
|
+
<Icons.Eraser {theme} />
|
|
18
|
+
{/if}
|
|
19
|
+
</Button>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ApplianceNames } from "@netless/fastboard-core";
|
|
3
|
+
import type { Theme } from "../../../typings";
|
|
4
|
+
import Button, { type ButtonProps } from "../../Button";
|
|
5
|
+
import Icons from "../../Icons";
|
|
6
|
+
|
|
7
|
+
export let btn_props: Partial<ButtonProps> = {};
|
|
8
|
+
export let content: ButtonProps["content"] | undefined;
|
|
9
|
+
export let appliance: ApplianceNames | undefined;
|
|
10
|
+
export let theme: Theme = "light";
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<Button class="hand" {...btn_props} on:click {content}>
|
|
14
|
+
{#if appliance === "hand"}
|
|
15
|
+
<Icons.DragFilled {theme} active />
|
|
16
|
+
{:else}
|
|
17
|
+
<Icons.Drag {theme} />
|
|
18
|
+
{/if}
|
|
19
|
+
</Button>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ApplianceNames } from "@netless/fastboard-core";
|
|
3
|
+
import type { Theme } from "../../../typings";
|
|
4
|
+
import Button, { type ButtonProps } from "../../Button";
|
|
5
|
+
import Icons from "../../Icons";
|
|
6
|
+
|
|
7
|
+
export let btn_props: Partial<ButtonProps> = {};
|
|
8
|
+
export let content: ButtonProps["content"] | undefined;
|
|
9
|
+
export let appliance: ApplianceNames | undefined;
|
|
10
|
+
export let theme: Theme = "light";
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<Button class="laserPointer" {...btn_props} on:click {content}>
|
|
14
|
+
{#if appliance === "laserPointer"}
|
|
15
|
+
<Icons.LaserFilled {theme} active />
|
|
16
|
+
{:else}
|
|
17
|
+
<Icons.Laser {theme} />
|
|
18
|
+
{/if}
|
|
19
|
+
</Button>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ApplianceNames } from "@netless/fastboard-core";
|
|
3
|
+
import type { Theme } from "../../../typings";
|
|
4
|
+
import Button, { type ButtonProps } from "../../Button";
|
|
5
|
+
import Icons from "../../Icons";
|
|
6
|
+
|
|
7
|
+
export let btn_props: Partial<ButtonProps> = {};
|
|
8
|
+
export let content: ButtonProps["content"] | undefined;
|
|
9
|
+
export let menu: ButtonProps["menu"] | undefined;
|
|
10
|
+
export let appliance: ApplianceNames | undefined;
|
|
11
|
+
export let theme: Theme = "light";
|
|
12
|
+
export let hasUseLaserPen: boolean = false;
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<Button class="pencil" {...btn_props} on:click {content} {menu}>
|
|
16
|
+
{#if appliance === "pencil" && hasUseLaserPen}
|
|
17
|
+
<Icons.LaserPenFilled {theme} active />
|
|
18
|
+
{:else if appliance === "pencil"}
|
|
19
|
+
<Icons.PencilFilled {theme} active />
|
|
20
|
+
{:else}
|
|
21
|
+
<Icons.Pencil {theme} />
|
|
22
|
+
{/if}
|
|
23
|
+
</Button>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ApplianceNames } from "@netless/fastboard-core";
|
|
3
|
+
import type { Theme } from "../../../typings";
|
|
4
|
+
import Button, { type ButtonProps } from "../../Button";
|
|
5
|
+
import Icons from "../../Icons";
|
|
6
|
+
|
|
7
|
+
export let btn_props: Partial<ButtonProps> = {};
|
|
8
|
+
export let content: ButtonProps["content"] | undefined;
|
|
9
|
+
export let appliance: ApplianceNames | undefined;
|
|
10
|
+
export let theme: Theme = "light";
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<Button class="selector" {...btn_props} on:click {content}>
|
|
14
|
+
{#if appliance === "selector"}
|
|
15
|
+
<Icons.SelectorFilled {theme} active />
|
|
16
|
+
{:else}
|
|
17
|
+
<Icons.Selector {theme} />
|
|
18
|
+
{/if}
|
|
19
|
+
</Button>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Appliance, ApplianceNames, FastboardApp } from "@netless/fastboard-core";
|
|
3
|
+
import type { Theme } from "../../../typings";
|
|
4
|
+
import { applianceShapes, shapesIcon, shapesIconActive, type Shape } from "../components/constants";
|
|
5
|
+
import Button, { type ButtonProps } from "../../Button";
|
|
6
|
+
|
|
7
|
+
export let app: FastboardApp | null | undefined = null;
|
|
8
|
+
export let btn_props: Partial<ButtonProps> = {};
|
|
9
|
+
export let content: ButtonProps["content"] | undefined;
|
|
10
|
+
export let menu: ButtonProps["menu"] | undefined;
|
|
11
|
+
export let appliance: ApplianceNames | undefined;
|
|
12
|
+
export let theme: Theme = "light";
|
|
13
|
+
|
|
14
|
+
$: memberState = app?.memberState;
|
|
15
|
+
$: appliance = $memberState?.currentApplianceName;
|
|
16
|
+
$: shape = $memberState?.shapeType;
|
|
17
|
+
|
|
18
|
+
let last_shape: Shape = "rectangle";
|
|
19
|
+
|
|
20
|
+
$: if (applianceShapes.includes(appliance as Appliance)) {
|
|
21
|
+
last_shape = appliance as Shape;
|
|
22
|
+
} else if (shape) {
|
|
23
|
+
last_shape = shape;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function select_last_shape() {
|
|
27
|
+
if (applianceShapes.includes(last_shape as Appliance)) {
|
|
28
|
+
app?.setAppliance(last_shape as Appliance);
|
|
29
|
+
} else {
|
|
30
|
+
app?.setAppliance("shape", last_shape as Exclude<Shape, Appliance>);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<Button class="shapes" {...btn_props} on:click={select_last_shape} {content} {menu}>
|
|
36
|
+
{#if appliance === last_shape || (appliance === "shape" && shape === last_shape)}
|
|
37
|
+
<svelte:component this={shapesIconActive[last_shape]} {theme} active />
|
|
38
|
+
{:else}
|
|
39
|
+
<svelte:component this={shapesIcon[last_shape]} {theme} />
|
|
40
|
+
{/if}
|
|
41
|
+
</Button>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ApplianceNames } from "@netless/fastboard-core";
|
|
3
|
+
import type { Theme } from "../../../typings";
|
|
4
|
+
import Button, { type ButtonProps } from "../../Button";
|
|
5
|
+
import Icons from "../../Icons";
|
|
6
|
+
|
|
7
|
+
export let btn_props: Partial<ButtonProps> = {};
|
|
8
|
+
export let content: ButtonProps["content"] | undefined;
|
|
9
|
+
export let menu: ButtonProps["menu"] | undefined;
|
|
10
|
+
export let appliance: ApplianceNames | undefined;
|
|
11
|
+
export let theme: Theme = "light";
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<Button class="text" {...btn_props} on:click {content} {menu}>
|
|
15
|
+
{#if appliance === "text"}
|
|
16
|
+
<Icons.TextFilled {theme} active />
|
|
17
|
+
{:else}
|
|
18
|
+
<Icons.Text {theme} />
|
|
19
|
+
{/if}
|
|
20
|
+
</Button>
|
|
@@ -49,7 +49,8 @@
|
|
|
49
49
|
const name = "fastboard-zoom-control";
|
|
50
50
|
|
|
51
51
|
$: writable = app?.writable;
|
|
52
|
-
$:
|
|
52
|
+
$: phase = app?.phase;
|
|
53
|
+
$: disabled = !($writable && $phase === "connected");
|
|
53
54
|
$: t = i18n[language];
|
|
54
55
|
|
|
55
56
|
let type: IconType;
|
|
@@ -57,10 +58,8 @@
|
|
|
57
58
|
|
|
58
59
|
$: camera = app?.camera;
|
|
59
60
|
$: scale = $camera?.scale ?? 1;
|
|
60
|
-
$: plus_disabled = disabled || next_scale(scale, 1)
|
|
61
|
-
$: minus_disabled = disabled || next_scale(scale, -1)
|
|
62
|
-
|
|
63
|
-
$: display_scale = clamp(Math.round(scale * 100), 30, 300);
|
|
61
|
+
$: plus_disabled = disabled || next_scale(scale, 1) === scale;
|
|
62
|
+
$: minus_disabled = disabled || next_scale(scale, -1) === scale;
|
|
64
63
|
|
|
65
64
|
function plus() {
|
|
66
65
|
app?.moveCamera({ scale: next_scale(scale, 1), centerX: 0, centerY: 0 });
|
|
@@ -85,7 +84,7 @@
|
|
|
85
84
|
{#if $camera == null}
|
|
86
85
|
…
|
|
87
86
|
{:else}
|
|
88
|
-
{
|
|
87
|
+
{Math.ceil(scale * 100)}%
|
|
89
88
|
{/if}
|
|
90
89
|
</span>
|
|
91
90
|
<Button class="minus" {name} {theme} disabled={minus_disabled} on:click={minus} content={t.minus}>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FastboardApp } from "@netless/fastboard-core";
|
|
2
2
|
import type { Theme, Language, GenericIcon } from "../../typings";
|
|
3
|
-
import { SvelteComponentTyped } from "
|
|
3
|
+
import { SvelteComponentTyped } from "../../typings";
|
|
4
4
|
|
|
5
5
|
export declare interface ZoomControlProps {
|
|
6
6
|
app?: FastboardApp | null;
|
|
@@ -7,7 +7,6 @@ $themes: (
|
|
|
7
7
|
active-color: $blue-6,
|
|
8
8
|
bg-color: color.change(white, $alpha: 0.9),
|
|
9
9
|
hover-bg-color: $blue-1,
|
|
10
|
-
active-bg-color: $blue-1,
|
|
11
10
|
border-color: $grey-1,
|
|
12
11
|
),
|
|
13
12
|
dark: (
|
|
@@ -15,7 +14,6 @@ $themes: (
|
|
|
15
14
|
active-color: $blue-7,
|
|
16
15
|
bg-color: color.change($grey-10, $alpha: 0.9),
|
|
17
16
|
hover-bg-color: $grey-8,
|
|
18
|
-
active-bg-color: $grey-8,
|
|
19
17
|
border-color: $grey-8,
|
|
20
18
|
),
|
|
21
19
|
);
|
|
@@ -60,7 +58,7 @@ $themes: (
|
|
|
60
58
|
}
|
|
61
59
|
}
|
|
62
60
|
|
|
63
|
-
@mixin btn($size: 24px, $padding: 0
|
|
61
|
+
@mixin btn($size: 24px, $padding: 0) {
|
|
64
62
|
appearance: none;
|
|
65
63
|
cursor: pointer;
|
|
66
64
|
margin: 0;
|
|
@@ -69,7 +67,7 @@ $themes: (
|
|
|
69
67
|
width: $size;
|
|
70
68
|
height: $size;
|
|
71
69
|
background-color: transparent;
|
|
72
|
-
border-radius:
|
|
70
|
+
border-radius: 4px;
|
|
73
71
|
font-size: 0;
|
|
74
72
|
line-height: 1;
|
|
75
73
|
flex-shrink: 0;
|
|
@@ -87,13 +85,8 @@ $themes: (
|
|
|
87
85
|
}
|
|
88
86
|
|
|
89
87
|
@each $name, $theme in $themes {
|
|
90
|
-
&.#{$name}:not(:disabled) {
|
|
91
|
-
|
|
92
|
-
background-color: read($theme, "hover-bg-color");
|
|
93
|
-
}
|
|
94
|
-
&.is-active {
|
|
95
|
-
background-color: read($theme, "active-bg-color");
|
|
96
|
-
}
|
|
88
|
+
&.#{$name}:not(:disabled):hover {
|
|
89
|
+
background-color: read($theme, "hover-bg-color");
|
|
97
90
|
}
|
|
98
91
|
}
|
|
99
92
|
}
|
package/src/helpers/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FastboardApp, FastboardPlayer } from "@netless/fastboard-core";
|
|
1
|
+
import type { Color, FastboardApp, FastboardPlayer } from "@netless/fastboard-core";
|
|
2
2
|
import type { FastboardProps, ReplayFastboardProps } from "../components/Fastboard";
|
|
3
3
|
|
|
4
4
|
import { Fastboard, ReplayFastboard } from "../components/Fastboard";
|
|
@@ -10,8 +10,6 @@ export interface UI {
|
|
|
10
10
|
update(props?: FastboardProps): void;
|
|
11
11
|
/** remove UI */
|
|
12
12
|
destroy(): void;
|
|
13
|
-
/** div == null ? destroy() : mount() */
|
|
14
|
-
setElement(div: Element | null): void;
|
|
15
13
|
}
|
|
16
14
|
|
|
17
15
|
/**
|
|
@@ -21,40 +19,50 @@ export interface UI {
|
|
|
21
19
|
*/
|
|
22
20
|
export function createUI(app?: FastboardApp | null, div?: Element): UI {
|
|
23
21
|
let fastboard: Fastboard | undefined;
|
|
22
|
+
let colors: Color[] | undefined;
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
if (app?.manager && app.manager.room) {
|
|
25
|
+
const floatBarOptions = (app.manager.room as any).floatBarOptions as { colors?: Color[] };
|
|
26
|
+
if (floatBarOptions.colors) {
|
|
27
|
+
colors = floatBarOptions.colors as Color[];
|
|
28
28
|
}
|
|
29
|
-
fastboard = new Fastboard({ target: div, props: { app, ...props } });
|
|
30
|
-
return ui;
|
|
31
29
|
}
|
|
32
30
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
fastboard
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
31
|
+
const ui: UI = {
|
|
32
|
+
mount(div: Element, props?: FastboardProps) {
|
|
33
|
+
if (fastboard) {
|
|
34
|
+
fastboard.$destroy();
|
|
35
|
+
}
|
|
36
|
+
if (colors && props?.config && !props.config.toolbar?.colors) {
|
|
37
|
+
if (!props?.config.toolbar) {
|
|
38
|
+
props.config.toolbar = {};
|
|
39
|
+
}
|
|
40
|
+
props.config.toolbar.colors = colors;
|
|
41
|
+
}
|
|
42
|
+
fastboard = new Fastboard({ target: div, props: { app, ...props } });
|
|
43
|
+
return ui;
|
|
44
|
+
},
|
|
45
|
+
update(props?: FastboardProps) {
|
|
46
|
+
if (fastboard && props) {
|
|
47
|
+
if (colors && props?.config && !props.config.toolbar?.colors) {
|
|
48
|
+
if (!props?.config.toolbar) {
|
|
49
|
+
props.config.toolbar = {};
|
|
50
|
+
}
|
|
51
|
+
props.config.toolbar.colors = colors;
|
|
52
|
+
}
|
|
53
|
+
fastboard.$set(props);
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
destroy() {
|
|
57
|
+
if (fastboard) {
|
|
58
|
+
fastboard.$destroy();
|
|
59
|
+
}
|
|
60
|
+
fastboard = undefined;
|
|
61
|
+
},
|
|
62
|
+
};
|
|
55
63
|
|
|
56
64
|
if (div) {
|
|
57
|
-
mount(div, { app });
|
|
65
|
+
ui.mount(div, { app });
|
|
58
66
|
}
|
|
59
67
|
|
|
60
68
|
return ui;
|
|
@@ -67,8 +75,6 @@ export interface ReplayUI {
|
|
|
67
75
|
update(props?: ReplayFastboardProps): void;
|
|
68
76
|
/** remove UI */
|
|
69
77
|
destroy(): void;
|
|
70
|
-
/** div == null ? destroy() : mount() */
|
|
71
|
-
setElement(div: Element | null): void;
|
|
72
78
|
}
|
|
73
79
|
|
|
74
80
|
/**
|
|
@@ -79,39 +85,29 @@ export interface ReplayUI {
|
|
|
79
85
|
export function createReplayUI(player?: FastboardPlayer | null, div?: Element): ReplayUI {
|
|
80
86
|
let fastboard: ReplayFastboard | undefined;
|
|
81
87
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
fastboard
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function setElement(div: Element | null) {
|
|
104
|
-
if (div) {
|
|
105
|
-
mount(div);
|
|
106
|
-
} else {
|
|
107
|
-
destroy();
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const ui: ReplayUI = { mount, update, destroy, setElement };
|
|
88
|
+
const ui: ReplayUI = {
|
|
89
|
+
mount(div: Element, props?: ReplayFastboardProps) {
|
|
90
|
+
if (fastboard) {
|
|
91
|
+
fastboard.$destroy();
|
|
92
|
+
}
|
|
93
|
+
fastboard = new ReplayFastboard({ target: div, props: { player, ...props } });
|
|
94
|
+
return ui;
|
|
95
|
+
},
|
|
96
|
+
update(props?: ReplayFastboardProps) {
|
|
97
|
+
if (fastboard && props) {
|
|
98
|
+
fastboard.$set(props);
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
destroy() {
|
|
102
|
+
if (fastboard) {
|
|
103
|
+
fastboard.$destroy();
|
|
104
|
+
}
|
|
105
|
+
fastboard = undefined;
|
|
106
|
+
},
|
|
107
|
+
};
|
|
112
108
|
|
|
113
109
|
if (div) {
|
|
114
|
-
mount(div, { player });
|
|
110
|
+
ui.mount(div, { player });
|
|
115
111
|
}
|
|
116
112
|
|
|
117
113
|
return ui;
|
package/src/typings.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/// <reference types="svelte/types/runtime/ambient.d.ts" />
|
|
2
|
+
|
|
3
|
+
import type { Color } from "@netless/fastboard-core";
|
|
4
|
+
|
|
5
|
+
export { SvelteComponentTyped } from "svelte/internal";
|
|
6
6
|
|
|
7
7
|
export interface SvelteAction<T = void> {
|
|
8
|
-
(
|
|
8
|
+
(
|
|
9
|
+
node: HTMLElement,
|
|
10
|
+
parameters: T
|
|
11
|
+
): void | {
|
|
9
12
|
update?: (parameters: T) => void;
|
|
10
13
|
destroy?: () => void;
|
|
11
14
|
};
|
|
@@ -22,27 +25,41 @@ export type GenericIcon<K extends string, E extends string = IconType> = {
|
|
|
22
25
|
|
|
23
26
|
export type I18nData<T extends string> = Record<Language, Record<T, string>>;
|
|
24
27
|
|
|
28
|
+
export type ToolbarItem =
|
|
29
|
+
| "clicker"
|
|
30
|
+
| "selector"
|
|
31
|
+
| "pencil"
|
|
32
|
+
| "text"
|
|
33
|
+
| "shapes"
|
|
34
|
+
| "eraser"
|
|
35
|
+
| "clear"
|
|
36
|
+
| "hand"
|
|
37
|
+
| "laserPointer";
|
|
38
|
+
|
|
39
|
+
export interface ToolbarConfig {
|
|
40
|
+
/** @default "left" */
|
|
41
|
+
placement?: "left" | "right";
|
|
42
|
+
/** @default ["clicker", "selector", "pencil", "text", "shapes", "eraser", "clear"] */
|
|
43
|
+
items?: ToolbarItem[];
|
|
44
|
+
/**
|
|
45
|
+
* Note: updating this option does not take effect when the element was mounted.
|
|
46
|
+
* Make sure to set this option in `UI.mount(div, { configs: { toolbar: { collapsed: true } } })`.
|
|
47
|
+
* @default false
|
|
48
|
+
*/
|
|
49
|
+
collapsed?: boolean;
|
|
50
|
+
/** Control the last button which opens apps stock on toolbar. */
|
|
51
|
+
apps?: { enable?: boolean };
|
|
52
|
+
/** 颜色 */
|
|
53
|
+
colors?: Color[];
|
|
54
|
+
}
|
|
55
|
+
|
|
25
56
|
export interface FastboardUIConfig {
|
|
26
|
-
toolbar?: {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
enable?: boolean;
|
|
31
|
-
icons?: RedoUndoProps["icons"];
|
|
32
|
-
};
|
|
33
|
-
zoom_control?: {
|
|
34
|
-
enable?: boolean;
|
|
35
|
-
icons?: ZoomControlProps["icons"];
|
|
36
|
-
};
|
|
37
|
-
page_control?: {
|
|
38
|
-
enable?: boolean;
|
|
39
|
-
icons?: PageControlProps["icons"];
|
|
40
|
-
};
|
|
57
|
+
toolbar?: { enable?: boolean } & ToolbarConfig;
|
|
58
|
+
redo_undo?: { enable?: boolean };
|
|
59
|
+
zoom_control?: { enable?: boolean };
|
|
60
|
+
page_control?: { enable?: boolean };
|
|
41
61
|
}
|
|
42
62
|
|
|
43
63
|
export interface ReplayFastboardUIConfig {
|
|
44
|
-
player_control?: {
|
|
45
|
-
enable?: boolean;
|
|
46
|
-
icons?: PlayerControlProps["icons"];
|
|
47
|
-
};
|
|
64
|
+
player_control?: { enable?: boolean };
|
|
48
65
|
}
|