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