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 +1 -13
- package/dist/board.html +2 -0
- package/dist/customWebComponents.js +63 -60
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/board.html
CHANGED
|
@@ -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
|
|
205
|
-
|
|
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
|
-
|
|
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
|
-
|
|
268
|
+
function setButtonsLoading() {
|
|
269
|
+
const loadingContent = "Loading…";
|
|
278
270
|
editButton.disabled = true;
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
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
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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
|
});
|