@netless/fastboard-ui 1.0.2 → 1.0.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/fastboard-ui",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "The front-end of @netless/fastboard-core.",
5
5
  "main": "dist/index.js",
6
6
  "svelte": "dist/index.svelte.mjs",
@@ -12,14 +12,14 @@
12
12
  ],
13
13
  "repository": "netless-io/fastboard",
14
14
  "peerDependencies": {
15
- "@netless/fastboard-core": "1.0.2"
15
+ "@netless/fastboard-core": "1.0.4"
16
16
  },
17
17
  "dependencies": {
18
18
  "tippy.js": "^6.3.7"
19
19
  },
20
20
  "devDependencies": {
21
- "@netless/fastboard-core": "1.0.2",
22
21
  "@netless/buildtool": "0.1.0",
22
+ "@netless/fastboard-core": "1.0.4",
23
23
  "@netless/esbuild-plugin-inline-sass": "0.1.0"
24
24
  },
25
25
  "scripts": {
@@ -34,7 +34,7 @@
34
34
  $: if (app?.manager && app?.manager.room) {
35
35
  if (colors && !config.colors?.length) {
36
36
  const floatBarOptions = (app?.manager.room as any).floatBarOptions as { colors?: Color[] };
37
- if (floatBarOptions.colors) {
37
+ if (floatBarOptions?.colors) {
38
38
  colors = floatBarOptions.colors as Color[];
39
39
  }
40
40
  } else {
@@ -97,13 +97,17 @@
97
97
  }
98
98
  function pencil() {
99
99
  if (hasAppliancePlugin) {
100
- app?.appliancePlugin?.setMemberState({
101
- currentApplianceName: "pencil",
102
- useLaserPen: false,
103
- strokeOpacity: 1,
104
- } as ExtendMemberState);
100
+ if (appliance !== "pencil") {
101
+ if (pencilType === "mark") {
102
+ useMarkPen();
103
+ } else if (pencilType === "laser") {
104
+ useLaserPen();
105
+ } else {
106
+ usePencil();
107
+ }
108
+ }
105
109
  } else {
106
- app?.setAppliance("pencil");
110
+ usePencil();
107
111
  }
108
112
  }
109
113
  function text() {
@@ -121,6 +125,17 @@
121
125
  function clear() {
122
126
  app?.cleanCurrentScene();
123
127
  }
128
+ function usePencil() {
129
+ if (hasAppliancePlugin) {
130
+ app?.appliancePlugin?.setMemberState({
131
+ currentApplianceName: "pencil",
132
+ useLaserPen: false,
133
+ strokeOpacity: 1,
134
+ } as ExtendMemberState);
135
+ } else {
136
+ app?.setAppliance("pencil");
137
+ }
138
+ }
124
139
  function useLaserPen() {
125
140
  app?.appliancePlugin?.setMemberState({
126
141
  currentApplianceName: "laserPen",
@@ -195,7 +210,7 @@
195
210
  <div class="{name}-panel-switch-pencil">
196
211
  {#if !!app?.appliancePlugin}
197
212
  {#if pencilType !== "pencil"}
198
- <Button class="{name}-panel-switch-btn" {...btn_props} on:click={pencil}>
213
+ <Button class="{name}-panel-switch-btn" {...btn_props} on:click={usePencil}>
199
214
  <Icons.Pencil {theme} />
200
215
  </Button>
201
216
  {:else if pencilType === "pencil"}
@@ -13,13 +13,23 @@
13
13
  </script>
14
14
 
15
15
  <Button class="pencil" {...btn_props} on:click {content} {menu}>
16
- {#if appliance === "pencil" && pencilType === "mark"}
17
- <Icons.MarkPenFilled {theme} active />
18
- {:else if appliance === "pencil" && pencilType === "laser"}
19
- <Icons.LaserPenFilled {theme} active />
20
- {:else if appliance === "pencil" && pencilType === "pencil"}
21
- <Icons.PencilFilled {theme} active />
22
- {:else}
23
- <Icons.Pencil {theme} />
16
+ {#if pencilType === "mark"}
17
+ {#if appliance === "pencil"}
18
+ <Icons.MarkPenFilled {theme} active />
19
+ {:else}
20
+ <Icons.MarkPen {theme} />
21
+ {/if}
22
+ {:else if pencilType === "laser"}
23
+ {#if appliance === "pencil"}
24
+ <Icons.LaserPenFilled {theme} active />
25
+ {:else}
26
+ <Icons.LaserPen {theme} />
27
+ {/if}
28
+ {:else if pencilType === "pencil"}
29
+ {#if appliance === "pencil"}
30
+ <Icons.PencilFilled {theme} active />
31
+ {:else}
32
+ <Icons.Pencil {theme} />
33
+ {/if}
24
34
  {/if}
25
35
  </Button>
@@ -23,7 +23,7 @@ export function createUI(app?: FastboardApp | null, div?: Element): UI {
23
23
 
24
24
  if (app?.manager && app.manager.room) {
25
25
  const floatBarOptions = (app.manager.room as any).floatBarOptions as { colors?: Color[] };
26
- if (floatBarOptions.colors) {
26
+ if (floatBarOptions?.colors) {
27
27
  colors = floatBarOptions.colors as Color[];
28
28
  }
29
29
  }