microboard-temp 0.13.79 → 0.13.80
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/cjs/browser.js +123 -41
- package/dist/cjs/index.js +123 -41
- package/dist/cjs/node.js +123 -41
- package/dist/esm/browser.js +143 -61
- package/dist/esm/index.js +143 -61
- package/dist/esm/node.js +143 -61
- package/dist/types/Events/Events.d.ts +6 -0
- package/dist/types/Items/Audio/AudioHelpers.d.ts +1 -1
- package/dist/types/Items/Image/ImageHelpers.d.ts +1 -1
- package/dist/types/Items/Video/VideoHelpers.d.ts +1 -1
- package/dist/types/Settings.d.ts +8 -0
- package/dist/types/api/AuthRequest.d.ts +6 -0
- package/dist/types/api/MediaHelpers.d.ts +2 -2
- package/package.json +1 -1
package/dist/esm/browser.js
CHANGED
|
@@ -3645,6 +3645,8 @@ var init_Settings = __esm(() => {
|
|
|
3645
3645
|
getDPI: () => 1,
|
|
3646
3646
|
reactEditorFocus: () => {},
|
|
3647
3647
|
reactEditorToSlatePoint: () => null,
|
|
3648
|
+
onAuthInvalid: async () => false,
|
|
3649
|
+
onAuthTerminalFailure: () => {},
|
|
3648
3650
|
planNames: {
|
|
3649
3651
|
basic: "Basic",
|
|
3650
3652
|
plus: "Plus",
|
|
@@ -14404,6 +14406,11 @@ class Events {
|
|
|
14404
14406
|
getOpKey(op) {
|
|
14405
14407
|
return op.method;
|
|
14406
14408
|
}
|
|
14409
|
+
refreshIdentity() {
|
|
14410
|
+
const sessionId = this.getSessionId();
|
|
14411
|
+
const authorUserId = this.getAuthorUserId();
|
|
14412
|
+
this.log.refreshUnconfirmedIdentity(sessionId, authorUserId);
|
|
14413
|
+
}
|
|
14407
14414
|
getSessionId() {
|
|
14408
14415
|
return getConnectionSessionId(this.connection);
|
|
14409
14416
|
}
|
|
@@ -31823,9 +31830,34 @@ var init_setLink = __esm(() => {
|
|
|
31823
31830
|
});
|
|
31824
31831
|
|
|
31825
31832
|
// src/Items/RichText/editorHelpers/common/getSelectionMarks.ts
|
|
31826
|
-
import { Editor as Editor13 } from "slate";
|
|
31833
|
+
import { Editor as Editor13, Range as Range6, Text as Text7 } from "slate";
|
|
31827
31834
|
function getSelectionMarks(editor) {
|
|
31828
|
-
|
|
31835
|
+
const marks = Editor13.marks(editor);
|
|
31836
|
+
if (!editor.selection) {
|
|
31837
|
+
return marks;
|
|
31838
|
+
}
|
|
31839
|
+
if (!Range6.isExpanded(editor.selection) || marks && Object.keys(marks).length > 0) {
|
|
31840
|
+
return marks;
|
|
31841
|
+
}
|
|
31842
|
+
const textEntries = Array.from(Editor13.nodes(editor, {
|
|
31843
|
+
at: editor.selection,
|
|
31844
|
+
match: (node) => Text7.isText(node)
|
|
31845
|
+
}));
|
|
31846
|
+
const [firstEntry, ...restEntries] = textEntries;
|
|
31847
|
+
if (!firstEntry) {
|
|
31848
|
+
return marks;
|
|
31849
|
+
}
|
|
31850
|
+
const { text: _firstText, ...firstMarks } = firstEntry[0];
|
|
31851
|
+
const commonMarks = { ...firstMarks };
|
|
31852
|
+
for (const [node] of restEntries) {
|
|
31853
|
+
const { text: _text, ...nodeMarks } = node;
|
|
31854
|
+
for (const key of Object.keys(commonMarks)) {
|
|
31855
|
+
if (commonMarks[key] !== nodeMarks[key]) {
|
|
31856
|
+
delete commonMarks[key];
|
|
31857
|
+
}
|
|
31858
|
+
}
|
|
31859
|
+
}
|
|
31860
|
+
return commonMarks;
|
|
31829
31861
|
}
|
|
31830
31862
|
var init_getSelectionMarks = () => {};
|
|
31831
31863
|
|
|
@@ -31844,13 +31876,13 @@ var init_clearText = __esm(() => {
|
|
|
31844
31876
|
});
|
|
31845
31877
|
|
|
31846
31878
|
// src/Items/RichText/editorHelpers/common/hasTextInSelection.ts
|
|
31847
|
-
import { Editor as Editor15, Range as
|
|
31879
|
+
import { Editor as Editor15, Range as Range7 } from "slate";
|
|
31848
31880
|
function hasTextInSelection(editor) {
|
|
31849
31881
|
const { selection } = editor;
|
|
31850
|
-
if (!selection ||
|
|
31882
|
+
if (!selection || Range7.isCollapsed(selection)) {
|
|
31851
31883
|
return false;
|
|
31852
31884
|
}
|
|
31853
|
-
const [start, end] =
|
|
31885
|
+
const [start, end] = Range7.edges(selection);
|
|
31854
31886
|
const text = Editor15.string(editor, { anchor: start, focus: end });
|
|
31855
31887
|
return text.length > 0;
|
|
31856
31888
|
}
|
|
@@ -39399,7 +39431,7 @@ function getParagraphWithPassedTextNode(textNode) {
|
|
|
39399
39431
|
}
|
|
39400
39432
|
|
|
39401
39433
|
// src/Items/RichText/editorHelpers/selectionOps/setSelectionFontSize.ts
|
|
39402
|
-
import { Editor as Editor24, Transforms as Transforms17 } from "slate";
|
|
39434
|
+
import { Editor as Editor24, Range as Range8, Text as Text8, Transforms as Transforms17 } from "slate";
|
|
39403
39435
|
import { ReactEditor as ReactEditor3 } from "slate-react";
|
|
39404
39436
|
function setSelectionFontSize(editor, isAutosize, fontSize, selectionContext) {
|
|
39405
39437
|
const size = fontSize;
|
|
@@ -39434,7 +39466,14 @@ function setSelectionFontSize(editor, isAutosize, fontSize, selectionContext) {
|
|
|
39434
39466
|
shouldUpdateElement = true;
|
|
39435
39467
|
}
|
|
39436
39468
|
} else {
|
|
39437
|
-
|
|
39469
|
+
if (editor.selection && Range8.isExpanded(editor.selection)) {
|
|
39470
|
+
Transforms17.setNodes(editor, { fontSize: size }, {
|
|
39471
|
+
match: (n) => Text8.isText(n),
|
|
39472
|
+
split: true
|
|
39473
|
+
});
|
|
39474
|
+
} else {
|
|
39475
|
+
Editor24.addMark(editor, "fontSize", size);
|
|
39476
|
+
}
|
|
39438
39477
|
}
|
|
39439
39478
|
}
|
|
39440
39479
|
if (selectionContext === "EditTextUnderPointer") {
|
|
@@ -39472,7 +39511,7 @@ var init_getEachNodeInSelectionStyles = __esm(() => {
|
|
|
39472
39511
|
});
|
|
39473
39512
|
|
|
39474
39513
|
// src/Items/RichText/editorHelpers/selectionOps/setSelectionFontStyle.ts
|
|
39475
|
-
import { Editor as Editor25, Range as
|
|
39514
|
+
import { Editor as Editor25, Range as Range9, Transforms as Transforms18 } from "slate";
|
|
39476
39515
|
function setSelectionFontStyle(editor, style) {
|
|
39477
39516
|
const styleList = Array.isArray(style) ? style : [style];
|
|
39478
39517
|
for (const style2 of styleList) {
|
|
@@ -39489,7 +39528,7 @@ function setSelectionFontStyle(editor, style) {
|
|
|
39489
39528
|
continue;
|
|
39490
39529
|
}
|
|
39491
39530
|
const { selection } = editor;
|
|
39492
|
-
if (selection &&
|
|
39531
|
+
if (selection && Range9.isExpanded(selection)) {
|
|
39493
39532
|
Transforms18.setNodes(editor, { [style2]: value }, {
|
|
39494
39533
|
match: (n) => !Editor25.isEditor(n) && n.type === "text",
|
|
39495
39534
|
split: true
|
|
@@ -39504,7 +39543,7 @@ var init_setSelectionFontStyle = __esm(() => {
|
|
|
39504
39543
|
});
|
|
39505
39544
|
|
|
39506
39545
|
// src/Items/RichText/editorHelpers/selectionOps/setSelectionFontColor.ts
|
|
39507
|
-
import { Editor as Editor26 } from "slate";
|
|
39546
|
+
import { Editor as Editor26, Range as Range10, Text as Text9, Transforms as Transforms19 } from "slate";
|
|
39508
39547
|
import { ReactEditor as ReactEditor4 } from "slate-react";
|
|
39509
39548
|
function setSelectionFontColor(editor, format, selectionContext) {
|
|
39510
39549
|
const marks = getSelectionMarks(editor);
|
|
@@ -39512,7 +39551,14 @@ function setSelectionFontColor(editor, format, selectionContext) {
|
|
|
39512
39551
|
return;
|
|
39513
39552
|
}
|
|
39514
39553
|
if (marks.fontColor !== format) {
|
|
39515
|
-
|
|
39554
|
+
if (editor.selection && Range10.isExpanded(editor.selection)) {
|
|
39555
|
+
Transforms19.setNodes(editor, { fontColor: format }, {
|
|
39556
|
+
match: (n) => Text9.isText(n),
|
|
39557
|
+
split: true
|
|
39558
|
+
});
|
|
39559
|
+
} else {
|
|
39560
|
+
Editor26.addMark(editor, "fontColor", format);
|
|
39561
|
+
}
|
|
39516
39562
|
}
|
|
39517
39563
|
if (selectionContext === "EditTextUnderPointer") {
|
|
39518
39564
|
try {
|
|
@@ -39530,7 +39576,7 @@ var init_setSelectionFontColor = __esm(() => {
|
|
|
39530
39576
|
import {
|
|
39531
39577
|
createEditor,
|
|
39532
39578
|
Editor as Editor27,
|
|
39533
|
-
Transforms as
|
|
39579
|
+
Transforms as Transforms20
|
|
39534
39580
|
} from "slate";
|
|
39535
39581
|
import { withReact } from "slate-react";
|
|
39536
39582
|
|
|
@@ -39806,7 +39852,7 @@ class EditorContainer {
|
|
|
39806
39852
|
break;
|
|
39807
39853
|
}
|
|
39808
39854
|
if (selection) {
|
|
39809
|
-
|
|
39855
|
+
Transforms20.select(this.editor, selection);
|
|
39810
39856
|
}
|
|
39811
39857
|
}
|
|
39812
39858
|
applyMaxWidth(maxWidth) {
|
|
@@ -39966,7 +40012,7 @@ class EditorContainer {
|
|
|
39966
40012
|
return JSON.parse(JSON.stringify(this.editor.selection));
|
|
39967
40013
|
}
|
|
39968
40014
|
splitNode() {
|
|
39969
|
-
|
|
40015
|
+
Transforms20.splitNodes(this.editor, { always: true });
|
|
39970
40016
|
}
|
|
39971
40017
|
getBlockNodes() {
|
|
39972
40018
|
return this.editor.children;
|
|
@@ -40056,7 +40102,7 @@ var init_findOptimalMaxWidthForTextAutoSize = __esm(() => {
|
|
|
40056
40102
|
});
|
|
40057
40103
|
|
|
40058
40104
|
// src/Items/RichText/editorHelpers/selectionOps/applySelectionFontColor.ts
|
|
40059
|
-
import { Editor as Editor28 } from "slate";
|
|
40105
|
+
import { Editor as Editor28, Range as Range11, Text as Text10, Transforms as Transforms21 } from "slate";
|
|
40060
40106
|
function applySelectionFontColor(editor, fontColor) {
|
|
40061
40107
|
if (!editor) {
|
|
40062
40108
|
throw new Error("Editor is not initialized");
|
|
@@ -40065,14 +40111,21 @@ function applySelectionFontColor(editor, fontColor) {
|
|
|
40065
40111
|
if (!marks) {
|
|
40066
40112
|
return;
|
|
40067
40113
|
}
|
|
40068
|
-
|
|
40114
|
+
if (editor.selection && Range11.isExpanded(editor.selection)) {
|
|
40115
|
+
Transforms21.setNodes(editor, { fontColor }, {
|
|
40116
|
+
match: (n) => Text10.isText(n),
|
|
40117
|
+
split: true
|
|
40118
|
+
});
|
|
40119
|
+
} else {
|
|
40120
|
+
Editor28.addMark(editor, "fontColor", fontColor);
|
|
40121
|
+
}
|
|
40069
40122
|
}
|
|
40070
40123
|
var init_applySelectionFontColor = __esm(() => {
|
|
40071
40124
|
init_getSelectionMarks();
|
|
40072
40125
|
});
|
|
40073
40126
|
|
|
40074
40127
|
// src/Items/RichText/editorHelpers/selectionOps/applySelectionFontSize.ts
|
|
40075
|
-
import { Editor as Editor29, Transforms as
|
|
40128
|
+
import { Editor as Editor29, Range as Range12, Text as Text11, Transforms as Transforms22 } from "slate";
|
|
40076
40129
|
function applySelectionFontSize(editor, fontSize, selectionContext) {
|
|
40077
40130
|
const size = fontSize;
|
|
40078
40131
|
if (typeof size !== "number") {
|
|
@@ -40087,12 +40140,19 @@ function applySelectionFontSize(editor, fontSize, selectionContext) {
|
|
|
40087
40140
|
return;
|
|
40088
40141
|
}
|
|
40089
40142
|
if (JSON.stringify(selection?.anchor) === JSON.stringify(selection?.focus)) {
|
|
40090
|
-
|
|
40143
|
+
Transforms22.select(editor, {
|
|
40091
40144
|
anchor: Editor29.start(editor, []),
|
|
40092
40145
|
focus: Editor29.end(editor, [])
|
|
40093
40146
|
});
|
|
40094
40147
|
}
|
|
40095
|
-
|
|
40148
|
+
if (editor.selection && Range12.isExpanded(editor.selection)) {
|
|
40149
|
+
Transforms22.setNodes(editor, { fontSize: size }, {
|
|
40150
|
+
match: (n) => Text11.isText(n),
|
|
40151
|
+
split: true
|
|
40152
|
+
});
|
|
40153
|
+
} else {
|
|
40154
|
+
Editor29.addMark(editor, "fontSize", size);
|
|
40155
|
+
}
|
|
40096
40156
|
if (selectionContext === "EditTextUnderPointer") {}
|
|
40097
40157
|
}
|
|
40098
40158
|
var init_applySelectionFontSize = __esm(() => {
|
|
@@ -40175,8 +40235,8 @@ var init_setEditorFocus = () => {};
|
|
|
40175
40235
|
import {
|
|
40176
40236
|
Editor as Editor31,
|
|
40177
40237
|
Element as Element9,
|
|
40178
|
-
Text as
|
|
40179
|
-
Transforms as
|
|
40238
|
+
Text as Text12,
|
|
40239
|
+
Transforms as Transforms23
|
|
40180
40240
|
} from "slate";
|
|
40181
40241
|
var isEditInProcessValue = false, counter = 0, RichText;
|
|
40182
40242
|
var init_RichText = __esm(() => {
|
|
@@ -40211,7 +40271,7 @@ var init_RichText = __esm(() => {
|
|
|
40211
40271
|
parent = "Board";
|
|
40212
40272
|
subject = new Subject;
|
|
40213
40273
|
editor;
|
|
40214
|
-
editorTransforms =
|
|
40274
|
+
editorTransforms = Transforms23;
|
|
40215
40275
|
editorEditor = Editor31;
|
|
40216
40276
|
isContainerSet = false;
|
|
40217
40277
|
isRenderEnabled = true;
|
|
@@ -40743,7 +40803,7 @@ var init_RichText = __esm(() => {
|
|
|
40743
40803
|
}
|
|
40744
40804
|
getMinFontSize() {
|
|
40745
40805
|
const textNodes = Editor31.nodes(this.editor.editor, {
|
|
40746
|
-
match: (n) =>
|
|
40806
|
+
match: (n) => Text12.isText(n),
|
|
40747
40807
|
at: []
|
|
40748
40808
|
});
|
|
40749
40809
|
const fontSizes = [];
|
|
@@ -40847,9 +40907,9 @@ var init_RichText = __esm(() => {
|
|
|
40847
40907
|
}
|
|
40848
40908
|
restoreSelection(selection) {
|
|
40849
40909
|
if (selection) {
|
|
40850
|
-
|
|
40910
|
+
Transforms23.select(this.editor.editor, selection);
|
|
40851
40911
|
} else {
|
|
40852
|
-
|
|
40912
|
+
Transforms23.deselect(this.editor.editor);
|
|
40853
40913
|
}
|
|
40854
40914
|
}
|
|
40855
40915
|
deserialize(data) {
|
|
@@ -41759,6 +41819,35 @@ var init_Audio = __esm(() => {
|
|
|
41759
41819
|
};
|
|
41760
41820
|
});
|
|
41761
41821
|
|
|
41822
|
+
// src/api/AuthRequest.ts
|
|
41823
|
+
async function authenticatedFetch(url2, init2 = {}, boardId) {
|
|
41824
|
+
const getAuthInit = (originalInit) => {
|
|
41825
|
+
const token = conf.getAccessToken();
|
|
41826
|
+
if (!token) {
|
|
41827
|
+
return originalInit;
|
|
41828
|
+
}
|
|
41829
|
+
const headers = new Headers(originalInit.headers);
|
|
41830
|
+
headers.set("Authorization", `Bearer ${token}`);
|
|
41831
|
+
return { ...originalInit, headers };
|
|
41832
|
+
};
|
|
41833
|
+
let response = await fetch(url2, getAuthInit(init2));
|
|
41834
|
+
if (response.status === 401) {
|
|
41835
|
+
const body = await response.clone().json().catch(() => ({}));
|
|
41836
|
+
if (body.code === "AUTH_INVALID_ACCESS_TOKEN") {
|
|
41837
|
+
const refreshed = await conf.onAuthInvalid(boardId);
|
|
41838
|
+
if (refreshed) {
|
|
41839
|
+
response = await fetch(url2, getAuthInit(init2));
|
|
41840
|
+
} else {
|
|
41841
|
+
conf.onAuthTerminalFailure(boardId, body.code);
|
|
41842
|
+
}
|
|
41843
|
+
}
|
|
41844
|
+
}
|
|
41845
|
+
return response;
|
|
41846
|
+
}
|
|
41847
|
+
var init_AuthRequest = __esm(() => {
|
|
41848
|
+
init_Settings();
|
|
41849
|
+
});
|
|
41850
|
+
|
|
41762
41851
|
// src/api/MediaHelpers.ts
|
|
41763
41852
|
function getAccessTypeFromUrl(url2) {
|
|
41764
41853
|
try {
|
|
@@ -41776,15 +41865,14 @@ function getAccessTypeFromUrl(url2) {
|
|
|
41776
41865
|
}
|
|
41777
41866
|
return null;
|
|
41778
41867
|
}
|
|
41779
|
-
var uploadSvgDirectly = async (blob,
|
|
41780
|
-
const response = await
|
|
41868
|
+
var uploadSvgDirectly = async (blob, boardId, baseUrl) => {
|
|
41869
|
+
const response = await authenticatedFetch(`${baseUrl || ""}/svg/${boardId}`, {
|
|
41781
41870
|
method: "POST",
|
|
41782
41871
|
headers: {
|
|
41783
|
-
"Content-Type": "image/svg+xml"
|
|
41784
|
-
Authorization: `Bearer ${accessToken}`
|
|
41872
|
+
"Content-Type": "image/svg+xml"
|
|
41785
41873
|
},
|
|
41786
41874
|
body: blob
|
|
41787
|
-
});
|
|
41875
|
+
}, boardId);
|
|
41788
41876
|
if (!response.ok) {
|
|
41789
41877
|
conf.hooks.onUploadMediaError(response, "image");
|
|
41790
41878
|
throw new Error(`Failed to upload SVG. Status: ${response.status}`);
|
|
@@ -41794,19 +41882,18 @@ var uploadSvgDirectly = async (blob, accessToken, boardId, baseUrl) => {
|
|
|
41794
41882
|
throw new Error("Server did not provide a key for the uploaded SVG.");
|
|
41795
41883
|
}
|
|
41796
41884
|
return data.url;
|
|
41797
|
-
}, uploadWithPresignedUrl = async (blob,
|
|
41798
|
-
const generateUrlResponse = await
|
|
41885
|
+
}, uploadWithPresignedUrl = async (blob, boardId, type, baseUrl) => {
|
|
41886
|
+
const generateUrlResponse = await authenticatedFetch(`${baseUrl || ""}/media/upload`, {
|
|
41799
41887
|
method: "POST",
|
|
41800
41888
|
headers: {
|
|
41801
|
-
"Content-Type": "application/json"
|
|
41802
|
-
Authorization: `Bearer ${accessToken}`
|
|
41889
|
+
"Content-Type": "application/json"
|
|
41803
41890
|
},
|
|
41804
41891
|
body: JSON.stringify({
|
|
41805
41892
|
fileSize: blob.size,
|
|
41806
41893
|
fileType: blob.type,
|
|
41807
41894
|
boardId
|
|
41808
41895
|
})
|
|
41809
|
-
});
|
|
41896
|
+
}, boardId);
|
|
41810
41897
|
if (!generateUrlResponse.ok) {
|
|
41811
41898
|
conf.hooks.onUploadMediaError(generateUrlResponse, type);
|
|
41812
41899
|
throw new Error(`Failed to get presigned URL. Status: ${generateUrlResponse.status}`);
|
|
@@ -41828,18 +41915,18 @@ var uploadSvgDirectly = async (blob, accessToken, boardId, baseUrl) => {
|
|
|
41828
41915
|
throw new Error(`Direct upload to storage failed. Status: ${uploadResponse.status}`);
|
|
41829
41916
|
}
|
|
41830
41917
|
return url2;
|
|
41831
|
-
}, uploadMediaToStorage = async (blob,
|
|
41918
|
+
}, uploadMediaToStorage = async (blob, boardId, type, baseUrl) => {
|
|
41832
41919
|
try {
|
|
41833
41920
|
if (blob.type === "image/svg+xml") {
|
|
41834
|
-
return await uploadSvgDirectly(blob,
|
|
41921
|
+
return await uploadSvgDirectly(blob, boardId, baseUrl);
|
|
41835
41922
|
} else {
|
|
41836
|
-
return await uploadWithPresignedUrl(blob,
|
|
41923
|
+
return await uploadWithPresignedUrl(blob, boardId, type, baseUrl);
|
|
41837
41924
|
}
|
|
41838
41925
|
} catch (error48) {
|
|
41839
41926
|
console.error("Media upload process error:", error48);
|
|
41840
41927
|
throw error48;
|
|
41841
41928
|
}
|
|
41842
|
-
}, getMediaSignedUrl = async (url2
|
|
41929
|
+
}, getMediaSignedUrl = async (url2) => {
|
|
41843
41930
|
const accessType = getAccessTypeFromUrl(url2);
|
|
41844
41931
|
if (!accessType) {
|
|
41845
41932
|
return null;
|
|
@@ -41847,15 +41934,9 @@ var uploadSvgDirectly = async (blob, accessToken, boardId, baseUrl) => {
|
|
|
41847
41934
|
if (accessType === "anonymous") {
|
|
41848
41935
|
return url2;
|
|
41849
41936
|
}
|
|
41850
|
-
if (!accessToken) {
|
|
41851
|
-
return null;
|
|
41852
|
-
}
|
|
41853
41937
|
try {
|
|
41854
|
-
const response = await
|
|
41855
|
-
method: "GET"
|
|
41856
|
-
headers: {
|
|
41857
|
-
Authorization: `Bearer ${accessToken}`
|
|
41858
|
-
}
|
|
41938
|
+
const response = await authenticatedFetch(url2, {
|
|
41939
|
+
method: "GET"
|
|
41859
41940
|
});
|
|
41860
41941
|
if (!response.ok) {
|
|
41861
41942
|
console.error("Failed to get media signed url:", response.status, response.statusText);
|
|
@@ -41870,15 +41951,16 @@ var uploadSvgDirectly = async (blob, accessToken, boardId, baseUrl) => {
|
|
|
41870
41951
|
};
|
|
41871
41952
|
var init_MediaHelpers = __esm(() => {
|
|
41872
41953
|
init_Settings();
|
|
41954
|
+
init_AuthRequest();
|
|
41873
41955
|
});
|
|
41874
41956
|
|
|
41875
41957
|
// src/Items/Audio/AudioHelpers.ts
|
|
41876
|
-
var prepareAudio = (file2,
|
|
41958
|
+
var prepareAudio = (file2, boardId, baseUrl) => {
|
|
41877
41959
|
return new Promise((resolve, reject) => {
|
|
41878
41960
|
const audio = document.createElement("audio");
|
|
41879
41961
|
audio.src = URL.createObjectURL(file2);
|
|
41880
41962
|
audio.onloadedmetadata = () => {
|
|
41881
|
-
uploadMediaToStorage(file2,
|
|
41963
|
+
uploadMediaToStorage(file2, boardId, "audio", baseUrl).then((url2) => {
|
|
41882
41964
|
resolve(url2);
|
|
41883
41965
|
}).catch(reject);
|
|
41884
41966
|
};
|
|
@@ -60405,7 +60487,7 @@ var init_Video = __esm(() => {
|
|
|
60405
60487
|
async setPreviewUrl(url2) {
|
|
60406
60488
|
if (this.isStorageUrl) {
|
|
60407
60489
|
try {
|
|
60408
|
-
this.preview.src = await getMediaSignedUrl(url2
|
|
60490
|
+
this.preview.src = await getMediaSignedUrl(url2) || "";
|
|
60409
60491
|
} catch (err) {
|
|
60410
60492
|
console.error(err);
|
|
60411
60493
|
this.onError();
|
|
@@ -60765,9 +60847,9 @@ var getBlobFromDataURL = (dataURL) => {
|
|
|
60765
60847
|
};
|
|
60766
60848
|
}
|
|
60767
60849
|
});
|
|
60768
|
-
}, prepareImage = (inp,
|
|
60850
|
+
}, prepareImage = (inp, boardId, baseUrl) => resizeAndConvertToPng(inp).then(({ width: width2, height: height2, dataURL, hash: hash2 }) => {
|
|
60769
60851
|
const { blob, mimeType } = getBlobFromDataURL(dataURL);
|
|
60770
|
-
return uploadMediaToStorage(blob,
|
|
60852
|
+
return uploadMediaToStorage(blob, boardId, "image", baseUrl).then((src) => {
|
|
60771
60853
|
return {
|
|
60772
60854
|
imageDimension: { width: width2, height: height2 },
|
|
60773
60855
|
base64: dataURL,
|
|
@@ -60808,15 +60890,15 @@ var getVideoMetadata = (file2) => {
|
|
|
60808
60890
|
board.selection.add(boardVideo);
|
|
60809
60891
|
onLoadCb(boardVideo);
|
|
60810
60892
|
});
|
|
60811
|
-
}, prepareVideo = (file2,
|
|
60893
|
+
}, prepareVideo = (file2, boardId, baseUrl) => {
|
|
60812
60894
|
return new Promise((resolve2, reject) => {
|
|
60813
60895
|
const video = document.createElement("video");
|
|
60814
60896
|
video.src = URL.createObjectURL(file2);
|
|
60815
60897
|
video.onloadedmetadata = () => {
|
|
60816
60898
|
video.onseeked = () => {
|
|
60817
60899
|
video.onseeked = null;
|
|
60818
|
-
prepareImage(captureFrame(0.1, video)?.src,
|
|
60819
|
-
uploadMediaToStorage(file2,
|
|
60900
|
+
prepareImage(captureFrame(0.1, video)?.src, boardId, baseUrl).then((imageData) => {
|
|
60901
|
+
uploadMediaToStorage(file2, boardId, "video", baseUrl).then((url2) => {
|
|
60820
60902
|
resolve2({
|
|
60821
60903
|
url: url2,
|
|
60822
60904
|
previewUrl: imageData.storageLink
|
|
@@ -66804,8 +66886,8 @@ var init_Card = __esm(() => {
|
|
|
66804
66886
|
async createImages() {
|
|
66805
66887
|
this.face = conf.documentFactory.createElement("img");
|
|
66806
66888
|
this.backside = conf.documentFactory.createElement("img");
|
|
66807
|
-
this.face.src = await getMediaSignedUrl(this.faceUrl
|
|
66808
|
-
this.backside.src = await getMediaSignedUrl(this.backsideUrl
|
|
66889
|
+
this.face.src = await getMediaSignedUrl(this.faceUrl) || "";
|
|
66890
|
+
this.backside.src = await getMediaSignedUrl(this.backsideUrl) || "";
|
|
66809
66891
|
this.face.onload = () => {
|
|
66810
66892
|
this.subject.publish(this);
|
|
66811
66893
|
};
|
|
@@ -67506,7 +67588,7 @@ var init_Dice = __esm(() => {
|
|
|
67506
67588
|
this.renderValues[index2] = value;
|
|
67507
67589
|
} else {
|
|
67508
67590
|
const image2 = conf.documentFactory.createElement("img");
|
|
67509
|
-
image2.src = await getMediaSignedUrl(value
|
|
67591
|
+
image2.src = await getMediaSignedUrl(value) || "";
|
|
67510
67592
|
this.renderValues[index2] = image2;
|
|
67511
67593
|
image2.onload = () => {
|
|
67512
67594
|
this.subject.publish(this);
|
|
@@ -67961,7 +68043,7 @@ var init_Screen = __esm(() => {
|
|
|
67961
68043
|
this.backgroundUrl = url2 || "";
|
|
67962
68044
|
if (url2) {
|
|
67963
68045
|
this.backgroundImage = conf.documentFactory.createElement("img");
|
|
67964
|
-
this.backgroundImage.src = await getMediaSignedUrl(url2
|
|
68046
|
+
this.backgroundImage.src = await getMediaSignedUrl(url2) || "";
|
|
67965
68047
|
this.applyBackgroundColor("none");
|
|
67966
68048
|
this.backgroundImage.onload = () => {
|
|
67967
68049
|
this.subject.publish(this);
|
|
@@ -69823,7 +69905,7 @@ var init_Image = __esm(() => {
|
|
|
69823
69905
|
}
|
|
69824
69906
|
async setStorageLink(link2) {
|
|
69825
69907
|
this.storageLink = link2;
|
|
69826
|
-
this.signedUrl = await getMediaSignedUrl(link2
|
|
69908
|
+
this.signedUrl = await getMediaSignedUrl(link2) || "";
|
|
69827
69909
|
if (!this.signedUrl) {
|
|
69828
69910
|
const canvas = conf.documentFactory.createElement("canvas");
|
|
69829
69911
|
canvas.width = 100;
|
|
@@ -70244,7 +70326,7 @@ function handleAudioGenerate(response, board) {
|
|
|
70244
70326
|
}
|
|
70245
70327
|
function handleImageGenerate(response, board) {
|
|
70246
70328
|
if (response.status === "completed" && response.base64) {
|
|
70247
|
-
prepareImage(response.base64,
|
|
70329
|
+
prepareImage(response.base64, board.getBoardId()).then((imageData) => {
|
|
70248
70330
|
const placeholderId = board.aiImagePlaceholder?.getId();
|
|
70249
70331
|
if (placeholderId) {
|
|
70250
70332
|
const placeholderNode = board.items.getById(placeholderId);
|