microboard-ui-temp 0.1.0 → 0.1.2
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/customWebComponents.js +60 -43
- package/dist/index.js +8 -11
- package/package.json +2 -2
|
@@ -191,7 +191,8 @@ document.addEventListener("DOMContentLoaded", () => {
|
|
|
191
191
|
editButton.appendChild(editIcon);
|
|
192
192
|
const editFileText = document.createElement("p");
|
|
193
193
|
const isSnapshotInIframe = window.parent && window.parent !== window && window.parent.location.href.includes("/snapshots/");
|
|
194
|
-
|
|
194
|
+
const editFileTextContent = isSnapshotInIframe ? "Edit copy" : "Edit file";
|
|
195
|
+
editFileText.textContent = editFileTextContent;
|
|
195
196
|
editButton.appendChild(editFileText);
|
|
196
197
|
editButton.style.backgroundColor = "rgba(20, 21, 26, 1)";
|
|
197
198
|
editButton.style.cursor = "pointer";
|
|
@@ -206,7 +207,8 @@ document.addEventListener("DOMContentLoaded", () => {
|
|
|
206
207
|
editButton.style.borderRadius = "10px";
|
|
207
208
|
const shareButton = document.createElement("button");
|
|
208
209
|
const shareButtonText = document.createElement("p");
|
|
209
|
-
|
|
210
|
+
const shareButtonTextContent = "Share with friends";
|
|
211
|
+
shareButtonText.textContent = shareButtonTextContent;
|
|
210
212
|
shareButton.appendChild(shareButtonText);
|
|
211
213
|
shareButton.style.backgroundColor = "rgba(20, 21, 26, 1)";
|
|
212
214
|
shareButton.style.cursor = "pointer";
|
|
@@ -263,49 +265,65 @@ document.addEventListener("DOMContentLoaded", () => {
|
|
|
263
265
|
titlePanel.appendChild(editButton);
|
|
264
266
|
titlePanel.appendChild(shareButton);
|
|
265
267
|
document.body.appendChild(titlePanel);
|
|
266
|
-
|
|
268
|
+
function setButtonsLoading() {
|
|
269
|
+
const loadingContent = "Loading…";
|
|
267
270
|
editButton.disabled = true;
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
await app.openBoardFromFile();
|
|
286
|
-
app.getBoard().deserializeHTML(stringed);
|
|
287
|
-
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();
|
|
288
288
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
|
|
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");
|
|
304
311
|
}
|
|
305
|
-
|
|
306
|
-
|
|
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) {
|
|
307
326
|
ev.preventDefault();
|
|
308
|
-
ev.stopPropagation();
|
|
309
327
|
const htmlContent = document.documentElement.innerHTML;
|
|
310
328
|
const boardName2 = document.title?.trim() || "shared-board";
|
|
311
329
|
const { boardsApi, api } = await import("https://www.unpkg.com/microboard-ui-temp/dist/index.js");
|
|
@@ -313,6 +331,5 @@ document.addEventListener("DOMContentLoaded", () => {
|
|
|
313
331
|
const boardRes = await boardsApi.createBoard(boardName2, true);
|
|
314
332
|
await boardsApi.publishSnapshot(htmlContent, boardRes.data.id, boardRes.data.id);
|
|
315
333
|
window.location.href = `https://dev-app.microboard.io/boards/${boardRes.data.id}`;
|
|
316
|
-
};
|
|
317
|
-
shareButton.onclick = handleShareBoard;
|
|
334
|
+
}));
|
|
318
335
|
});
|
package/dist/index.js
CHANGED
|
@@ -228002,18 +228002,18 @@ class BaseCommand {
|
|
|
228002
228002
|
const items = this.items;
|
|
228003
228003
|
switch (this.operation.method) {
|
|
228004
228004
|
case "addChildren":
|
|
228005
|
-
return
|
|
228006
|
-
return {
|
|
228005
|
+
return items.map((item) => {
|
|
228006
|
+
return { item, operation: {
|
|
228007
228007
|
...this.operation,
|
|
228008
|
-
|
|
228009
|
-
};
|
|
228008
|
+
method: "removeChildren"
|
|
228009
|
+
} };
|
|
228010
228010
|
});
|
|
228011
228011
|
case "removeChildren":
|
|
228012
|
-
return
|
|
228013
|
-
return {
|
|
228012
|
+
return items.map((item) => {
|
|
228013
|
+
return { item, operation: {
|
|
228014
228014
|
...this.operation,
|
|
228015
|
-
|
|
228016
|
-
};
|
|
228015
|
+
method: "addChildren"
|
|
228016
|
+
} };
|
|
228017
228017
|
});
|
|
228018
228018
|
default:
|
|
228019
228019
|
return mapItemsByOperation(items, (item) => {
|
|
@@ -248636,9 +248636,6 @@ class Frame2 extends BaseItem {
|
|
|
248636
248636
|
case "RichText":
|
|
248637
248637
|
this.text.apply(op);
|
|
248638
248638
|
break;
|
|
248639
|
-
case "LinkTo":
|
|
248640
|
-
this.linkTo.apply(op);
|
|
248641
|
-
break;
|
|
248642
248639
|
default:
|
|
248643
248640
|
return;
|
|
248644
248641
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "microboard-ui-temp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"i18next-browser-languagedetector": "^8.2.0",
|
|
51
51
|
"js-cookie": "^3.0.5",
|
|
52
52
|
"jwt-decode": "^4.0.0",
|
|
53
|
-
"microboard-temp": "^0.4.
|
|
53
|
+
"microboard-temp": "^0.4.100",
|
|
54
54
|
"nanoid": "^5.1.5",
|
|
55
55
|
"prop-types": "^15.8.1",
|
|
56
56
|
"react-hot-toast": "2.4.1",
|