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/cjs/browser.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",
|
|
@@ -14432,6 +14434,11 @@ class Events {
|
|
|
14432
14434
|
getOpKey(op) {
|
|
14433
14435
|
return op.method;
|
|
14434
14436
|
}
|
|
14437
|
+
refreshIdentity() {
|
|
14438
|
+
const sessionId = this.getSessionId();
|
|
14439
|
+
const authorUserId = this.getAuthorUserId();
|
|
14440
|
+
this.log.refreshUnconfirmedIdentity(sessionId, authorUserId);
|
|
14441
|
+
}
|
|
14435
14442
|
getSessionId() {
|
|
14436
14443
|
return getConnectionSessionId(this.connection);
|
|
14437
14444
|
}
|
|
@@ -31871,7 +31878,32 @@ var init_setLink = __esm(() => {
|
|
|
31871
31878
|
|
|
31872
31879
|
// src/Items/RichText/editorHelpers/common/getSelectionMarks.ts
|
|
31873
31880
|
function getSelectionMarks(editor) {
|
|
31874
|
-
|
|
31881
|
+
const marks = import_slate42.Editor.marks(editor);
|
|
31882
|
+
if (!editor.selection) {
|
|
31883
|
+
return marks;
|
|
31884
|
+
}
|
|
31885
|
+
if (!import_slate42.Range.isExpanded(editor.selection) || marks && Object.keys(marks).length > 0) {
|
|
31886
|
+
return marks;
|
|
31887
|
+
}
|
|
31888
|
+
const textEntries = Array.from(import_slate42.Editor.nodes(editor, {
|
|
31889
|
+
at: editor.selection,
|
|
31890
|
+
match: (node) => import_slate42.Text.isText(node)
|
|
31891
|
+
}));
|
|
31892
|
+
const [firstEntry, ...restEntries] = textEntries;
|
|
31893
|
+
if (!firstEntry) {
|
|
31894
|
+
return marks;
|
|
31895
|
+
}
|
|
31896
|
+
const { text: _firstText, ...firstMarks } = firstEntry[0];
|
|
31897
|
+
const commonMarks = { ...firstMarks };
|
|
31898
|
+
for (const [node] of restEntries) {
|
|
31899
|
+
const { text: _text, ...nodeMarks } = node;
|
|
31900
|
+
for (const key of Object.keys(commonMarks)) {
|
|
31901
|
+
if (commonMarks[key] !== nodeMarks[key]) {
|
|
31902
|
+
delete commonMarks[key];
|
|
31903
|
+
}
|
|
31904
|
+
}
|
|
31905
|
+
}
|
|
31906
|
+
return commonMarks;
|
|
31875
31907
|
}
|
|
31876
31908
|
var import_slate42;
|
|
31877
31909
|
var init_getSelectionMarks = __esm(() => {
|
|
@@ -39494,7 +39526,14 @@ function setSelectionFontSize(editor, isAutosize, fontSize, selectionContext) {
|
|
|
39494
39526
|
shouldUpdateElement = true;
|
|
39495
39527
|
}
|
|
39496
39528
|
} else {
|
|
39497
|
-
import_slate53.
|
|
39529
|
+
if (editor.selection && import_slate53.Range.isExpanded(editor.selection)) {
|
|
39530
|
+
import_slate53.Transforms.setNodes(editor, { fontSize: size }, {
|
|
39531
|
+
match: (n) => import_slate53.Text.isText(n),
|
|
39532
|
+
split: true
|
|
39533
|
+
});
|
|
39534
|
+
} else {
|
|
39535
|
+
import_slate53.Editor.addMark(editor, "fontSize", size);
|
|
39536
|
+
}
|
|
39498
39537
|
}
|
|
39499
39538
|
}
|
|
39500
39539
|
if (selectionContext === "EditTextUnderPointer") {
|
|
@@ -39574,7 +39613,14 @@ function setSelectionFontColor(editor, format, selectionContext) {
|
|
|
39574
39613
|
return;
|
|
39575
39614
|
}
|
|
39576
39615
|
if (marks.fontColor !== format) {
|
|
39577
|
-
import_slate55.
|
|
39616
|
+
if (editor.selection && import_slate55.Range.isExpanded(editor.selection)) {
|
|
39617
|
+
import_slate55.Transforms.setNodes(editor, { fontColor: format }, {
|
|
39618
|
+
match: (n) => import_slate55.Text.isText(n),
|
|
39619
|
+
split: true
|
|
39620
|
+
});
|
|
39621
|
+
} else {
|
|
39622
|
+
import_slate55.Editor.addMark(editor, "fontColor", format);
|
|
39623
|
+
}
|
|
39578
39624
|
}
|
|
39579
39625
|
if (selectionContext === "EditTextUnderPointer") {
|
|
39580
39626
|
try {
|
|
@@ -40125,7 +40171,14 @@ function applySelectionFontColor(editor, fontColor) {
|
|
|
40125
40171
|
if (!marks) {
|
|
40126
40172
|
return;
|
|
40127
40173
|
}
|
|
40128
|
-
import_slate57.
|
|
40174
|
+
if (editor.selection && import_slate57.Range.isExpanded(editor.selection)) {
|
|
40175
|
+
import_slate57.Transforms.setNodes(editor, { fontColor }, {
|
|
40176
|
+
match: (n) => import_slate57.Text.isText(n),
|
|
40177
|
+
split: true
|
|
40178
|
+
});
|
|
40179
|
+
} else {
|
|
40180
|
+
import_slate57.Editor.addMark(editor, "fontColor", fontColor);
|
|
40181
|
+
}
|
|
40129
40182
|
}
|
|
40130
40183
|
var import_slate57;
|
|
40131
40184
|
var init_applySelectionFontColor = __esm(() => {
|
|
@@ -40153,7 +40206,14 @@ function applySelectionFontSize(editor, fontSize, selectionContext) {
|
|
|
40153
40206
|
focus: import_slate58.Editor.end(editor, [])
|
|
40154
40207
|
});
|
|
40155
40208
|
}
|
|
40156
|
-
import_slate58.
|
|
40209
|
+
if (editor.selection && import_slate58.Range.isExpanded(editor.selection)) {
|
|
40210
|
+
import_slate58.Transforms.setNodes(editor, { fontSize: size }, {
|
|
40211
|
+
match: (n) => import_slate58.Text.isText(n),
|
|
40212
|
+
split: true
|
|
40213
|
+
});
|
|
40214
|
+
} else {
|
|
40215
|
+
import_slate58.Editor.addMark(editor, "fontSize", size);
|
|
40216
|
+
}
|
|
40157
40217
|
if (selectionContext === "EditTextUnderPointer") {}
|
|
40158
40218
|
}
|
|
40159
40219
|
var import_slate58;
|
|
@@ -41821,6 +41881,35 @@ var init_Audio = __esm(() => {
|
|
|
41821
41881
|
};
|
|
41822
41882
|
});
|
|
41823
41883
|
|
|
41884
|
+
// src/api/AuthRequest.ts
|
|
41885
|
+
async function authenticatedFetch(url2, init2 = {}, boardId) {
|
|
41886
|
+
const getAuthInit = (originalInit) => {
|
|
41887
|
+
const token = conf.getAccessToken();
|
|
41888
|
+
if (!token) {
|
|
41889
|
+
return originalInit;
|
|
41890
|
+
}
|
|
41891
|
+
const headers = new Headers(originalInit.headers);
|
|
41892
|
+
headers.set("Authorization", `Bearer ${token}`);
|
|
41893
|
+
return { ...originalInit, headers };
|
|
41894
|
+
};
|
|
41895
|
+
let response = await fetch(url2, getAuthInit(init2));
|
|
41896
|
+
if (response.status === 401) {
|
|
41897
|
+
const body = await response.clone().json().catch(() => ({}));
|
|
41898
|
+
if (body.code === "AUTH_INVALID_ACCESS_TOKEN") {
|
|
41899
|
+
const refreshed = await conf.onAuthInvalid(boardId);
|
|
41900
|
+
if (refreshed) {
|
|
41901
|
+
response = await fetch(url2, getAuthInit(init2));
|
|
41902
|
+
} else {
|
|
41903
|
+
conf.onAuthTerminalFailure(boardId, body.code);
|
|
41904
|
+
}
|
|
41905
|
+
}
|
|
41906
|
+
}
|
|
41907
|
+
return response;
|
|
41908
|
+
}
|
|
41909
|
+
var init_AuthRequest = __esm(() => {
|
|
41910
|
+
init_Settings();
|
|
41911
|
+
});
|
|
41912
|
+
|
|
41824
41913
|
// src/api/MediaHelpers.ts
|
|
41825
41914
|
function getAccessTypeFromUrl(url2) {
|
|
41826
41915
|
try {
|
|
@@ -41838,15 +41927,14 @@ function getAccessTypeFromUrl(url2) {
|
|
|
41838
41927
|
}
|
|
41839
41928
|
return null;
|
|
41840
41929
|
}
|
|
41841
|
-
var uploadSvgDirectly = async (blob,
|
|
41842
|
-
const response = await
|
|
41930
|
+
var uploadSvgDirectly = async (blob, boardId, baseUrl) => {
|
|
41931
|
+
const response = await authenticatedFetch(`${baseUrl || ""}/svg/${boardId}`, {
|
|
41843
41932
|
method: "POST",
|
|
41844
41933
|
headers: {
|
|
41845
|
-
"Content-Type": "image/svg+xml"
|
|
41846
|
-
Authorization: `Bearer ${accessToken}`
|
|
41934
|
+
"Content-Type": "image/svg+xml"
|
|
41847
41935
|
},
|
|
41848
41936
|
body: blob
|
|
41849
|
-
});
|
|
41937
|
+
}, boardId);
|
|
41850
41938
|
if (!response.ok) {
|
|
41851
41939
|
conf.hooks.onUploadMediaError(response, "image");
|
|
41852
41940
|
throw new Error(`Failed to upload SVG. Status: ${response.status}`);
|
|
@@ -41856,19 +41944,18 @@ var uploadSvgDirectly = async (blob, accessToken, boardId, baseUrl) => {
|
|
|
41856
41944
|
throw new Error("Server did not provide a key for the uploaded SVG.");
|
|
41857
41945
|
}
|
|
41858
41946
|
return data.url;
|
|
41859
|
-
}, uploadWithPresignedUrl = async (blob,
|
|
41860
|
-
const generateUrlResponse = await
|
|
41947
|
+
}, uploadWithPresignedUrl = async (blob, boardId, type, baseUrl) => {
|
|
41948
|
+
const generateUrlResponse = await authenticatedFetch(`${baseUrl || ""}/media/upload`, {
|
|
41861
41949
|
method: "POST",
|
|
41862
41950
|
headers: {
|
|
41863
|
-
"Content-Type": "application/json"
|
|
41864
|
-
Authorization: `Bearer ${accessToken}`
|
|
41951
|
+
"Content-Type": "application/json"
|
|
41865
41952
|
},
|
|
41866
41953
|
body: JSON.stringify({
|
|
41867
41954
|
fileSize: blob.size,
|
|
41868
41955
|
fileType: blob.type,
|
|
41869
41956
|
boardId
|
|
41870
41957
|
})
|
|
41871
|
-
});
|
|
41958
|
+
}, boardId);
|
|
41872
41959
|
if (!generateUrlResponse.ok) {
|
|
41873
41960
|
conf.hooks.onUploadMediaError(generateUrlResponse, type);
|
|
41874
41961
|
throw new Error(`Failed to get presigned URL. Status: ${generateUrlResponse.status}`);
|
|
@@ -41890,18 +41977,18 @@ var uploadSvgDirectly = async (blob, accessToken, boardId, baseUrl) => {
|
|
|
41890
41977
|
throw new Error(`Direct upload to storage failed. Status: ${uploadResponse.status}`);
|
|
41891
41978
|
}
|
|
41892
41979
|
return url2;
|
|
41893
|
-
}, uploadMediaToStorage = async (blob,
|
|
41980
|
+
}, uploadMediaToStorage = async (blob, boardId, type, baseUrl) => {
|
|
41894
41981
|
try {
|
|
41895
41982
|
if (blob.type === "image/svg+xml") {
|
|
41896
|
-
return await uploadSvgDirectly(blob,
|
|
41983
|
+
return await uploadSvgDirectly(blob, boardId, baseUrl);
|
|
41897
41984
|
} else {
|
|
41898
|
-
return await uploadWithPresignedUrl(blob,
|
|
41985
|
+
return await uploadWithPresignedUrl(blob, boardId, type, baseUrl);
|
|
41899
41986
|
}
|
|
41900
41987
|
} catch (error48) {
|
|
41901
41988
|
console.error("Media upload process error:", error48);
|
|
41902
41989
|
throw error48;
|
|
41903
41990
|
}
|
|
41904
|
-
}, getMediaSignedUrl = async (url2
|
|
41991
|
+
}, getMediaSignedUrl = async (url2) => {
|
|
41905
41992
|
const accessType = getAccessTypeFromUrl(url2);
|
|
41906
41993
|
if (!accessType) {
|
|
41907
41994
|
return null;
|
|
@@ -41909,15 +41996,9 @@ var uploadSvgDirectly = async (blob, accessToken, boardId, baseUrl) => {
|
|
|
41909
41996
|
if (accessType === "anonymous") {
|
|
41910
41997
|
return url2;
|
|
41911
41998
|
}
|
|
41912
|
-
if (!accessToken) {
|
|
41913
|
-
return null;
|
|
41914
|
-
}
|
|
41915
41999
|
try {
|
|
41916
|
-
const response = await
|
|
41917
|
-
method: "GET"
|
|
41918
|
-
headers: {
|
|
41919
|
-
Authorization: `Bearer ${accessToken}`
|
|
41920
|
-
}
|
|
42000
|
+
const response = await authenticatedFetch(url2, {
|
|
42001
|
+
method: "GET"
|
|
41921
42002
|
});
|
|
41922
42003
|
if (!response.ok) {
|
|
41923
42004
|
console.error("Failed to get media signed url:", response.status, response.statusText);
|
|
@@ -41932,15 +42013,16 @@ var uploadSvgDirectly = async (blob, accessToken, boardId, baseUrl) => {
|
|
|
41932
42013
|
};
|
|
41933
42014
|
var init_MediaHelpers = __esm(() => {
|
|
41934
42015
|
init_Settings();
|
|
42016
|
+
init_AuthRequest();
|
|
41935
42017
|
});
|
|
41936
42018
|
|
|
41937
42019
|
// src/Items/Audio/AudioHelpers.ts
|
|
41938
|
-
var prepareAudio = (file2,
|
|
42020
|
+
var prepareAudio = (file2, boardId, baseUrl) => {
|
|
41939
42021
|
return new Promise((resolve, reject) => {
|
|
41940
42022
|
const audio = document.createElement("audio");
|
|
41941
42023
|
audio.src = URL.createObjectURL(file2);
|
|
41942
42024
|
audio.onloadedmetadata = () => {
|
|
41943
|
-
uploadMediaToStorage(file2,
|
|
42025
|
+
uploadMediaToStorage(file2, boardId, "audio", baseUrl).then((url2) => {
|
|
41944
42026
|
resolve(url2);
|
|
41945
42027
|
}).catch(reject);
|
|
41946
42028
|
};
|
|
@@ -60467,7 +60549,7 @@ var init_Video = __esm(() => {
|
|
|
60467
60549
|
async setPreviewUrl(url2) {
|
|
60468
60550
|
if (this.isStorageUrl) {
|
|
60469
60551
|
try {
|
|
60470
|
-
this.preview.src = await getMediaSignedUrl(url2
|
|
60552
|
+
this.preview.src = await getMediaSignedUrl(url2) || "";
|
|
60471
60553
|
} catch (err) {
|
|
60472
60554
|
console.error(err);
|
|
60473
60555
|
this.onError();
|
|
@@ -60827,9 +60909,9 @@ var getBlobFromDataURL = (dataURL) => {
|
|
|
60827
60909
|
};
|
|
60828
60910
|
}
|
|
60829
60911
|
});
|
|
60830
|
-
}, prepareImage = (inp,
|
|
60912
|
+
}, prepareImage = (inp, boardId, baseUrl) => resizeAndConvertToPng(inp).then(({ width: width2, height: height2, dataURL, hash: hash2 }) => {
|
|
60831
60913
|
const { blob, mimeType } = getBlobFromDataURL(dataURL);
|
|
60832
|
-
return uploadMediaToStorage(blob,
|
|
60914
|
+
return uploadMediaToStorage(blob, boardId, "image", baseUrl).then((src) => {
|
|
60833
60915
|
return {
|
|
60834
60916
|
imageDimension: { width: width2, height: height2 },
|
|
60835
60917
|
base64: dataURL,
|
|
@@ -60870,15 +60952,15 @@ var getVideoMetadata = (file2) => {
|
|
|
60870
60952
|
board.selection.add(boardVideo);
|
|
60871
60953
|
onLoadCb(boardVideo);
|
|
60872
60954
|
});
|
|
60873
|
-
}, prepareVideo = (file2,
|
|
60955
|
+
}, prepareVideo = (file2, boardId, baseUrl) => {
|
|
60874
60956
|
return new Promise((resolve2, reject) => {
|
|
60875
60957
|
const video = document.createElement("video");
|
|
60876
60958
|
video.src = URL.createObjectURL(file2);
|
|
60877
60959
|
video.onloadedmetadata = () => {
|
|
60878
60960
|
video.onseeked = () => {
|
|
60879
60961
|
video.onseeked = null;
|
|
60880
|
-
prepareImage(captureFrame(0.1, video)?.src,
|
|
60881
|
-
uploadMediaToStorage(file2,
|
|
60962
|
+
prepareImage(captureFrame(0.1, video)?.src, boardId, baseUrl).then((imageData) => {
|
|
60963
|
+
uploadMediaToStorage(file2, boardId, "video", baseUrl).then((url2) => {
|
|
60882
60964
|
resolve2({
|
|
60883
60965
|
url: url2,
|
|
60884
60966
|
previewUrl: imageData.storageLink
|
|
@@ -66866,8 +66948,8 @@ var init_Card = __esm(() => {
|
|
|
66866
66948
|
async createImages() {
|
|
66867
66949
|
this.face = conf.documentFactory.createElement("img");
|
|
66868
66950
|
this.backside = conf.documentFactory.createElement("img");
|
|
66869
|
-
this.face.src = await getMediaSignedUrl(this.faceUrl
|
|
66870
|
-
this.backside.src = await getMediaSignedUrl(this.backsideUrl
|
|
66951
|
+
this.face.src = await getMediaSignedUrl(this.faceUrl) || "";
|
|
66952
|
+
this.backside.src = await getMediaSignedUrl(this.backsideUrl) || "";
|
|
66871
66953
|
this.face.onload = () => {
|
|
66872
66954
|
this.subject.publish(this);
|
|
66873
66955
|
};
|
|
@@ -67568,7 +67650,7 @@ var init_Dice = __esm(() => {
|
|
|
67568
67650
|
this.renderValues[index2] = value;
|
|
67569
67651
|
} else {
|
|
67570
67652
|
const image2 = conf.documentFactory.createElement("img");
|
|
67571
|
-
image2.src = await getMediaSignedUrl(value
|
|
67653
|
+
image2.src = await getMediaSignedUrl(value) || "";
|
|
67572
67654
|
this.renderValues[index2] = image2;
|
|
67573
67655
|
image2.onload = () => {
|
|
67574
67656
|
this.subject.publish(this);
|
|
@@ -68023,7 +68105,7 @@ var init_Screen = __esm(() => {
|
|
|
68023
68105
|
this.backgroundUrl = url2 || "";
|
|
68024
68106
|
if (url2) {
|
|
68025
68107
|
this.backgroundImage = conf.documentFactory.createElement("img");
|
|
68026
|
-
this.backgroundImage.src = await getMediaSignedUrl(url2
|
|
68108
|
+
this.backgroundImage.src = await getMediaSignedUrl(url2) || "";
|
|
68027
68109
|
this.applyBackgroundColor("none");
|
|
68028
68110
|
this.backgroundImage.onload = () => {
|
|
68029
68111
|
this.subject.publish(this);
|
|
@@ -69885,7 +69967,7 @@ var init_Image = __esm(() => {
|
|
|
69885
69967
|
}
|
|
69886
69968
|
async setStorageLink(link2) {
|
|
69887
69969
|
this.storageLink = link2;
|
|
69888
|
-
this.signedUrl = await getMediaSignedUrl(link2
|
|
69970
|
+
this.signedUrl = await getMediaSignedUrl(link2) || "";
|
|
69889
69971
|
if (!this.signedUrl) {
|
|
69890
69972
|
const canvas = conf.documentFactory.createElement("canvas");
|
|
69891
69973
|
canvas.width = 100;
|
|
@@ -70306,7 +70388,7 @@ function handleAudioGenerate(response, board) {
|
|
|
70306
70388
|
}
|
|
70307
70389
|
function handleImageGenerate(response, board) {
|
|
70308
70390
|
if (response.status === "completed" && response.base64) {
|
|
70309
|
-
prepareImage(response.base64,
|
|
70391
|
+
prepareImage(response.base64, board.getBoardId()).then((imageData) => {
|
|
70310
70392
|
const placeholderId = board.aiImagePlaceholder?.getId();
|
|
70311
70393
|
if (placeholderId) {
|
|
70312
70394
|
const placeholderNode = board.items.getById(placeholderId);
|
package/dist/cjs/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",
|
|
@@ -14432,6 +14434,11 @@ class Events {
|
|
|
14432
14434
|
getOpKey(op) {
|
|
14433
14435
|
return op.method;
|
|
14434
14436
|
}
|
|
14437
|
+
refreshIdentity() {
|
|
14438
|
+
const sessionId = this.getSessionId();
|
|
14439
|
+
const authorUserId = this.getAuthorUserId();
|
|
14440
|
+
this.log.refreshUnconfirmedIdentity(sessionId, authorUserId);
|
|
14441
|
+
}
|
|
14435
14442
|
getSessionId() {
|
|
14436
14443
|
return getConnectionSessionId(this.connection);
|
|
14437
14444
|
}
|
|
@@ -31871,7 +31878,32 @@ var init_setLink = __esm(() => {
|
|
|
31871
31878
|
|
|
31872
31879
|
// src/Items/RichText/editorHelpers/common/getSelectionMarks.ts
|
|
31873
31880
|
function getSelectionMarks(editor) {
|
|
31874
|
-
|
|
31881
|
+
const marks = import_slate42.Editor.marks(editor);
|
|
31882
|
+
if (!editor.selection) {
|
|
31883
|
+
return marks;
|
|
31884
|
+
}
|
|
31885
|
+
if (!import_slate42.Range.isExpanded(editor.selection) || marks && Object.keys(marks).length > 0) {
|
|
31886
|
+
return marks;
|
|
31887
|
+
}
|
|
31888
|
+
const textEntries = Array.from(import_slate42.Editor.nodes(editor, {
|
|
31889
|
+
at: editor.selection,
|
|
31890
|
+
match: (node) => import_slate42.Text.isText(node)
|
|
31891
|
+
}));
|
|
31892
|
+
const [firstEntry, ...restEntries] = textEntries;
|
|
31893
|
+
if (!firstEntry) {
|
|
31894
|
+
return marks;
|
|
31895
|
+
}
|
|
31896
|
+
const { text: _firstText, ...firstMarks } = firstEntry[0];
|
|
31897
|
+
const commonMarks = { ...firstMarks };
|
|
31898
|
+
for (const [node] of restEntries) {
|
|
31899
|
+
const { text: _text, ...nodeMarks } = node;
|
|
31900
|
+
for (const key of Object.keys(commonMarks)) {
|
|
31901
|
+
if (commonMarks[key] !== nodeMarks[key]) {
|
|
31902
|
+
delete commonMarks[key];
|
|
31903
|
+
}
|
|
31904
|
+
}
|
|
31905
|
+
}
|
|
31906
|
+
return commonMarks;
|
|
31875
31907
|
}
|
|
31876
31908
|
var import_slate42;
|
|
31877
31909
|
var init_getSelectionMarks = __esm(() => {
|
|
@@ -39494,7 +39526,14 @@ function setSelectionFontSize(editor, isAutosize, fontSize, selectionContext) {
|
|
|
39494
39526
|
shouldUpdateElement = true;
|
|
39495
39527
|
}
|
|
39496
39528
|
} else {
|
|
39497
|
-
import_slate53.
|
|
39529
|
+
if (editor.selection && import_slate53.Range.isExpanded(editor.selection)) {
|
|
39530
|
+
import_slate53.Transforms.setNodes(editor, { fontSize: size }, {
|
|
39531
|
+
match: (n) => import_slate53.Text.isText(n),
|
|
39532
|
+
split: true
|
|
39533
|
+
});
|
|
39534
|
+
} else {
|
|
39535
|
+
import_slate53.Editor.addMark(editor, "fontSize", size);
|
|
39536
|
+
}
|
|
39498
39537
|
}
|
|
39499
39538
|
}
|
|
39500
39539
|
if (selectionContext === "EditTextUnderPointer") {
|
|
@@ -39574,7 +39613,14 @@ function setSelectionFontColor(editor, format, selectionContext) {
|
|
|
39574
39613
|
return;
|
|
39575
39614
|
}
|
|
39576
39615
|
if (marks.fontColor !== format) {
|
|
39577
|
-
import_slate55.
|
|
39616
|
+
if (editor.selection && import_slate55.Range.isExpanded(editor.selection)) {
|
|
39617
|
+
import_slate55.Transforms.setNodes(editor, { fontColor: format }, {
|
|
39618
|
+
match: (n) => import_slate55.Text.isText(n),
|
|
39619
|
+
split: true
|
|
39620
|
+
});
|
|
39621
|
+
} else {
|
|
39622
|
+
import_slate55.Editor.addMark(editor, "fontColor", format);
|
|
39623
|
+
}
|
|
39578
39624
|
}
|
|
39579
39625
|
if (selectionContext === "EditTextUnderPointer") {
|
|
39580
39626
|
try {
|
|
@@ -40125,7 +40171,14 @@ function applySelectionFontColor(editor, fontColor) {
|
|
|
40125
40171
|
if (!marks) {
|
|
40126
40172
|
return;
|
|
40127
40173
|
}
|
|
40128
|
-
import_slate57.
|
|
40174
|
+
if (editor.selection && import_slate57.Range.isExpanded(editor.selection)) {
|
|
40175
|
+
import_slate57.Transforms.setNodes(editor, { fontColor }, {
|
|
40176
|
+
match: (n) => import_slate57.Text.isText(n),
|
|
40177
|
+
split: true
|
|
40178
|
+
});
|
|
40179
|
+
} else {
|
|
40180
|
+
import_slate57.Editor.addMark(editor, "fontColor", fontColor);
|
|
40181
|
+
}
|
|
40129
40182
|
}
|
|
40130
40183
|
var import_slate57;
|
|
40131
40184
|
var init_applySelectionFontColor = __esm(() => {
|
|
@@ -40153,7 +40206,14 @@ function applySelectionFontSize(editor, fontSize, selectionContext) {
|
|
|
40153
40206
|
focus: import_slate58.Editor.end(editor, [])
|
|
40154
40207
|
});
|
|
40155
40208
|
}
|
|
40156
|
-
import_slate58.
|
|
40209
|
+
if (editor.selection && import_slate58.Range.isExpanded(editor.selection)) {
|
|
40210
|
+
import_slate58.Transforms.setNodes(editor, { fontSize: size }, {
|
|
40211
|
+
match: (n) => import_slate58.Text.isText(n),
|
|
40212
|
+
split: true
|
|
40213
|
+
});
|
|
40214
|
+
} else {
|
|
40215
|
+
import_slate58.Editor.addMark(editor, "fontSize", size);
|
|
40216
|
+
}
|
|
40157
40217
|
if (selectionContext === "EditTextUnderPointer") {}
|
|
40158
40218
|
}
|
|
40159
40219
|
var import_slate58;
|
|
@@ -41821,6 +41881,35 @@ var init_Audio = __esm(() => {
|
|
|
41821
41881
|
};
|
|
41822
41882
|
});
|
|
41823
41883
|
|
|
41884
|
+
// src/api/AuthRequest.ts
|
|
41885
|
+
async function authenticatedFetch(url2, init2 = {}, boardId) {
|
|
41886
|
+
const getAuthInit = (originalInit) => {
|
|
41887
|
+
const token = conf.getAccessToken();
|
|
41888
|
+
if (!token) {
|
|
41889
|
+
return originalInit;
|
|
41890
|
+
}
|
|
41891
|
+
const headers = new Headers(originalInit.headers);
|
|
41892
|
+
headers.set("Authorization", `Bearer ${token}`);
|
|
41893
|
+
return { ...originalInit, headers };
|
|
41894
|
+
};
|
|
41895
|
+
let response = await fetch(url2, getAuthInit(init2));
|
|
41896
|
+
if (response.status === 401) {
|
|
41897
|
+
const body = await response.clone().json().catch(() => ({}));
|
|
41898
|
+
if (body.code === "AUTH_INVALID_ACCESS_TOKEN") {
|
|
41899
|
+
const refreshed = await conf.onAuthInvalid(boardId);
|
|
41900
|
+
if (refreshed) {
|
|
41901
|
+
response = await fetch(url2, getAuthInit(init2));
|
|
41902
|
+
} else {
|
|
41903
|
+
conf.onAuthTerminalFailure(boardId, body.code);
|
|
41904
|
+
}
|
|
41905
|
+
}
|
|
41906
|
+
}
|
|
41907
|
+
return response;
|
|
41908
|
+
}
|
|
41909
|
+
var init_AuthRequest = __esm(() => {
|
|
41910
|
+
init_Settings();
|
|
41911
|
+
});
|
|
41912
|
+
|
|
41824
41913
|
// src/api/MediaHelpers.ts
|
|
41825
41914
|
function getAccessTypeFromUrl(url2) {
|
|
41826
41915
|
try {
|
|
@@ -41838,15 +41927,14 @@ function getAccessTypeFromUrl(url2) {
|
|
|
41838
41927
|
}
|
|
41839
41928
|
return null;
|
|
41840
41929
|
}
|
|
41841
|
-
var uploadSvgDirectly = async (blob,
|
|
41842
|
-
const response = await
|
|
41930
|
+
var uploadSvgDirectly = async (blob, boardId, baseUrl) => {
|
|
41931
|
+
const response = await authenticatedFetch(`${baseUrl || ""}/svg/${boardId}`, {
|
|
41843
41932
|
method: "POST",
|
|
41844
41933
|
headers: {
|
|
41845
|
-
"Content-Type": "image/svg+xml"
|
|
41846
|
-
Authorization: `Bearer ${accessToken}`
|
|
41934
|
+
"Content-Type": "image/svg+xml"
|
|
41847
41935
|
},
|
|
41848
41936
|
body: blob
|
|
41849
|
-
});
|
|
41937
|
+
}, boardId);
|
|
41850
41938
|
if (!response.ok) {
|
|
41851
41939
|
conf.hooks.onUploadMediaError(response, "image");
|
|
41852
41940
|
throw new Error(`Failed to upload SVG. Status: ${response.status}`);
|
|
@@ -41856,19 +41944,18 @@ var uploadSvgDirectly = async (blob, accessToken, boardId, baseUrl) => {
|
|
|
41856
41944
|
throw new Error("Server did not provide a key for the uploaded SVG.");
|
|
41857
41945
|
}
|
|
41858
41946
|
return data.url;
|
|
41859
|
-
}, uploadWithPresignedUrl = async (blob,
|
|
41860
|
-
const generateUrlResponse = await
|
|
41947
|
+
}, uploadWithPresignedUrl = async (blob, boardId, type, baseUrl) => {
|
|
41948
|
+
const generateUrlResponse = await authenticatedFetch(`${baseUrl || ""}/media/upload`, {
|
|
41861
41949
|
method: "POST",
|
|
41862
41950
|
headers: {
|
|
41863
|
-
"Content-Type": "application/json"
|
|
41864
|
-
Authorization: `Bearer ${accessToken}`
|
|
41951
|
+
"Content-Type": "application/json"
|
|
41865
41952
|
},
|
|
41866
41953
|
body: JSON.stringify({
|
|
41867
41954
|
fileSize: blob.size,
|
|
41868
41955
|
fileType: blob.type,
|
|
41869
41956
|
boardId
|
|
41870
41957
|
})
|
|
41871
|
-
});
|
|
41958
|
+
}, boardId);
|
|
41872
41959
|
if (!generateUrlResponse.ok) {
|
|
41873
41960
|
conf.hooks.onUploadMediaError(generateUrlResponse, type);
|
|
41874
41961
|
throw new Error(`Failed to get presigned URL. Status: ${generateUrlResponse.status}`);
|
|
@@ -41890,18 +41977,18 @@ var uploadSvgDirectly = async (blob, accessToken, boardId, baseUrl) => {
|
|
|
41890
41977
|
throw new Error(`Direct upload to storage failed. Status: ${uploadResponse.status}`);
|
|
41891
41978
|
}
|
|
41892
41979
|
return url2;
|
|
41893
|
-
}, uploadMediaToStorage = async (blob,
|
|
41980
|
+
}, uploadMediaToStorage = async (blob, boardId, type, baseUrl) => {
|
|
41894
41981
|
try {
|
|
41895
41982
|
if (blob.type === "image/svg+xml") {
|
|
41896
|
-
return await uploadSvgDirectly(blob,
|
|
41983
|
+
return await uploadSvgDirectly(blob, boardId, baseUrl);
|
|
41897
41984
|
} else {
|
|
41898
|
-
return await uploadWithPresignedUrl(blob,
|
|
41985
|
+
return await uploadWithPresignedUrl(blob, boardId, type, baseUrl);
|
|
41899
41986
|
}
|
|
41900
41987
|
} catch (error48) {
|
|
41901
41988
|
console.error("Media upload process error:", error48);
|
|
41902
41989
|
throw error48;
|
|
41903
41990
|
}
|
|
41904
|
-
}, getMediaSignedUrl = async (url2
|
|
41991
|
+
}, getMediaSignedUrl = async (url2) => {
|
|
41905
41992
|
const accessType = getAccessTypeFromUrl(url2);
|
|
41906
41993
|
if (!accessType) {
|
|
41907
41994
|
return null;
|
|
@@ -41909,15 +41996,9 @@ var uploadSvgDirectly = async (blob, accessToken, boardId, baseUrl) => {
|
|
|
41909
41996
|
if (accessType === "anonymous") {
|
|
41910
41997
|
return url2;
|
|
41911
41998
|
}
|
|
41912
|
-
if (!accessToken) {
|
|
41913
|
-
return null;
|
|
41914
|
-
}
|
|
41915
41999
|
try {
|
|
41916
|
-
const response = await
|
|
41917
|
-
method: "GET"
|
|
41918
|
-
headers: {
|
|
41919
|
-
Authorization: `Bearer ${accessToken}`
|
|
41920
|
-
}
|
|
42000
|
+
const response = await authenticatedFetch(url2, {
|
|
42001
|
+
method: "GET"
|
|
41921
42002
|
});
|
|
41922
42003
|
if (!response.ok) {
|
|
41923
42004
|
console.error("Failed to get media signed url:", response.status, response.statusText);
|
|
@@ -41932,15 +42013,16 @@ var uploadSvgDirectly = async (blob, accessToken, boardId, baseUrl) => {
|
|
|
41932
42013
|
};
|
|
41933
42014
|
var init_MediaHelpers = __esm(() => {
|
|
41934
42015
|
init_Settings();
|
|
42016
|
+
init_AuthRequest();
|
|
41935
42017
|
});
|
|
41936
42018
|
|
|
41937
42019
|
// src/Items/Audio/AudioHelpers.ts
|
|
41938
|
-
var prepareAudio = (file2,
|
|
42020
|
+
var prepareAudio = (file2, boardId, baseUrl) => {
|
|
41939
42021
|
return new Promise((resolve, reject) => {
|
|
41940
42022
|
const audio = document.createElement("audio");
|
|
41941
42023
|
audio.src = URL.createObjectURL(file2);
|
|
41942
42024
|
audio.onloadedmetadata = () => {
|
|
41943
|
-
uploadMediaToStorage(file2,
|
|
42025
|
+
uploadMediaToStorage(file2, boardId, "audio", baseUrl).then((url2) => {
|
|
41944
42026
|
resolve(url2);
|
|
41945
42027
|
}).catch(reject);
|
|
41946
42028
|
};
|
|
@@ -60467,7 +60549,7 @@ var init_Video = __esm(() => {
|
|
|
60467
60549
|
async setPreviewUrl(url2) {
|
|
60468
60550
|
if (this.isStorageUrl) {
|
|
60469
60551
|
try {
|
|
60470
|
-
this.preview.src = await getMediaSignedUrl(url2
|
|
60552
|
+
this.preview.src = await getMediaSignedUrl(url2) || "";
|
|
60471
60553
|
} catch (err) {
|
|
60472
60554
|
console.error(err);
|
|
60473
60555
|
this.onError();
|
|
@@ -60827,9 +60909,9 @@ var getBlobFromDataURL = (dataURL) => {
|
|
|
60827
60909
|
};
|
|
60828
60910
|
}
|
|
60829
60911
|
});
|
|
60830
|
-
}, prepareImage = (inp,
|
|
60912
|
+
}, prepareImage = (inp, boardId, baseUrl) => resizeAndConvertToPng(inp).then(({ width: width2, height: height2, dataURL, hash: hash2 }) => {
|
|
60831
60913
|
const { blob, mimeType } = getBlobFromDataURL(dataURL);
|
|
60832
|
-
return uploadMediaToStorage(blob,
|
|
60914
|
+
return uploadMediaToStorage(blob, boardId, "image", baseUrl).then((src) => {
|
|
60833
60915
|
return {
|
|
60834
60916
|
imageDimension: { width: width2, height: height2 },
|
|
60835
60917
|
base64: dataURL,
|
|
@@ -60870,15 +60952,15 @@ var getVideoMetadata = (file2) => {
|
|
|
60870
60952
|
board.selection.add(boardVideo);
|
|
60871
60953
|
onLoadCb(boardVideo);
|
|
60872
60954
|
});
|
|
60873
|
-
}, prepareVideo = (file2,
|
|
60955
|
+
}, prepareVideo = (file2, boardId, baseUrl) => {
|
|
60874
60956
|
return new Promise((resolve2, reject) => {
|
|
60875
60957
|
const video = document.createElement("video");
|
|
60876
60958
|
video.src = URL.createObjectURL(file2);
|
|
60877
60959
|
video.onloadedmetadata = () => {
|
|
60878
60960
|
video.onseeked = () => {
|
|
60879
60961
|
video.onseeked = null;
|
|
60880
|
-
prepareImage(captureFrame(0.1, video)?.src,
|
|
60881
|
-
uploadMediaToStorage(file2,
|
|
60962
|
+
prepareImage(captureFrame(0.1, video)?.src, boardId, baseUrl).then((imageData) => {
|
|
60963
|
+
uploadMediaToStorage(file2, boardId, "video", baseUrl).then((url2) => {
|
|
60882
60964
|
resolve2({
|
|
60883
60965
|
url: url2,
|
|
60884
60966
|
previewUrl: imageData.storageLink
|
|
@@ -66866,8 +66948,8 @@ var init_Card = __esm(() => {
|
|
|
66866
66948
|
async createImages() {
|
|
66867
66949
|
this.face = conf.documentFactory.createElement("img");
|
|
66868
66950
|
this.backside = conf.documentFactory.createElement("img");
|
|
66869
|
-
this.face.src = await getMediaSignedUrl(this.faceUrl
|
|
66870
|
-
this.backside.src = await getMediaSignedUrl(this.backsideUrl
|
|
66951
|
+
this.face.src = await getMediaSignedUrl(this.faceUrl) || "";
|
|
66952
|
+
this.backside.src = await getMediaSignedUrl(this.backsideUrl) || "";
|
|
66871
66953
|
this.face.onload = () => {
|
|
66872
66954
|
this.subject.publish(this);
|
|
66873
66955
|
};
|
|
@@ -67568,7 +67650,7 @@ var init_Dice = __esm(() => {
|
|
|
67568
67650
|
this.renderValues[index2] = value;
|
|
67569
67651
|
} else {
|
|
67570
67652
|
const image2 = conf.documentFactory.createElement("img");
|
|
67571
|
-
image2.src = await getMediaSignedUrl(value
|
|
67653
|
+
image2.src = await getMediaSignedUrl(value) || "";
|
|
67572
67654
|
this.renderValues[index2] = image2;
|
|
67573
67655
|
image2.onload = () => {
|
|
67574
67656
|
this.subject.publish(this);
|
|
@@ -68023,7 +68105,7 @@ var init_Screen = __esm(() => {
|
|
|
68023
68105
|
this.backgroundUrl = url2 || "";
|
|
68024
68106
|
if (url2) {
|
|
68025
68107
|
this.backgroundImage = conf.documentFactory.createElement("img");
|
|
68026
|
-
this.backgroundImage.src = await getMediaSignedUrl(url2
|
|
68108
|
+
this.backgroundImage.src = await getMediaSignedUrl(url2) || "";
|
|
68027
68109
|
this.applyBackgroundColor("none");
|
|
68028
68110
|
this.backgroundImage.onload = () => {
|
|
68029
68111
|
this.subject.publish(this);
|
|
@@ -69885,7 +69967,7 @@ var init_Image = __esm(() => {
|
|
|
69885
69967
|
}
|
|
69886
69968
|
async setStorageLink(link2) {
|
|
69887
69969
|
this.storageLink = link2;
|
|
69888
|
-
this.signedUrl = await getMediaSignedUrl(link2
|
|
69970
|
+
this.signedUrl = await getMediaSignedUrl(link2) || "";
|
|
69889
69971
|
if (!this.signedUrl) {
|
|
69890
69972
|
const canvas = conf.documentFactory.createElement("canvas");
|
|
69891
69973
|
canvas.width = 100;
|
|
@@ -70306,7 +70388,7 @@ function handleAudioGenerate(response, board) {
|
|
|
70306
70388
|
}
|
|
70307
70389
|
function handleImageGenerate(response, board) {
|
|
70308
70390
|
if (response.status === "completed" && response.base64) {
|
|
70309
|
-
prepareImage(response.base64,
|
|
70391
|
+
prepareImage(response.base64, board.getBoardId()).then((imageData) => {
|
|
70310
70392
|
const placeholderId = board.aiImagePlaceholder?.getId();
|
|
70311
70393
|
if (placeholderId) {
|
|
70312
70394
|
const placeholderNode = board.items.getById(placeholderId);
|