@netless/fastboard 0.0.6 → 0.0.7

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/index.es.js CHANGED
@@ -1985,6 +1985,17 @@ function Root({
1985
1985
  }) {
1986
1986
  const [mux] = useState(() => new Lock());
1987
1987
  const useWhiteboard = useCallback((container) => mux.schedule(container ? () => app.mount(container) : () => app.unmount()), [app, mux]);
1988
+ const {
1989
+ Toolbar: toolbar = true,
1990
+ RedoUndo: redo_undo = true,
1991
+ ZoomControl: zoom_control = true,
1992
+ PageControl: page_control = true
1993
+ } = app.config.layout || {};
1994
+ const props = {
1995
+ room: app.room,
1996
+ manager: app.manager,
1997
+ i18n: app.i18n
1998
+ };
1988
1999
  return /* @__PURE__ */ jsx(Instance.Context.Provider, {
1989
2000
  value: app,
1990
2001
  children: /* @__PURE__ */ jsxs("div", {
@@ -1995,31 +2006,15 @@ function Root({
1995
2006
  }), /* @__PURE__ */ jsx("div", {
1996
2007
  className: "fastboard-view",
1997
2008
  ref: useWhiteboard
1998
- }), /* @__PURE__ */ jsx("div", {
2009
+ }), toolbar && /* @__PURE__ */ jsx("div", {
1999
2010
  className: "fastboard-left",
2000
- children: /* @__PURE__ */ jsx(Toolbar, {
2001
- room: app.room,
2002
- manager: app.manager,
2003
- i18n: app.i18n
2004
- })
2005
- }), /* @__PURE__ */ jsxs("div", {
2011
+ children: /* @__PURE__ */ jsx(Toolbar, __spreadValues({}, props))
2012
+ }), (redo_undo || zoom_control) && /* @__PURE__ */ jsxs("div", {
2006
2013
  className: "fastboard-bottom-left",
2007
- children: [/* @__PURE__ */ jsx(RedoUndo, {
2008
- room: app.room,
2009
- manager: app.manager,
2010
- i18n: app.i18n
2011
- }), /* @__PURE__ */ jsx(ZoomControl, {
2012
- room: app.room,
2013
- manager: app.manager,
2014
- i18n: app.i18n
2015
- })]
2016
- }), /* @__PURE__ */ jsx("div", {
2014
+ children: [redo_undo && /* @__PURE__ */ jsx(RedoUndo, __spreadValues({}, props)), zoom_control && /* @__PURE__ */ jsx(ZoomControl, __spreadValues({}, props))]
2015
+ }), page_control && /* @__PURE__ */ jsx("div", {
2017
2016
  className: "fastboard-bottom-right",
2018
- children: /* @__PURE__ */ jsx(PageControl, {
2019
- room: app.room,
2020
- manager: app.manager,
2021
- i18n: app.i18n
2022
- })
2017
+ children: /* @__PURE__ */ jsx(PageControl, __spreadValues({}, props))
2023
2018
  })]
2024
2019
  })
2025
2020
  });
@@ -2034,9 +2029,9 @@ class Instance {
2034
2029
  __publicField(this, "ready", false);
2035
2030
  __publicField(this, "resolveReady");
2036
2031
  __publicField(this, "readyPromise");
2037
- __publicField(this, "_target", null);
2032
+ __publicField(this, "target", null);
2038
2033
  __publicField(this, "collector", null);
2039
- this.config = config;
2034
+ this.config = __spreadValues({}, config);
2040
2035
  this.refreshReadyPromise();
2041
2036
  this.initialize();
2042
2037
  }
@@ -2054,21 +2049,18 @@ class Instance {
2054
2049
  this.accept(essentials);
2055
2050
  this.resolveReady();
2056
2051
  }
2057
- get target() {
2058
- return this._target;
2059
- }
2060
- set target(value) {
2061
- if (this._target && value) {
2062
- ReactDOM.unmountComponentAtNode(this._target);
2063
- }
2064
- this._target = value;
2065
- this.forceUpdate();
2066
- }
2067
2052
  bindElement(target, collector) {
2053
+ if (this.target && target) {
2054
+ ReactDOM.unmountComponentAtNode(this.target);
2055
+ }
2068
2056
  this.target = target;
2069
2057
  this.collector = collector;
2070
2058
  this.forceUpdate();
2071
2059
  }
2060
+ updateLayout(layout) {
2061
+ this.config.layout = layout;
2062
+ this.forceUpdate();
2063
+ }
2072
2064
  async forceUpdate() {
2073
2065
  await this.readyPromise;
2074
2066
  if (this.target) {
@@ -2250,7 +2242,7 @@ class WhiteboardApp {
2250
2242
  return this._instance.dispose();
2251
2243
  }
2252
2244
  }
2253
- const version = "0.0.6";
2245
+ const version = "0.0.7";
2254
2246
  const EMPTY_ARRAY = [];
2255
2247
  function useForceUpdate() {
2256
2248
  const [, forceUpdate_] = useState({});