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/index.js
CHANGED
|
@@ -3638,6 +3638,8 @@ var init_Settings = __esm(() => {
|
|
|
3638
3638
|
getDPI: () => 1,
|
|
3639
3639
|
reactEditorFocus: () => {},
|
|
3640
3640
|
reactEditorToSlatePoint: () => null,
|
|
3641
|
+
onAuthInvalid: async () => false,
|
|
3642
|
+
onAuthTerminalFailure: () => {},
|
|
3641
3643
|
planNames: {
|
|
3642
3644
|
basic: "Basic",
|
|
3643
3645
|
plus: "Plus",
|
|
@@ -14397,6 +14399,11 @@ class Events {
|
|
|
14397
14399
|
getOpKey(op) {
|
|
14398
14400
|
return op.method;
|
|
14399
14401
|
}
|
|
14402
|
+
refreshIdentity() {
|
|
14403
|
+
const sessionId = this.getSessionId();
|
|
14404
|
+
const authorUserId = this.getAuthorUserId();
|
|
14405
|
+
this.log.refreshUnconfirmedIdentity(sessionId, authorUserId);
|
|
14406
|
+
}
|
|
14400
14407
|
getSessionId() {
|
|
14401
14408
|
return getConnectionSessionId(this.connection);
|
|
14402
14409
|
}
|
|
@@ -31816,9 +31823,34 @@ var init_setLink = __esm(() => {
|
|
|
31816
31823
|
});
|
|
31817
31824
|
|
|
31818
31825
|
// src/Items/RichText/editorHelpers/common/getSelectionMarks.ts
|
|
31819
|
-
import { Editor as Editor13 } from "slate";
|
|
31826
|
+
import { Editor as Editor13, Range as Range6, Text as Text7 } from "slate";
|
|
31820
31827
|
function getSelectionMarks(editor) {
|
|
31821
|
-
|
|
31828
|
+
const marks = Editor13.marks(editor);
|
|
31829
|
+
if (!editor.selection) {
|
|
31830
|
+
return marks;
|
|
31831
|
+
}
|
|
31832
|
+
if (!Range6.isExpanded(editor.selection) || marks && Object.keys(marks).length > 0) {
|
|
31833
|
+
return marks;
|
|
31834
|
+
}
|
|
31835
|
+
const textEntries = Array.from(Editor13.nodes(editor, {
|
|
31836
|
+
at: editor.selection,
|
|
31837
|
+
match: (node) => Text7.isText(node)
|
|
31838
|
+
}));
|
|
31839
|
+
const [firstEntry, ...restEntries] = textEntries;
|
|
31840
|
+
if (!firstEntry) {
|
|
31841
|
+
return marks;
|
|
31842
|
+
}
|
|
31843
|
+
const { text: _firstText, ...firstMarks } = firstEntry[0];
|
|
31844
|
+
const commonMarks = { ...firstMarks };
|
|
31845
|
+
for (const [node] of restEntries) {
|
|
31846
|
+
const { text: _text, ...nodeMarks } = node;
|
|
31847
|
+
for (const key of Object.keys(commonMarks)) {
|
|
31848
|
+
if (commonMarks[key] !== nodeMarks[key]) {
|
|
31849
|
+
delete commonMarks[key];
|
|
31850
|
+
}
|
|
31851
|
+
}
|
|
31852
|
+
}
|
|
31853
|
+
return commonMarks;
|
|
31822
31854
|
}
|
|
31823
31855
|
var init_getSelectionMarks = () => {};
|
|
31824
31856
|
|
|
@@ -31837,13 +31869,13 @@ var init_clearText = __esm(() => {
|
|
|
31837
31869
|
});
|
|
31838
31870
|
|
|
31839
31871
|
// src/Items/RichText/editorHelpers/common/hasTextInSelection.ts
|
|
31840
|
-
import { Editor as Editor15, Range as
|
|
31872
|
+
import { Editor as Editor15, Range as Range7 } from "slate";
|
|
31841
31873
|
function hasTextInSelection(editor) {
|
|
31842
31874
|
const { selection } = editor;
|
|
31843
|
-
if (!selection ||
|
|
31875
|
+
if (!selection || Range7.isCollapsed(selection)) {
|
|
31844
31876
|
return false;
|
|
31845
31877
|
}
|
|
31846
|
-
const [start, end] =
|
|
31878
|
+
const [start, end] = Range7.edges(selection);
|
|
31847
31879
|
const text = Editor15.string(editor, { anchor: start, focus: end });
|
|
31848
31880
|
return text.length > 0;
|
|
31849
31881
|
}
|
|
@@ -39392,7 +39424,7 @@ function getParagraphWithPassedTextNode(textNode) {
|
|
|
39392
39424
|
}
|
|
39393
39425
|
|
|
39394
39426
|
// src/Items/RichText/editorHelpers/selectionOps/setSelectionFontSize.ts
|
|
39395
|
-
import { Editor as Editor24, Transforms as Transforms17 } from "slate";
|
|
39427
|
+
import { Editor as Editor24, Range as Range8, Text as Text8, Transforms as Transforms17 } from "slate";
|
|
39396
39428
|
import { ReactEditor as ReactEditor3 } from "slate-react";
|
|
39397
39429
|
function setSelectionFontSize(editor, isAutosize, fontSize, selectionContext) {
|
|
39398
39430
|
const size = fontSize;
|
|
@@ -39427,7 +39459,14 @@ function setSelectionFontSize(editor, isAutosize, fontSize, selectionContext) {
|
|
|
39427
39459
|
shouldUpdateElement = true;
|
|
39428
39460
|
}
|
|
39429
39461
|
} else {
|
|
39430
|
-
|
|
39462
|
+
if (editor.selection && Range8.isExpanded(editor.selection)) {
|
|
39463
|
+
Transforms17.setNodes(editor, { fontSize: size }, {
|
|
39464
|
+
match: (n) => Text8.isText(n),
|
|
39465
|
+
split: true
|
|
39466
|
+
});
|
|
39467
|
+
} else {
|
|
39468
|
+
Editor24.addMark(editor, "fontSize", size);
|
|
39469
|
+
}
|
|
39431
39470
|
}
|
|
39432
39471
|
}
|
|
39433
39472
|
if (selectionContext === "EditTextUnderPointer") {
|
|
@@ -39465,7 +39504,7 @@ var init_getEachNodeInSelectionStyles = __esm(() => {
|
|
|
39465
39504
|
});
|
|
39466
39505
|
|
|
39467
39506
|
// src/Items/RichText/editorHelpers/selectionOps/setSelectionFontStyle.ts
|
|
39468
|
-
import { Editor as Editor25, Range as
|
|
39507
|
+
import { Editor as Editor25, Range as Range9, Transforms as Transforms18 } from "slate";
|
|
39469
39508
|
function setSelectionFontStyle(editor, style) {
|
|
39470
39509
|
const styleList = Array.isArray(style) ? style : [style];
|
|
39471
39510
|
for (const style2 of styleList) {
|
|
@@ -39482,7 +39521,7 @@ function setSelectionFontStyle(editor, style) {
|
|
|
39482
39521
|
continue;
|
|
39483
39522
|
}
|
|
39484
39523
|
const { selection } = editor;
|
|
39485
|
-
if (selection &&
|
|
39524
|
+
if (selection && Range9.isExpanded(selection)) {
|
|
39486
39525
|
Transforms18.setNodes(editor, { [style2]: value }, {
|
|
39487
39526
|
match: (n) => !Editor25.isEditor(n) && n.type === "text",
|
|
39488
39527
|
split: true
|
|
@@ -39497,7 +39536,7 @@ var init_setSelectionFontStyle = __esm(() => {
|
|
|
39497
39536
|
});
|
|
39498
39537
|
|
|
39499
39538
|
// src/Items/RichText/editorHelpers/selectionOps/setSelectionFontColor.ts
|
|
39500
|
-
import { Editor as Editor26 } from "slate";
|
|
39539
|
+
import { Editor as Editor26, Range as Range10, Text as Text9, Transforms as Transforms19 } from "slate";
|
|
39501
39540
|
import { ReactEditor as ReactEditor4 } from "slate-react";
|
|
39502
39541
|
function setSelectionFontColor(editor, format, selectionContext) {
|
|
39503
39542
|
const marks = getSelectionMarks(editor);
|
|
@@ -39505,7 +39544,14 @@ function setSelectionFontColor(editor, format, selectionContext) {
|
|
|
39505
39544
|
return;
|
|
39506
39545
|
}
|
|
39507
39546
|
if (marks.fontColor !== format) {
|
|
39508
|
-
|
|
39547
|
+
if (editor.selection && Range10.isExpanded(editor.selection)) {
|
|
39548
|
+
Transforms19.setNodes(editor, { fontColor: format }, {
|
|
39549
|
+
match: (n) => Text9.isText(n),
|
|
39550
|
+
split: true
|
|
39551
|
+
});
|
|
39552
|
+
} else {
|
|
39553
|
+
Editor26.addMark(editor, "fontColor", format);
|
|
39554
|
+
}
|
|
39509
39555
|
}
|
|
39510
39556
|
if (selectionContext === "EditTextUnderPointer") {
|
|
39511
39557
|
try {
|
|
@@ -39523,7 +39569,7 @@ var init_setSelectionFontColor = __esm(() => {
|
|
|
39523
39569
|
import {
|
|
39524
39570
|
createEditor,
|
|
39525
39571
|
Editor as Editor27,
|
|
39526
|
-
Transforms as
|
|
39572
|
+
Transforms as Transforms20
|
|
39527
39573
|
} from "slate";
|
|
39528
39574
|
import { withReact } from "slate-react";
|
|
39529
39575
|
|
|
@@ -39799,7 +39845,7 @@ class EditorContainer {
|
|
|
39799
39845
|
break;
|
|
39800
39846
|
}
|
|
39801
39847
|
if (selection) {
|
|
39802
|
-
|
|
39848
|
+
Transforms20.select(this.editor, selection);
|
|
39803
39849
|
}
|
|
39804
39850
|
}
|
|
39805
39851
|
applyMaxWidth(maxWidth) {
|
|
@@ -39959,7 +40005,7 @@ class EditorContainer {
|
|
|
39959
40005
|
return JSON.parse(JSON.stringify(this.editor.selection));
|
|
39960
40006
|
}
|
|
39961
40007
|
splitNode() {
|
|
39962
|
-
|
|
40008
|
+
Transforms20.splitNodes(this.editor, { always: true });
|
|
39963
40009
|
}
|
|
39964
40010
|
getBlockNodes() {
|
|
39965
40011
|
return this.editor.children;
|
|
@@ -40049,7 +40095,7 @@ var init_findOptimalMaxWidthForTextAutoSize = __esm(() => {
|
|
|
40049
40095
|
});
|
|
40050
40096
|
|
|
40051
40097
|
// src/Items/RichText/editorHelpers/selectionOps/applySelectionFontColor.ts
|
|
40052
|
-
import { Editor as Editor28 } from "slate";
|
|
40098
|
+
import { Editor as Editor28, Range as Range11, Text as Text10, Transforms as Transforms21 } from "slate";
|
|
40053
40099
|
function applySelectionFontColor(editor, fontColor) {
|
|
40054
40100
|
if (!editor) {
|
|
40055
40101
|
throw new Error("Editor is not initialized");
|
|
@@ -40058,14 +40104,21 @@ function applySelectionFontColor(editor, fontColor) {
|
|
|
40058
40104
|
if (!marks) {
|
|
40059
40105
|
return;
|
|
40060
40106
|
}
|
|
40061
|
-
|
|
40107
|
+
if (editor.selection && Range11.isExpanded(editor.selection)) {
|
|
40108
|
+
Transforms21.setNodes(editor, { fontColor }, {
|
|
40109
|
+
match: (n) => Text10.isText(n),
|
|
40110
|
+
split: true
|
|
40111
|
+
});
|
|
40112
|
+
} else {
|
|
40113
|
+
Editor28.addMark(editor, "fontColor", fontColor);
|
|
40114
|
+
}
|
|
40062
40115
|
}
|
|
40063
40116
|
var init_applySelectionFontColor = __esm(() => {
|
|
40064
40117
|
init_getSelectionMarks();
|
|
40065
40118
|
});
|
|
40066
40119
|
|
|
40067
40120
|
// src/Items/RichText/editorHelpers/selectionOps/applySelectionFontSize.ts
|
|
40068
|
-
import { Editor as Editor29, Transforms as
|
|
40121
|
+
import { Editor as Editor29, Range as Range12, Text as Text11, Transforms as Transforms22 } from "slate";
|
|
40069
40122
|
function applySelectionFontSize(editor, fontSize, selectionContext) {
|
|
40070
40123
|
const size = fontSize;
|
|
40071
40124
|
if (typeof size !== "number") {
|
|
@@ -40080,12 +40133,19 @@ function applySelectionFontSize(editor, fontSize, selectionContext) {
|
|
|
40080
40133
|
return;
|
|
40081
40134
|
}
|
|
40082
40135
|
if (JSON.stringify(selection?.anchor) === JSON.stringify(selection?.focus)) {
|
|
40083
|
-
|
|
40136
|
+
Transforms22.select(editor, {
|
|
40084
40137
|
anchor: Editor29.start(editor, []),
|
|
40085
40138
|
focus: Editor29.end(editor, [])
|
|
40086
40139
|
});
|
|
40087
40140
|
}
|
|
40088
|
-
|
|
40141
|
+
if (editor.selection && Range12.isExpanded(editor.selection)) {
|
|
40142
|
+
Transforms22.setNodes(editor, { fontSize: size }, {
|
|
40143
|
+
match: (n) => Text11.isText(n),
|
|
40144
|
+
split: true
|
|
40145
|
+
});
|
|
40146
|
+
} else {
|
|
40147
|
+
Editor29.addMark(editor, "fontSize", size);
|
|
40148
|
+
}
|
|
40089
40149
|
if (selectionContext === "EditTextUnderPointer") {}
|
|
40090
40150
|
}
|
|
40091
40151
|
var init_applySelectionFontSize = __esm(() => {
|
|
@@ -40168,8 +40228,8 @@ var init_setEditorFocus = () => {};
|
|
|
40168
40228
|
import {
|
|
40169
40229
|
Editor as Editor31,
|
|
40170
40230
|
Element as Element9,
|
|
40171
|
-
Text as
|
|
40172
|
-
Transforms as
|
|
40231
|
+
Text as Text12,
|
|
40232
|
+
Transforms as Transforms23
|
|
40173
40233
|
} from "slate";
|
|
40174
40234
|
var isEditInProcessValue = false, counter = 0, RichText;
|
|
40175
40235
|
var init_RichText = __esm(() => {
|
|
@@ -40204,7 +40264,7 @@ var init_RichText = __esm(() => {
|
|
|
40204
40264
|
parent = "Board";
|
|
40205
40265
|
subject = new Subject;
|
|
40206
40266
|
editor;
|
|
40207
|
-
editorTransforms =
|
|
40267
|
+
editorTransforms = Transforms23;
|
|
40208
40268
|
editorEditor = Editor31;
|
|
40209
40269
|
isContainerSet = false;
|
|
40210
40270
|
isRenderEnabled = true;
|
|
@@ -40736,7 +40796,7 @@ var init_RichText = __esm(() => {
|
|
|
40736
40796
|
}
|
|
40737
40797
|
getMinFontSize() {
|
|
40738
40798
|
const textNodes = Editor31.nodes(this.editor.editor, {
|
|
40739
|
-
match: (n) =>
|
|
40799
|
+
match: (n) => Text12.isText(n),
|
|
40740
40800
|
at: []
|
|
40741
40801
|
});
|
|
40742
40802
|
const fontSizes = [];
|
|
@@ -40840,9 +40900,9 @@ var init_RichText = __esm(() => {
|
|
|
40840
40900
|
}
|
|
40841
40901
|
restoreSelection(selection) {
|
|
40842
40902
|
if (selection) {
|
|
40843
|
-
|
|
40903
|
+
Transforms23.select(this.editor.editor, selection);
|
|
40844
40904
|
} else {
|
|
40845
|
-
|
|
40905
|
+
Transforms23.deselect(this.editor.editor);
|
|
40846
40906
|
}
|
|
40847
40907
|
}
|
|
40848
40908
|
deserialize(data) {
|
|
@@ -41752,6 +41812,35 @@ var init_Audio = __esm(() => {
|
|
|
41752
41812
|
};
|
|
41753
41813
|
});
|
|
41754
41814
|
|
|
41815
|
+
// src/api/AuthRequest.ts
|
|
41816
|
+
async function authenticatedFetch(url2, init2 = {}, boardId) {
|
|
41817
|
+
const getAuthInit = (originalInit) => {
|
|
41818
|
+
const token = conf.getAccessToken();
|
|
41819
|
+
if (!token) {
|
|
41820
|
+
return originalInit;
|
|
41821
|
+
}
|
|
41822
|
+
const headers = new Headers(originalInit.headers);
|
|
41823
|
+
headers.set("Authorization", `Bearer ${token}`);
|
|
41824
|
+
return { ...originalInit, headers };
|
|
41825
|
+
};
|
|
41826
|
+
let response = await fetch(url2, getAuthInit(init2));
|
|
41827
|
+
if (response.status === 401) {
|
|
41828
|
+
const body = await response.clone().json().catch(() => ({}));
|
|
41829
|
+
if (body.code === "AUTH_INVALID_ACCESS_TOKEN") {
|
|
41830
|
+
const refreshed = await conf.onAuthInvalid(boardId);
|
|
41831
|
+
if (refreshed) {
|
|
41832
|
+
response = await fetch(url2, getAuthInit(init2));
|
|
41833
|
+
} else {
|
|
41834
|
+
conf.onAuthTerminalFailure(boardId, body.code);
|
|
41835
|
+
}
|
|
41836
|
+
}
|
|
41837
|
+
}
|
|
41838
|
+
return response;
|
|
41839
|
+
}
|
|
41840
|
+
var init_AuthRequest = __esm(() => {
|
|
41841
|
+
init_Settings();
|
|
41842
|
+
});
|
|
41843
|
+
|
|
41755
41844
|
// src/api/MediaHelpers.ts
|
|
41756
41845
|
function getAccessTypeFromUrl(url2) {
|
|
41757
41846
|
try {
|
|
@@ -41769,15 +41858,14 @@ function getAccessTypeFromUrl(url2) {
|
|
|
41769
41858
|
}
|
|
41770
41859
|
return null;
|
|
41771
41860
|
}
|
|
41772
|
-
var uploadSvgDirectly = async (blob,
|
|
41773
|
-
const response = await
|
|
41861
|
+
var uploadSvgDirectly = async (blob, boardId, baseUrl) => {
|
|
41862
|
+
const response = await authenticatedFetch(`${baseUrl || ""}/svg/${boardId}`, {
|
|
41774
41863
|
method: "POST",
|
|
41775
41864
|
headers: {
|
|
41776
|
-
"Content-Type": "image/svg+xml"
|
|
41777
|
-
Authorization: `Bearer ${accessToken}`
|
|
41865
|
+
"Content-Type": "image/svg+xml"
|
|
41778
41866
|
},
|
|
41779
41867
|
body: blob
|
|
41780
|
-
});
|
|
41868
|
+
}, boardId);
|
|
41781
41869
|
if (!response.ok) {
|
|
41782
41870
|
conf.hooks.onUploadMediaError(response, "image");
|
|
41783
41871
|
throw new Error(`Failed to upload SVG. Status: ${response.status}`);
|
|
@@ -41787,19 +41875,18 @@ var uploadSvgDirectly = async (blob, accessToken, boardId, baseUrl) => {
|
|
|
41787
41875
|
throw new Error("Server did not provide a key for the uploaded SVG.");
|
|
41788
41876
|
}
|
|
41789
41877
|
return data.url;
|
|
41790
|
-
}, uploadWithPresignedUrl = async (blob,
|
|
41791
|
-
const generateUrlResponse = await
|
|
41878
|
+
}, uploadWithPresignedUrl = async (blob, boardId, type, baseUrl) => {
|
|
41879
|
+
const generateUrlResponse = await authenticatedFetch(`${baseUrl || ""}/media/upload`, {
|
|
41792
41880
|
method: "POST",
|
|
41793
41881
|
headers: {
|
|
41794
|
-
"Content-Type": "application/json"
|
|
41795
|
-
Authorization: `Bearer ${accessToken}`
|
|
41882
|
+
"Content-Type": "application/json"
|
|
41796
41883
|
},
|
|
41797
41884
|
body: JSON.stringify({
|
|
41798
41885
|
fileSize: blob.size,
|
|
41799
41886
|
fileType: blob.type,
|
|
41800
41887
|
boardId
|
|
41801
41888
|
})
|
|
41802
|
-
});
|
|
41889
|
+
}, boardId);
|
|
41803
41890
|
if (!generateUrlResponse.ok) {
|
|
41804
41891
|
conf.hooks.onUploadMediaError(generateUrlResponse, type);
|
|
41805
41892
|
throw new Error(`Failed to get presigned URL. Status: ${generateUrlResponse.status}`);
|
|
@@ -41821,18 +41908,18 @@ var uploadSvgDirectly = async (blob, accessToken, boardId, baseUrl) => {
|
|
|
41821
41908
|
throw new Error(`Direct upload to storage failed. Status: ${uploadResponse.status}`);
|
|
41822
41909
|
}
|
|
41823
41910
|
return url2;
|
|
41824
|
-
}, uploadMediaToStorage = async (blob,
|
|
41911
|
+
}, uploadMediaToStorage = async (blob, boardId, type, baseUrl) => {
|
|
41825
41912
|
try {
|
|
41826
41913
|
if (blob.type === "image/svg+xml") {
|
|
41827
|
-
return await uploadSvgDirectly(blob,
|
|
41914
|
+
return await uploadSvgDirectly(blob, boardId, baseUrl);
|
|
41828
41915
|
} else {
|
|
41829
|
-
return await uploadWithPresignedUrl(blob,
|
|
41916
|
+
return await uploadWithPresignedUrl(blob, boardId, type, baseUrl);
|
|
41830
41917
|
}
|
|
41831
41918
|
} catch (error48) {
|
|
41832
41919
|
console.error("Media upload process error:", error48);
|
|
41833
41920
|
throw error48;
|
|
41834
41921
|
}
|
|
41835
|
-
}, getMediaSignedUrl = async (url2
|
|
41922
|
+
}, getMediaSignedUrl = async (url2) => {
|
|
41836
41923
|
const accessType = getAccessTypeFromUrl(url2);
|
|
41837
41924
|
if (!accessType) {
|
|
41838
41925
|
return null;
|
|
@@ -41840,15 +41927,9 @@ var uploadSvgDirectly = async (blob, accessToken, boardId, baseUrl) => {
|
|
|
41840
41927
|
if (accessType === "anonymous") {
|
|
41841
41928
|
return url2;
|
|
41842
41929
|
}
|
|
41843
|
-
if (!accessToken) {
|
|
41844
|
-
return null;
|
|
41845
|
-
}
|
|
41846
41930
|
try {
|
|
41847
|
-
const response = await
|
|
41848
|
-
method: "GET"
|
|
41849
|
-
headers: {
|
|
41850
|
-
Authorization: `Bearer ${accessToken}`
|
|
41851
|
-
}
|
|
41931
|
+
const response = await authenticatedFetch(url2, {
|
|
41932
|
+
method: "GET"
|
|
41852
41933
|
});
|
|
41853
41934
|
if (!response.ok) {
|
|
41854
41935
|
console.error("Failed to get media signed url:", response.status, response.statusText);
|
|
@@ -41863,15 +41944,16 @@ var uploadSvgDirectly = async (blob, accessToken, boardId, baseUrl) => {
|
|
|
41863
41944
|
};
|
|
41864
41945
|
var init_MediaHelpers = __esm(() => {
|
|
41865
41946
|
init_Settings();
|
|
41947
|
+
init_AuthRequest();
|
|
41866
41948
|
});
|
|
41867
41949
|
|
|
41868
41950
|
// src/Items/Audio/AudioHelpers.ts
|
|
41869
|
-
var prepareAudio = (file2,
|
|
41951
|
+
var prepareAudio = (file2, boardId, baseUrl) => {
|
|
41870
41952
|
return new Promise((resolve, reject) => {
|
|
41871
41953
|
const audio = document.createElement("audio");
|
|
41872
41954
|
audio.src = URL.createObjectURL(file2);
|
|
41873
41955
|
audio.onloadedmetadata = () => {
|
|
41874
|
-
uploadMediaToStorage(file2,
|
|
41956
|
+
uploadMediaToStorage(file2, boardId, "audio", baseUrl).then((url2) => {
|
|
41875
41957
|
resolve(url2);
|
|
41876
41958
|
}).catch(reject);
|
|
41877
41959
|
};
|
|
@@ -60398,7 +60480,7 @@ var init_Video = __esm(() => {
|
|
|
60398
60480
|
async setPreviewUrl(url2) {
|
|
60399
60481
|
if (this.isStorageUrl) {
|
|
60400
60482
|
try {
|
|
60401
|
-
this.preview.src = await getMediaSignedUrl(url2
|
|
60483
|
+
this.preview.src = await getMediaSignedUrl(url2) || "";
|
|
60402
60484
|
} catch (err) {
|
|
60403
60485
|
console.error(err);
|
|
60404
60486
|
this.onError();
|
|
@@ -60758,9 +60840,9 @@ var getBlobFromDataURL = (dataURL) => {
|
|
|
60758
60840
|
};
|
|
60759
60841
|
}
|
|
60760
60842
|
});
|
|
60761
|
-
}, prepareImage = (inp,
|
|
60843
|
+
}, prepareImage = (inp, boardId, baseUrl) => resizeAndConvertToPng(inp).then(({ width: width2, height: height2, dataURL, hash: hash2 }) => {
|
|
60762
60844
|
const { blob, mimeType } = getBlobFromDataURL(dataURL);
|
|
60763
|
-
return uploadMediaToStorage(blob,
|
|
60845
|
+
return uploadMediaToStorage(blob, boardId, "image", baseUrl).then((src) => {
|
|
60764
60846
|
return {
|
|
60765
60847
|
imageDimension: { width: width2, height: height2 },
|
|
60766
60848
|
base64: dataURL,
|
|
@@ -60801,15 +60883,15 @@ var getVideoMetadata = (file2) => {
|
|
|
60801
60883
|
board.selection.add(boardVideo);
|
|
60802
60884
|
onLoadCb(boardVideo);
|
|
60803
60885
|
});
|
|
60804
|
-
}, prepareVideo = (file2,
|
|
60886
|
+
}, prepareVideo = (file2, boardId, baseUrl) => {
|
|
60805
60887
|
return new Promise((resolve2, reject) => {
|
|
60806
60888
|
const video = document.createElement("video");
|
|
60807
60889
|
video.src = URL.createObjectURL(file2);
|
|
60808
60890
|
video.onloadedmetadata = () => {
|
|
60809
60891
|
video.onseeked = () => {
|
|
60810
60892
|
video.onseeked = null;
|
|
60811
|
-
prepareImage(captureFrame(0.1, video)?.src,
|
|
60812
|
-
uploadMediaToStorage(file2,
|
|
60893
|
+
prepareImage(captureFrame(0.1, video)?.src, boardId, baseUrl).then((imageData) => {
|
|
60894
|
+
uploadMediaToStorage(file2, boardId, "video", baseUrl).then((url2) => {
|
|
60813
60895
|
resolve2({
|
|
60814
60896
|
url: url2,
|
|
60815
60897
|
previewUrl: imageData.storageLink
|
|
@@ -66797,8 +66879,8 @@ var init_Card = __esm(() => {
|
|
|
66797
66879
|
async createImages() {
|
|
66798
66880
|
this.face = conf.documentFactory.createElement("img");
|
|
66799
66881
|
this.backside = conf.documentFactory.createElement("img");
|
|
66800
|
-
this.face.src = await getMediaSignedUrl(this.faceUrl
|
|
66801
|
-
this.backside.src = await getMediaSignedUrl(this.backsideUrl
|
|
66882
|
+
this.face.src = await getMediaSignedUrl(this.faceUrl) || "";
|
|
66883
|
+
this.backside.src = await getMediaSignedUrl(this.backsideUrl) || "";
|
|
66802
66884
|
this.face.onload = () => {
|
|
66803
66885
|
this.subject.publish(this);
|
|
66804
66886
|
};
|
|
@@ -67499,7 +67581,7 @@ var init_Dice = __esm(() => {
|
|
|
67499
67581
|
this.renderValues[index2] = value;
|
|
67500
67582
|
} else {
|
|
67501
67583
|
const image2 = conf.documentFactory.createElement("img");
|
|
67502
|
-
image2.src = await getMediaSignedUrl(value
|
|
67584
|
+
image2.src = await getMediaSignedUrl(value) || "";
|
|
67503
67585
|
this.renderValues[index2] = image2;
|
|
67504
67586
|
image2.onload = () => {
|
|
67505
67587
|
this.subject.publish(this);
|
|
@@ -67954,7 +68036,7 @@ var init_Screen = __esm(() => {
|
|
|
67954
68036
|
this.backgroundUrl = url2 || "";
|
|
67955
68037
|
if (url2) {
|
|
67956
68038
|
this.backgroundImage = conf.documentFactory.createElement("img");
|
|
67957
|
-
this.backgroundImage.src = await getMediaSignedUrl(url2
|
|
68039
|
+
this.backgroundImage.src = await getMediaSignedUrl(url2) || "";
|
|
67958
68040
|
this.applyBackgroundColor("none");
|
|
67959
68041
|
this.backgroundImage.onload = () => {
|
|
67960
68042
|
this.subject.publish(this);
|
|
@@ -69816,7 +69898,7 @@ var init_Image = __esm(() => {
|
|
|
69816
69898
|
}
|
|
69817
69899
|
async setStorageLink(link2) {
|
|
69818
69900
|
this.storageLink = link2;
|
|
69819
|
-
this.signedUrl = await getMediaSignedUrl(link2
|
|
69901
|
+
this.signedUrl = await getMediaSignedUrl(link2) || "";
|
|
69820
69902
|
if (!this.signedUrl) {
|
|
69821
69903
|
const canvas = conf.documentFactory.createElement("canvas");
|
|
69822
69904
|
canvas.width = 100;
|
|
@@ -70237,7 +70319,7 @@ function handleAudioGenerate(response, board) {
|
|
|
70237
70319
|
}
|
|
70238
70320
|
function handleImageGenerate(response, board) {
|
|
70239
70321
|
if (response.status === "completed" && response.base64) {
|
|
70240
|
-
prepareImage(response.base64,
|
|
70322
|
+
prepareImage(response.base64, board.getBoardId()).then((imageData) => {
|
|
70241
70323
|
const placeholderId = board.aiImagePlaceholder?.getId();
|
|
70242
70324
|
if (placeholderId) {
|
|
70243
70325
|
const placeholderNode = board.items.getById(placeholderId);
|