@blockslides/core 0.3.2 → 0.4.0
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/index.d.mts +104 -2
- package/dist/index.d.ts +104 -2
- package/dist/index.js +80 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +78 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -203,6 +203,7 @@ __export(commands_exports, {
|
|
|
203
203
|
undoInputRule: () => undoInputRule,
|
|
204
204
|
unsetAllMarks: () => unsetAllMarks,
|
|
205
205
|
unsetMark: () => unsetMark,
|
|
206
|
+
updateAssetUrls: () => updateAssetUrls,
|
|
206
207
|
updateAttributes: () => updateAttributes,
|
|
207
208
|
wrapIn: () => wrapIn,
|
|
208
209
|
wrapInList: () => wrapInList
|
|
@@ -2693,6 +2694,37 @@ var unsetMark = (typeOrName, options = {}) => ({ tr, state, dispatch }) => {
|
|
|
2693
2694
|
return true;
|
|
2694
2695
|
};
|
|
2695
2696
|
|
|
2697
|
+
// src/commands/updateAssetUrls.ts
|
|
2698
|
+
var updateAssetUrls = (urlMap) => ({ tr, state, dispatch }) => {
|
|
2699
|
+
if (dispatch) {
|
|
2700
|
+
state.doc.descendants((node, pos) => {
|
|
2701
|
+
if (node.type.name === "imageBlock" && node.attrs.src) {
|
|
2702
|
+
const key = node.attrs.assetId && urlMap[node.attrs.assetId] ? node.attrs.assetId : node.attrs.src;
|
|
2703
|
+
const newUrl = urlMap[key];
|
|
2704
|
+
if (newUrl) {
|
|
2705
|
+
tr.setNodeMarkup(pos, void 0, { ...node.attrs, src: newUrl });
|
|
2706
|
+
}
|
|
2707
|
+
}
|
|
2708
|
+
if ((node.type.name === "slide" || node.type.name === "columnGroup") && node.attrs.backgroundImage) {
|
|
2709
|
+
const newUrl = urlMap[node.attrs.backgroundImage];
|
|
2710
|
+
if (newUrl) {
|
|
2711
|
+
tr.setNodeMarkup(pos, void 0, {
|
|
2712
|
+
...node.attrs,
|
|
2713
|
+
backgroundImage: newUrl
|
|
2714
|
+
});
|
|
2715
|
+
}
|
|
2716
|
+
}
|
|
2717
|
+
if (node.type.name === "video" && node.attrs.src) {
|
|
2718
|
+
const newUrl = urlMap[node.attrs.src];
|
|
2719
|
+
if (newUrl) {
|
|
2720
|
+
tr.setNodeMarkup(pos, void 0, { ...node.attrs, src: newUrl });
|
|
2721
|
+
}
|
|
2722
|
+
}
|
|
2723
|
+
});
|
|
2724
|
+
}
|
|
2725
|
+
return true;
|
|
2726
|
+
};
|
|
2727
|
+
|
|
2696
2728
|
// src/commands/updateAttributes.ts
|
|
2697
2729
|
var updateAttributes = (typeOrName, attributes = {}) => ({ tr, state, dispatch }) => {
|
|
2698
2730
|
let nodeType = null;
|
|
@@ -2812,6 +2844,7 @@ var EventEmitter = class {
|
|
|
2812
2844
|
this.callbacks = {};
|
|
2813
2845
|
}
|
|
2814
2846
|
on(event, fn) {
|
|
2847
|
+
if (!fn) return this;
|
|
2815
2848
|
if (!this.callbacks[event]) {
|
|
2816
2849
|
this.callbacks[event] = [];
|
|
2817
2850
|
}
|
|
@@ -5934,6 +5967,49 @@ function renderNestedMarkdownContent(node, h2, prefixOrGenerator, ctx) {
|
|
|
5934
5967
|
return output.join("\n");
|
|
5935
5968
|
}
|
|
5936
5969
|
|
|
5970
|
+
// src/utilities/assetRefresh.ts
|
|
5971
|
+
function getEditorAssets(editor) {
|
|
5972
|
+
const assets = [];
|
|
5973
|
+
editor.state.doc.descendants((node) => {
|
|
5974
|
+
var _a;
|
|
5975
|
+
if (node.type.name === "imageBlock" && node.attrs.src) {
|
|
5976
|
+
assets.push({
|
|
5977
|
+
assetId: (_a = node.attrs.assetId) != null ? _a : null,
|
|
5978
|
+
currentUrl: node.attrs.src,
|
|
5979
|
+
nodeType: "imageBlock"
|
|
5980
|
+
});
|
|
5981
|
+
}
|
|
5982
|
+
if (node.type.name === "slide" && node.attrs.backgroundImage) {
|
|
5983
|
+
assets.push({
|
|
5984
|
+
assetId: null,
|
|
5985
|
+
currentUrl: node.attrs.backgroundImage,
|
|
5986
|
+
nodeType: "slide"
|
|
5987
|
+
});
|
|
5988
|
+
}
|
|
5989
|
+
if (node.type.name === "columnGroup" && node.attrs.backgroundImage) {
|
|
5990
|
+
assets.push({
|
|
5991
|
+
assetId: null,
|
|
5992
|
+
currentUrl: node.attrs.backgroundImage,
|
|
5993
|
+
nodeType: "columnGroup"
|
|
5994
|
+
});
|
|
5995
|
+
}
|
|
5996
|
+
if (node.type.name === "video" && node.attrs.src) {
|
|
5997
|
+
assets.push({
|
|
5998
|
+
assetId: null,
|
|
5999
|
+
currentUrl: node.attrs.src,
|
|
6000
|
+
nodeType: "video"
|
|
6001
|
+
});
|
|
6002
|
+
}
|
|
6003
|
+
});
|
|
6004
|
+
return assets;
|
|
6005
|
+
}
|
|
6006
|
+
async function refreshAssets(editor, resolver) {
|
|
6007
|
+
const assets = getEditorAssets(editor);
|
|
6008
|
+
if (assets.length === 0) return;
|
|
6009
|
+
const urlMap = await resolver(assets);
|
|
6010
|
+
editor.commands.updateAssetUrls(urlMap);
|
|
6011
|
+
}
|
|
6012
|
+
|
|
5937
6013
|
// src/MarkView.ts
|
|
5938
6014
|
function updateMarkViewAttributes(checkMark, editor, attrs = {}) {
|
|
5939
6015
|
const { state } = editor;
|
|
@@ -6414,6 +6490,7 @@ export {
|
|
|
6414
6490
|
getAttributesFromExtensions,
|
|
6415
6491
|
getChangedRanges,
|
|
6416
6492
|
getDebugJSON,
|
|
6493
|
+
getEditorAssets,
|
|
6417
6494
|
getExtensionField,
|
|
6418
6495
|
getHTMLFromFragment,
|
|
6419
6496
|
getMarkAttributes,
|
|
@@ -6472,6 +6549,7 @@ export {
|
|
|
6472
6549
|
parseLayout,
|
|
6473
6550
|
pasteRulesPlugin,
|
|
6474
6551
|
posToDOMRect,
|
|
6552
|
+
refreshAssets,
|
|
6475
6553
|
registerTheme,
|
|
6476
6554
|
removeDuplicates,
|
|
6477
6555
|
renderNestedMarkdownContent,
|