microboard-ui-temp 0.0.50 → 0.1.1

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/README.md CHANGED
@@ -7,17 +7,5 @@ bun install
7
7
  To build:
8
8
 
9
9
  ```bash
10
- bun run build:app
11
- ```
12
-
13
- To run:
14
-
15
- ```bash
16
- bun run start
17
- ```
18
-
19
- or:
20
-
21
- ```bash
22
- docker compose up --build
10
+ bun run build
23
11
  ```
package/dist/board.html CHANGED
@@ -90,5 +90,7 @@
90
90
  defer
91
91
  src="https://unpkg.com/microboard-ui-temp/dist/loadLinksImages.js"
92
92
  ></script>
93
+ <!-- <script type="module" src="public/customWebComponents.ts"></script>
94
+ <script defer src="public/loadLinksImages.js"></script> -->
93
95
  </body>
94
96
  </head>
@@ -22,17 +22,6 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
22
22
  throw Error('Dynamic require of "' + x + '" is not supported');
23
23
  });
24
24
 
25
- // src/Config.ts
26
- var frontConf = {
27
- apiURL: undefined,
28
- wsURL: undefined
29
- };
30
- var isSnapshotInIframe = typeof window !== "undefined" && window.parent && window.parent !== window && window.parent.location.href.includes("/snapshots/");
31
- var baseUrl = typeof process !== "undefined" && process.env.BASE_URL ? process.env.BASE_URL : isSnapshotInIframe ? `${window.parent.location.protocol}//${window.parent.location.host}` : `${location.protocol}//${location.host}`;
32
- var parsedUrl = new URL(baseUrl);
33
- var PROTOCOL = parsedUrl.protocol;
34
- var HOST = parsedUrl.host;
35
-
36
25
  // src/public/customWebComponents.ts
37
26
  class RichTextElement extends HTMLElement {
38
27
  constructor() {
@@ -201,8 +190,9 @@ document.addEventListener("DOMContentLoaded", () => {
201
190
  editIcon.appendChild(editIconPath);
202
191
  editButton.appendChild(editIcon);
203
192
  const editFileText = document.createElement("p");
204
- const isSnapshotInIframe2 = window.parent && window.parent !== window && window.parent.location.href.includes("/snapshots/");
205
- editFileText.textContent = isSnapshotInIframe2 ? "Edit copy" : "Edit file";
193
+ const isSnapshotInIframe = window.parent && window.parent !== window && window.parent.location.href.includes("/snapshots/");
194
+ const editFileTextContent = isSnapshotInIframe ? "Edit copy" : "Edit file";
195
+ editFileText.textContent = editFileTextContent;
206
196
  editButton.appendChild(editFileText);
207
197
  editButton.style.backgroundColor = "rgba(20, 21, 26, 1)";
208
198
  editButton.style.cursor = "pointer";
@@ -217,7 +207,8 @@ document.addEventListener("DOMContentLoaded", () => {
217
207
  editButton.style.borderRadius = "10px";
218
208
  const shareButton = document.createElement("button");
219
209
  const shareButtonText = document.createElement("p");
220
- shareButtonText.textContent = "Share with friends";
210
+ const shareButtonTextContent = "Share with friends";
211
+ shareButtonText.textContent = shareButtonTextContent;
221
212
  shareButton.appendChild(shareButtonText);
222
213
  shareButton.style.backgroundColor = "rgba(20, 21, 26, 1)";
223
214
  shareButton.style.cursor = "pointer";
@@ -274,59 +265,71 @@ document.addEventListener("DOMContentLoaded", () => {
274
265
  titlePanel.appendChild(editButton);
275
266
  titlePanel.appendChild(shareButton);
276
267
  document.body.appendChild(titlePanel);
277
- editButton.onclick = async () => {
268
+ function setButtonsLoading() {
269
+ const loadingContent = "Loading…";
278
270
  editButton.disabled = true;
279
- editButton.textContent = "Loading...";
280
- try {
281
- document.removeEventListener("mousedown", handleMouseDown);
282
- document.removeEventListener("mousemove", handleMouseMove);
283
- document.removeEventListener("mouseup", handleMouseUp);
284
- document.removeEventListener("wheel", handleWheel);
285
- translateX = 0;
286
- translateY = 0;
287
- scale = 1;
288
- updateTransform();
289
- const { initInter } = await import("https://www.unpkg.com/microboard-ui-temp/dist/index.js");
290
- initInter();
291
- const { createApp } = await import("https://www.unpkg.com/microboard-ui-temp/dist/index.js");
292
- const app = createApp();
293
- window.app = app;
294
- const stringed = await app.openAndEditFile();
295
- if (stringed) {
296
- await app.openBoardFromFile();
297
- app.getBoard().deserializeHTML(stringed);
298
- app.localRender("items");
271
+ editFileText.textContent = loadingContent;
272
+ shareButton.disabled = true;
273
+ shareButtonText.textContent = loadingContent;
274
+ }
275
+ function resetButtons() {
276
+ editButton.disabled = false;
277
+ editFileText.textContent = editFileTextContent;
278
+ shareButton.disabled = false;
279
+ shareButtonText.textContent = shareButtonTextContent;
280
+ }
281
+ function onClickWrapper(handler) {
282
+ return async function(ev) {
283
+ setButtonsLoading();
284
+ try {
285
+ await handler.call(this, ev);
286
+ } finally {
287
+ resetButtons();
299
288
  }
300
- const response = await fetch("https://www.unpkg.com/microboard-ui-temp/dist/index.css");
301
- const cssText = await response.text();
302
- const styleEl = document.createElement("style");
303
- styleEl.textContent = cssText;
304
- document.body.appendChild(styleEl);
305
- const responseSvg = await fetch("https://www.unpkg.com/microboard-ui-temp/dist/sprite.svg");
306
- const svgText = await responseSvg.text();
307
- const div = document.createElement("div");
308
- div.style.display = "none";
309
- div.id = "sprite";
310
- div.innerHTML = svgText;
311
- document.body.appendChild(div);
312
- } finally {
313
- editButton.disabled = false;
314
- editButton.textContent = "Edit board";
289
+ };
290
+ }
291
+ editButton.addEventListener("click", onClickWrapper(async function(ev) {
292
+ ev.preventDefault();
293
+ document.removeEventListener("mousedown", handleMouseDown);
294
+ document.removeEventListener("mousemove", handleMouseMove);
295
+ document.removeEventListener("mouseup", handleMouseUp);
296
+ document.removeEventListener("wheel", handleWheel);
297
+ translateX = 0;
298
+ translateY = 0;
299
+ scale = 1;
300
+ updateTransform();
301
+ const { initInter } = await import("https://www.unpkg.com/microboard-ui-temp/dist/index.js");
302
+ initInter();
303
+ const { createApp } = await import("https://www.unpkg.com/microboard-ui-temp/dist/index.js");
304
+ const app = createApp();
305
+ window.app = app;
306
+ const stringed = await app.openAndEditFile();
307
+ if (stringed) {
308
+ await app.openBoardFromFile();
309
+ app.getBoard().deserializeHTML(stringed);
310
+ app.localRender("items");
315
311
  }
316
- };
317
- const handleShareBoard = async (ev) => {
312
+ const response = await fetch("https://www.unpkg.com/microboard-ui-temp/dist/index.css");
313
+ const cssText = await response.text();
314
+ const styleEl = document.createElement("style");
315
+ styleEl.textContent = cssText;
316
+ document.body.appendChild(styleEl);
317
+ const responseSvg = await fetch("https://www.unpkg.com/microboard-ui-temp/dist/sprite.svg");
318
+ const svgText = await responseSvg.text();
319
+ const div = document.createElement("div");
320
+ div.style.display = "none";
321
+ div.id = "sprite";
322
+ div.innerHTML = svgText;
323
+ document.body.appendChild(div);
324
+ }));
325
+ shareButton.addEventListener("click", onClickWrapper(async function(ev) {
318
326
  ev.preventDefault();
319
- ev.stopPropagation();
320
327
  const htmlContent = document.documentElement.innerHTML;
321
328
  const boardName2 = document.title?.trim() || "shared-board";
322
- const { boardsApi, createApp, api } = await import("https://www.unpkg.com/microboard-ui-temp/dist/index.js");
329
+ const { boardsApi, api } = await import("https://www.unpkg.com/microboard-ui-temp/dist/index.js");
323
330
  api.updateURL("https://dev-app.microboard.io/api/v1");
324
- frontConf.wsURL = "wss://dev-app.microboard.io/ws";
325
331
  const boardRes = await boardsApi.createBoard(boardName2, true);
326
- const publishedSnapshot = await boardsApi.publishSnapshot(htmlContent, boardName2, boardRes.data.id);
327
- console.log("boardid", boardRes);
328
- console.log("snapshot pub", publishedSnapshot);
332
+ await boardsApi.publishSnapshot(htmlContent, boardRes.data.id, boardRes.data.id);
329
333
  window.location.href = `https://dev-app.microboard.io/boards/${boardRes.data.id}`;
330
- };
331
- shareButton.onclick = handleShareBoard;
334
+ }));
332
335
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-ui-temp",
3
- "version": "0.0.50",
3
+ "version": "0.1.1",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "type": "module",