@netless/fastboard-ui 1.0.5 → 1.0.6

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/lite.d.ts CHANGED
@@ -121,6 +121,14 @@ declare interface FastboardProps {
121
121
  */
122
122
  containerRef?: (container: HTMLDivElement | null) => void;
123
123
  config?: FastboardUIConfig;
124
+ /** Whether to forcibly display the toolbar */
125
+ force_show_toolbar?: boolean;
126
+ /** Whether to force the display of the redo undo button */
127
+ force_show_redo_undo?: boolean;
128
+ /** Whether to force the display of the zoom control button */
129
+ force_show_zoom_control?: boolean;
130
+ /** Whether to forcibly display the page control button */
131
+ force_show_page_control?: boolean;
124
132
  }
125
133
 
126
134
  declare class Fastboard extends SvelteComponentTyped<FastboardProps> {}
@@ -132,6 +140,30 @@ interface UI {
132
140
  update(props?: FastboardProps): void;
133
141
  /** remove UI */
134
142
  destroy(): void;
143
+ /** force show toolbar */
144
+ forceShowToolbar(): void;
145
+ /** force hide toolbar */
146
+ forceHideToolbar(): void;
147
+ /** recover show toolbar */
148
+ recoverToolbar(): void;
149
+ /** force show redo undo */
150
+ forceShowRedoUndo(): void;
151
+ /** force hide redo undo */
152
+ forceHideRedoUndo(): void;
153
+ /** recover show redo undo */
154
+ recoverRedoUndo(): void;
155
+ /** force show zoom control */
156
+ forceShowZoomControl(): void;
157
+ /** force hide zoom control */
158
+ forceHideZoomControl(): void;
159
+ /** recover show zoom control */
160
+ recoverZoomControl(): void;
161
+ /** force show page control */
162
+ forceShowPageControl(): void;
163
+ /** force hide page control */
164
+ forceHidePageControl(): void;
165
+ /** recover show page control */
166
+ recoverPageControl(): void;
135
167
  }
136
168
  /**
137
169
  * @example
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/fastboard-ui",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "The front-end of @netless/fastboard-core.",
5
5
  "main": "dist/index.js",
6
6
  "svelte": "dist/index.svelte.mjs",
@@ -12,15 +12,15 @@
12
12
  ],
13
13
  "repository": "netless-io/fastboard",
14
14
  "peerDependencies": {
15
- "@netless/fastboard-core": "1.0.5"
15
+ "@netless/fastboard-core": "1.0.6"
16
16
  },
17
17
  "dependencies": {
18
18
  "tippy.js": "^6.3.7"
19
19
  },
20
20
  "devDependencies": {
21
- "@netless/fastboard-core": "1.0.5",
21
+ "@netless/buildtool": "0.1.0",
22
22
  "@netless/esbuild-plugin-inline-sass": "0.1.0",
23
- "@netless/buildtool": "0.1.0"
23
+ "@netless/fastboard-core": "1.0.6"
24
24
  },
25
25
  "scripts": {
26
26
  "cleanup": "rimraf dist",
@@ -15,9 +15,13 @@
15
15
  export let language: Language = "en";
16
16
  export let containerRef: ((element: HTMLDivElement | null) => void) | undefined = undefined;
17
17
  export let config: FastboardUIConfig = {};
18
+ export let force_show_toolbar: boolean | undefined = undefined;
19
+ export let force_show_redo_undo: boolean | undefined = undefined;
20
+ export let force_show_zoom_control: boolean | undefined = undefined;
21
+ export let force_show_page_control: boolean | undefined = undefined;
18
22
 
19
23
  const name = "fastboard";
20
- const AppsShowToolbar = ["DocsViewer", "Slide"];
24
+ const AppsShowToolbar = ["DocsViewer", "Slide", "PDFjs"];
21
25
 
22
26
  let container: HTMLDivElement;
23
27
  let layout: "hidden" | "toolbar-only" | "visible" = "hidden";
@@ -26,9 +30,24 @@
26
30
  $: writable = app?.writable;
27
31
  $: boxState = app?.boxState;
28
32
  $: focusedApp = app?.focusedApp;
33
+ $: visibleApps = app?.visibleApps;
29
34
 
30
35
  $: if (!$writable) {
31
36
  layout = "hidden";
37
+ } else if (app?.appInMainViewPlugin) {
38
+ if ($visibleApps && $visibleApps.size > 0) {
39
+ if ( $boxState === "maximized" ) {
40
+ if (AppsShowToolbar.some(kind => ($focusedApp || "").includes(kind))) {
41
+ layout = "toolbar-only";
42
+ } else {
43
+ layout = "hidden";
44
+ }
45
+ } else {
46
+ layout = "visible";
47
+ }
48
+ } else {
49
+ layout = "visible";
50
+ }
32
51
  } else if ($boxState === "maximized") {
33
52
  if ($focusedApp && AppsShowToolbar.some(kind => ($focusedApp || "").includes(kind))) {
34
53
  layout = "toolbar-only";
@@ -60,6 +79,42 @@
60
79
  app.manager.setPrefersColorScheme(theme);
61
80
  }
62
81
 
82
+ let hidden_toolbar = false;
83
+ $: if (force_show_toolbar === false) {
84
+ hidden_toolbar = true;
85
+ } else if (force_show_toolbar === true) {
86
+ hidden_toolbar = false;
87
+ } else {
88
+ hidden_toolbar = !toolbar_has_items || !(layout === "visible" || layout === "toolbar-only");
89
+ }
90
+
91
+ let hidden_redo_undo = false;
92
+ $: if (force_show_redo_undo === false) {
93
+ hidden_redo_undo = true;
94
+ } else if (force_show_redo_undo === true) {
95
+ hidden_redo_undo = false;
96
+ } else {
97
+ hidden_redo_undo = layout !== "visible";
98
+ }
99
+
100
+ let hidden_zoom_control = false;
101
+ $: if (force_show_zoom_control === false) {
102
+ hidden_zoom_control = true;
103
+ } else if (force_show_zoom_control === true) {
104
+ hidden_zoom_control = false;
105
+ } else {
106
+ hidden_zoom_control = layout !== "visible";
107
+ }
108
+
109
+ let hidden_page_control = false;
110
+ $: if (force_show_page_control === false) {
111
+ hidden_page_control = true;
112
+ } else if (force_show_page_control === true) {
113
+ hidden_page_control = false;
114
+ } else {
115
+ hidden_page_control = layout !== "visible";
116
+ }
117
+
63
118
  onMount(() => {
64
119
  if (containerRef) {
65
120
  containerRef(container);
@@ -81,21 +136,21 @@
81
136
  <div class="{name}-view" bind:this={container} on:touchstart|capture={focus_me} />
82
137
  <div
83
138
  class="{name}-{config.toolbar?.placement || 'left'}"
84
- class:hidden={!toolbar_has_items || !(layout === "visible" || layout === "toolbar-only")}
139
+ class:hidden={hidden_toolbar}
85
140
  >
86
141
  {#if config.toolbar?.enable !== false}
87
142
  <Toolbar {app} {theme} {language} config={config.toolbar || {}} />
88
143
  {/if}
89
144
  </div>
90
- <div class="{name}-bottom-left" class:hidden={layout !== "visible"}>
91
- {#if config.redo_undo?.enable !== false}
145
+ <div class="{name}-bottom-left" class:hidden={hidden_toolbar && hidden_redo_undo}>
146
+ {#if config.redo_undo?.enable !== false && !hidden_redo_undo}
92
147
  <RedoUndo {app} {theme} {language} />
93
148
  {/if}
94
- {#if config.zoom_control?.enable !== false}
149
+ {#if config.zoom_control?.enable !== false && !hidden_zoom_control}
95
150
  <ZoomControl {app} {theme} {language} />
96
151
  {/if}
97
152
  </div>
98
- <div class="{name}-bottom-right" class:hidden={layout !== "visible"}>
153
+ <div class="{name}-bottom-right" class:hidden={hidden_page_control}>
99
154
  {#if config.page_control?.enable !== false}
100
155
  <PageControl {app} {theme} {language} />
101
156
  {/if}
@@ -12,6 +12,14 @@ export declare interface FastboardProps {
12
12
  */
13
13
  containerRef?: (container: HTMLDivElement | null) => void;
14
14
  config?: FastboardUIConfig;
15
+ /** Whether to forcibly display the toolbar */
16
+ force_show_toolbar?: boolean;
17
+ /** Whether to force the display of the redo undo button */
18
+ force_show_redo_undo?: boolean;
19
+ /** Whether to force the display of the zoom control button */
20
+ force_show_zoom_control?: boolean;
21
+ /** Whether to forcibly display the page control button */
22
+ force_show_page_control?: boolean;
15
23
  }
16
24
 
17
25
  declare class Fastboard extends SvelteComponentTyped<FastboardProps> {}
@@ -105,7 +105,7 @@ const Icons = {
105
105
  MarkPen,
106
106
  MarkPenFilled,
107
107
  EraserBitmap,
108
- EraserBitmapFilled
108
+ EraserBitmapFilled,
109
109
  };
110
110
 
111
111
  export default Icons;
@@ -10,6 +10,30 @@ export interface UI {
10
10
  update(props?: FastboardProps): void;
11
11
  /** remove UI */
12
12
  destroy(): void;
13
+ /** force show toolbar */
14
+ forceShowToolbar(): void;
15
+ /** force hide toolbar */
16
+ forceHideToolbar(): void;
17
+ /** recover show toolbar */
18
+ recoverToolbar(): void;
19
+ /** force show redo undo */
20
+ forceShowRedoUndo(): void;
21
+ /** force hide redo undo */
22
+ forceHideRedoUndo(): void;
23
+ /** recover show redo undo */
24
+ recoverRedoUndo(): void;
25
+ /** force show zoom control */
26
+ forceShowZoomControl(): void;
27
+ /** force hide zoom control */
28
+ forceHideZoomControl(): void;
29
+ /** recover show zoom control */
30
+ recoverZoomControl(): void;
31
+ /** force show page control */
32
+ forceShowPageControl(): void;
33
+ /** force hide page control */
34
+ forceHidePageControl(): void;
35
+ /** recover show page control */
36
+ recoverPageControl(): void;
13
37
  }
14
38
 
15
39
  /**
@@ -27,7 +51,6 @@ export function createUI(app?: FastboardApp | null, div?: Element): UI {
27
51
  colors = floatBarOptions.colors as Color[];
28
52
  }
29
53
  }
30
-
31
54
  const ui: UI = {
32
55
  mount(div: Element, props?: FastboardProps) {
33
56
  if (fastboard) {
@@ -59,6 +82,66 @@ export function createUI(app?: FastboardApp | null, div?: Element): UI {
59
82
  }
60
83
  fastboard = undefined;
61
84
  },
85
+ forceShowToolbar() {
86
+ if (fastboard) {
87
+ fastboard.$set({ force_show_toolbar: true });
88
+ }
89
+ },
90
+ forceHideToolbar() {
91
+ if (fastboard) {
92
+ fastboard.$set({ force_show_toolbar: false });
93
+ }
94
+ },
95
+ recoverToolbar() {
96
+ if (fastboard) {
97
+ fastboard.$set({ force_show_toolbar: undefined });
98
+ }
99
+ },
100
+ forceShowPageControl() {
101
+ if (fastboard) {
102
+ fastboard.$set({ force_show_page_control: true });
103
+ }
104
+ },
105
+ forceHidePageControl() {
106
+ if (fastboard) {
107
+ fastboard.$set({ force_show_page_control: false });
108
+ }
109
+ },
110
+ recoverPageControl() {
111
+ if (fastboard) {
112
+ fastboard.$set({ force_show_page_control: undefined });
113
+ }
114
+ },
115
+ forceShowRedoUndo() {
116
+ if (fastboard) {
117
+ fastboard.$set({ force_show_redo_undo: true });
118
+ }
119
+ },
120
+ forceHideRedoUndo() {
121
+ if (fastboard) {
122
+ fastboard.$set({ force_show_redo_undo: false });
123
+ }
124
+ },
125
+ recoverRedoUndo() {
126
+ if (fastboard) {
127
+ fastboard.$set({ force_show_redo_undo: undefined });
128
+ }
129
+ },
130
+ forceShowZoomControl() {
131
+ if (fastboard) {
132
+ fastboard.$set({ force_show_zoom_control: true });
133
+ }
134
+ },
135
+ forceHideZoomControl() {
136
+ if (fastboard) {
137
+ fastboard.$set({ force_show_zoom_control: false });
138
+ }
139
+ },
140
+ recoverZoomControl() {
141
+ if (fastboard) {
142
+ fastboard.$set({ force_show_zoom_control: undefined });
143
+ }
144
+ },
62
145
  };
63
146
 
64
147
  if (div) {