@netless/fastboard-ui 1.0.0-canary.0 → 1.0.0-canary.10

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 (46) hide show
  1. package/dist/index.css +888 -0
  2. package/dist/index.d.ts +95 -69
  3. package/dist/index.js +7338 -2009
  4. package/dist/index.mjs +7342 -2011
  5. package/dist/index.svelte.mjs +10001 -3775
  6. package/package.json +6 -3
  7. package/src/actions/scroll.ts +1 -1
  8. package/src/actions/tippy.ts +9 -5
  9. package/src/behaviors/apps.ts +4 -38
  10. package/src/components/Button/Button.svelte +4 -1
  11. package/src/components/Button/Button.svelte.d.ts +2 -2
  12. package/src/components/Fastboard/Fastboard.scss +2 -3
  13. package/src/components/Fastboard/Fastboard.svelte +11 -4
  14. package/src/components/Fastboard/{Fastboard.svelte.ts → Fastboard.svelte.d.ts} +1 -1
  15. package/src/components/Fastboard/ReplayFastboard.svelte +13 -3
  16. package/src/components/Fastboard/{ReplayFastboard.svelte.ts → ReplayFastboard.svelte.d.ts} +2 -1
  17. package/src/components/Icons/Curve.svelte +10 -0
  18. package/src/components/Icons/CurveDashed.svelte +16 -0
  19. package/src/components/Icons/Eraser.svelte +35 -1
  20. package/src/components/Icons/EraserFilled.svelte +2 -2
  21. package/src/components/Icons/PencilEraser.svelte +16 -0
  22. package/src/components/Icons/PencilEraserFilled.svelte +16 -0
  23. package/src/components/Icons/index.ts +11 -0
  24. package/src/components/PageControl/PageControl.svelte +2 -2
  25. package/src/components/Toolbar/README.md +1 -1
  26. package/src/components/Toolbar/Toolbar.scss +5 -5
  27. package/src/components/Toolbar/Toolbar.svelte +24 -10
  28. package/src/components/Toolbar/Toolbar.svelte.d.ts +18 -1
  29. package/src/components/Toolbar/components/Contents.scss +14 -3
  30. package/src/components/Toolbar/components/Contents.svelte +191 -22
  31. package/src/components/Toolbar/components/PencilEraserSize.svelte +27 -0
  32. package/src/components/Toolbar/components/Shapes.svelte +1 -0
  33. package/src/components/Toolbar/components/Slider.svelte +0 -1
  34. package/src/components/Toolbar/components/StrokeColor.svelte +1 -0
  35. package/src/components/Toolbar/components/TextColor.svelte +1 -0
  36. package/src/components/Toolbar/components/constants.ts +32 -4
  37. package/src/components/Toolbar/components/helper.ts +1 -1
  38. package/src/components/ZoomControl/ZoomControl.svelte +5 -3
  39. package/src/components/theme.scss +11 -4
  40. package/src/helpers/index.ts +72 -48
  41. package/src/index.ts +8 -4
  42. package/src/style.scss +4 -0
  43. package/src/typings.ts +16 -6
  44. package/dist/index.js.map +0 -1
  45. package/dist/index.mjs.map +0 -1
  46. package/dist/index.svelte.mjs.map +0 -1
@@ -5,11 +5,13 @@ import { Fastboard, ReplayFastboard } from "../components/Fastboard";
5
5
 
6
6
  export interface UI {
7
7
  /** render UI to div */
8
- mount(div: Element, props?: Omit<FastboardProps, "app">): UI;
8
+ mount(div: Element, props?: FastboardProps): UI;
9
9
  /** update UI (theme, language, etc.) */
10
- update(props?: Omit<FastboardProps, "app">): void;
10
+ update(props?: FastboardProps): void;
11
11
  /** remove UI */
12
12
  destroy(): void;
13
+ /** div == null ? destroy() : mount() */
14
+ setElement(div: Element | null): void;
13
15
  }
14
16
 
15
17
  /**
@@ -17,32 +19,42 @@ export interface UI {
17
19
  * let ui = createUI(fastboardApp, document.getElementById("whiteboard"));
18
20
  * ui.update({ theme: "dark" })
19
21
  */
20
- export function createUI(app: FastboardApp, div?: Element): UI {
22
+ export function createUI(app?: FastboardApp | null, div?: Element): UI {
21
23
  let fastboard: Fastboard | undefined;
22
24
 
23
- const ui: UI = {
24
- mount(div: Element, props?: Omit<FastboardProps, "app">) {
25
- if (fastboard) {
26
- fastboard.$destroy();
27
- }
28
- fastboard = new Fastboard({ target: div, props: { app, ...props } });
29
- return ui;
30
- },
31
- update(props?: Omit<FastboardProps, "app">) {
32
- if (fastboard) {
33
- fastboard.$set(props);
34
- }
35
- },
36
- destroy() {
37
- if (fastboard) {
38
- fastboard.$destroy();
39
- }
40
- fastboard = undefined;
41
- },
42
- };
25
+ function mount(div: Element, props?: FastboardProps) {
26
+ if (fastboard) {
27
+ fastboard.$destroy();
28
+ }
29
+ fastboard = new Fastboard({ target: div, props: { app, ...props } });
30
+ return ui;
31
+ }
32
+
33
+ function update(props?: FastboardProps) {
34
+ if (fastboard) {
35
+ fastboard.$set(props);
36
+ }
37
+ }
38
+
39
+ function destroy() {
40
+ if (fastboard) {
41
+ fastboard.$destroy();
42
+ }
43
+ fastboard = undefined;
44
+ }
45
+
46
+ function setElement(div: Element | null) {
47
+ if (div) {
48
+ mount(div);
49
+ } else {
50
+ destroy();
51
+ }
52
+ }
53
+
54
+ const ui: UI = { mount, update, destroy, setElement };
43
55
 
44
56
  if (div) {
45
- ui.mount(div);
57
+ mount(div, { app });
46
58
  }
47
59
 
48
60
  return ui;
@@ -50,11 +62,13 @@ export function createUI(app: FastboardApp, div?: Element): UI {
50
62
 
51
63
  export interface ReplayUI {
52
64
  /** render UI to div */
53
- mount(div: Element, props?: Omit<ReplayFastboardProps, "player">): ReplayUI;
65
+ mount(div: Element, props?: ReplayFastboardProps): ReplayUI;
54
66
  /** update UI (theme, language, etc.) */
55
- update(props?: Omit<ReplayFastboardProps, "player">): void;
67
+ update(props?: ReplayFastboardProps): void;
56
68
  /** remove UI */
57
69
  destroy(): void;
70
+ /** div == null ? destroy() : mount() */
71
+ setElement(div: Element | null): void;
58
72
  }
59
73
 
60
74
  /**
@@ -62,32 +76,42 @@ export interface ReplayUI {
62
76
  * let ui = createReplayUI(fastboardPlayer, document.getElementById("whiteboard"));
63
77
  * ui.update({ theme: "dark" })
64
78
  */
65
- export function createReplayUI(player: FastboardPlayer, div?: Element): ReplayUI {
79
+ export function createReplayUI(player?: FastboardPlayer | null, div?: Element): ReplayUI {
66
80
  let fastboard: ReplayFastboard | undefined;
67
81
 
68
- const ui: ReplayUI = {
69
- mount(div: Element, props?: Omit<ReplayFastboardProps, "player">) {
70
- if (fastboard) {
71
- fastboard.$destroy();
72
- }
73
- fastboard = new ReplayFastboard({ target: div, props: { player, ...props } });
74
- return ui;
75
- },
76
- update(props?: Omit<ReplayFastboardProps, "player">) {
77
- if (fastboard) {
78
- fastboard.$set(props);
79
- }
80
- },
81
- destroy() {
82
- if (fastboard) {
83
- fastboard.$destroy();
84
- }
85
- fastboard = undefined;
86
- },
87
- };
82
+ function mount(div: Element, props?: ReplayFastboardProps) {
83
+ if (fastboard) {
84
+ fastboard.$destroy();
85
+ }
86
+ fastboard = new ReplayFastboard({ target: div, props: { player, ...props } });
87
+ return ui;
88
+ }
89
+
90
+ function update(props?: ReplayFastboardProps) {
91
+ if (fastboard) {
92
+ fastboard.$set(props);
93
+ }
94
+ }
95
+
96
+ function destroy() {
97
+ if (fastboard) {
98
+ fastboard.$destroy();
99
+ }
100
+ fastboard = undefined;
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
112
 
89
113
  if (div) {
90
- ui.mount(div);
114
+ mount(div, { player });
91
115
  }
92
116
 
93
117
  return ui;
package/src/index.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import "./style.scss";
2
+
1
3
  export * from "./typings";
2
4
 
3
5
  export { default as RedoUndo, type RedoUndoProps } from "./components/RedoUndo";
@@ -5,10 +7,12 @@ export { default as PageControl, type PageControlProps } from "./components/Page
5
7
  export { default as ZoomControl, type ZoomControlProps } from "./components/ZoomControl";
6
8
  export { default as Toolbar, type ToolbarProps } from "./components/Toolbar";
7
9
  export { default as PlayerControl, type PlayerControlProps } from "./components/PlayerControl";
8
- export { Fastboard, ReplayFastboard } from "./components/Fastboard";
9
- export type { FastboardProps, ReplayFastboardProps } from "./components/Fastboard";
10
+ export {
11
+ Fastboard,
12
+ ReplayFastboard,
13
+ type FastboardProps,
14
+ type ReplayFastboardProps,
15
+ } from "./components/Fastboard";
10
16
 
11
17
  export * from "./helpers";
12
18
  export * from "./behaviors";
13
-
14
- import "./style.scss";
package/src/style.scss CHANGED
@@ -34,3 +34,7 @@
34
34
  padding: 8px;
35
35
  }
36
36
  }
37
+
38
+ .netless-whiteboard:focus-visible {
39
+ outline: none;
40
+ }
package/src/typings.ts CHANGED
@@ -1,3 +1,9 @@
1
+ import type { PageControlProps } from "./components/PageControl";
2
+ import type { PlayerControlProps } from "./components/PlayerControl";
3
+ import type { RedoUndoProps } from "./components/RedoUndo";
4
+ import type { ToolbarConfig } from "./components/Toolbar";
5
+ import type { ZoomControlProps } from "./components/ZoomControl";
6
+
1
7
  export interface SvelteAction<T = void> {
2
8
  (node: HTMLElement, parameters: T): void | {
3
9
  update?: (parameters: T) => void;
@@ -16,23 +22,27 @@ export type GenericIcon<K extends string, E extends string = IconType> = {
16
22
 
17
23
  export type I18nData<T extends string> = Record<Language, Record<T, string>>;
18
24
 
19
- export interface ToolbarConfig {
20
- apps?: {
21
- enable?: boolean;
22
- };
23
- }
24
-
25
25
  export interface FastboardUIConfig {
26
26
  toolbar?: {
27
27
  enable?: boolean;
28
28
  } & ToolbarConfig;
29
29
  redo_undo?: {
30
30
  enable?: boolean;
31
+ icons?: RedoUndoProps["icons"];
31
32
  };
32
33
  zoom_control?: {
33
34
  enable?: boolean;
35
+ icons?: ZoomControlProps["icons"];
34
36
  };
35
37
  page_control?: {
36
38
  enable?: boolean;
39
+ icons?: PageControlProps["icons"];
40
+ };
41
+ }
42
+
43
+ export interface ReplayFastboardUIConfig {
44
+ player_control?: {
45
+ enable?: boolean;
46
+ icons?: PlayerControlProps["icons"];
37
47
  };
38
48
  }