@blockslides/core 0.3.3 → 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 +79 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +77 -29
- 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;
|
|
@@ -4588,7 +4620,6 @@ function createStyleTag(style2, nonce, suffix) {
|
|
|
4588
4620
|
// src/SlideEditor.ts
|
|
4589
4621
|
var SlideEditor = class extends EventEmitter {
|
|
4590
4622
|
constructor(options = {}) {
|
|
4591
|
-
console.log("[Core SlideEditor] Constructor called with options:", options);
|
|
4592
4623
|
super();
|
|
4593
4624
|
this.css = null;
|
|
4594
4625
|
this.editorView = null;
|
|
@@ -4638,15 +4669,10 @@ var SlideEditor = class extends EventEmitter {
|
|
|
4638
4669
|
this.isCapturingTransaction = false;
|
|
4639
4670
|
this.capturedTransaction = null;
|
|
4640
4671
|
this.setOptions(options);
|
|
4641
|
-
console.log("[Core SlideEditor] this.options.enableCoreExtensions:", this.options.enableCoreExtensions);
|
|
4642
4672
|
this.resolvedTheme = resolveTheme(this.options.theme);
|
|
4643
|
-
console.log("[Core SlideEditor] Theme resolved:", this.resolvedTheme);
|
|
4644
4673
|
this.createExtensionManager();
|
|
4645
|
-
console.log("[Core SlideEditor] Extension manager created");
|
|
4646
4674
|
this.createCommandManager();
|
|
4647
|
-
console.log("[Core SlideEditor] Command manager created");
|
|
4648
4675
|
this.createSchema();
|
|
4649
|
-
console.log("[Core SlideEditor] Schema created");
|
|
4650
4676
|
this.on("beforeCreate", this.options.onBeforeCreate);
|
|
4651
4677
|
this.emit("beforeCreate", { editor: this });
|
|
4652
4678
|
this.on("mount", this.options.onMount);
|
|
@@ -4665,29 +4691,21 @@ var SlideEditor = class extends EventEmitter {
|
|
|
4665
4691
|
);
|
|
4666
4692
|
this.on("paste", ({ event, slice }) => this.options.onPaste(event, slice));
|
|
4667
4693
|
this.on("delete", this.options.onDelete);
|
|
4668
|
-
console.log("[Core SlideEditor] Event handlers registered");
|
|
4669
4694
|
const initialDoc = this.createDoc();
|
|
4670
|
-
console.log("[Core SlideEditor] Initial doc created:", initialDoc);
|
|
4671
4695
|
const selection = resolveFocusPosition(initialDoc, this.options.autofocus);
|
|
4672
4696
|
this.editorState = EditorState.create({
|
|
4673
4697
|
doc: initialDoc,
|
|
4674
4698
|
schema: this.schema,
|
|
4675
4699
|
selection: selection || void 0
|
|
4676
4700
|
});
|
|
4677
|
-
console.log("[Core SlideEditor] Editor state created:", this.editorState);
|
|
4678
4701
|
if (this.options.element) {
|
|
4679
|
-
console.log("[Core SlideEditor] Element provided, calling mount");
|
|
4680
4702
|
this.mount(this.options.element);
|
|
4681
|
-
} else {
|
|
4682
|
-
console.log("[Core SlideEditor] No element provided, skipping mount");
|
|
4683
4703
|
}
|
|
4684
|
-
console.log("[Core SlideEditor] \u2705 Constructor complete");
|
|
4685
4704
|
}
|
|
4686
4705
|
/**
|
|
4687
4706
|
* Attach the editor to the DOM, creating a new editor view.
|
|
4688
4707
|
*/
|
|
4689
4708
|
mount(el) {
|
|
4690
|
-
console.log("[Core SlideEditor] mount() called with element:", el);
|
|
4691
4709
|
if (typeof document === "undefined") {
|
|
4692
4710
|
throw new Error(
|
|
4693
4711
|
`[blockslides error]: The editor cannot be mounted because there is no 'document' defined in this environment.`
|
|
@@ -4699,15 +4717,9 @@ var SlideEditor = class extends EventEmitter {
|
|
|
4699
4717
|
document.head.appendChild(this.css);
|
|
4700
4718
|
}
|
|
4701
4719
|
window.setTimeout(() => {
|
|
4702
|
-
var _a;
|
|
4703
4720
|
if (this.isDestroyed) {
|
|
4704
4721
|
return;
|
|
4705
4722
|
}
|
|
4706
|
-
console.log("[mount setTimeout] this:", this);
|
|
4707
|
-
console.log("[mount setTimeout] this.commandManager:", this.commandManager);
|
|
4708
|
-
console.log("[mount setTimeout] this.commands:", this.commands);
|
|
4709
|
-
console.log("[mount setTimeout] typeof this.commands:", typeof this.commands);
|
|
4710
|
-
console.log("[mount setTimeout] this.commands.focus:", (_a = this.commands) == null ? void 0 : _a.focus);
|
|
4711
4723
|
this.commands.focus(this.options.autofocus);
|
|
4712
4724
|
this.emit("create", { editor: this });
|
|
4713
4725
|
this.isInitialized = true;
|
|
@@ -4907,7 +4919,6 @@ var SlideEditor = class extends EventEmitter {
|
|
|
4907
4919
|
*/
|
|
4908
4920
|
createExtensionManager() {
|
|
4909
4921
|
var _a, _b;
|
|
4910
|
-
console.log("[Core SlideEditor] createExtensionManager - enableCoreExtensions:", this.options.enableCoreExtensions);
|
|
4911
4922
|
const coreExtensions = this.options.enableCoreExtensions ? [
|
|
4912
4923
|
Editable,
|
|
4913
4924
|
ClipboardTextSerializer.configure({
|
|
@@ -4926,8 +4937,6 @@ var SlideEditor = class extends EventEmitter {
|
|
|
4926
4937
|
}
|
|
4927
4938
|
return true;
|
|
4928
4939
|
}) : [];
|
|
4929
|
-
console.log("[Core SlideEditor] coreExtensions:", coreExtensions.map((e) => e.name));
|
|
4930
|
-
console.log("[Core SlideEditor] this.options.extensions:", this.options.extensions.map((e) => e.name));
|
|
4931
4940
|
const allExtensions = [
|
|
4932
4941
|
...coreExtensions,
|
|
4933
4942
|
...this.options.extensions
|
|
@@ -5000,8 +5009,6 @@ var SlideEditor = class extends EventEmitter {
|
|
|
5000
5009
|
*/
|
|
5001
5010
|
createView(element) {
|
|
5002
5011
|
var _a;
|
|
5003
|
-
console.log("[Core SlideEditor] createView() called with element:", element);
|
|
5004
|
-
console.log("[Core SlideEditor] editorState:", this.editorState);
|
|
5005
5012
|
this.editorView = new EditorView(element, {
|
|
5006
5013
|
...this.options.editorProps,
|
|
5007
5014
|
attributes: {
|
|
@@ -5014,14 +5021,10 @@ var SlideEditor = class extends EventEmitter {
|
|
|
5014
5021
|
markViews: this.extensionManager.markViews,
|
|
5015
5022
|
nodeViews: this.extensionManager.nodeViews
|
|
5016
5023
|
});
|
|
5017
|
-
console.log("[Core SlideEditor] EditorView created:", this.editorView);
|
|
5018
|
-
console.log("[Core SlideEditor] EditorView.dom:", this.editorView.dom);
|
|
5019
5024
|
const newState = this.state.reconfigure({
|
|
5020
5025
|
plugins: this.extensionManager.plugins
|
|
5021
5026
|
});
|
|
5022
|
-
console.log("[Core SlideEditor] Reconfigured state with plugins");
|
|
5023
5027
|
this.view.updateState(newState);
|
|
5024
|
-
console.log("[Core SlideEditor] \u2705 View state updated");
|
|
5025
5028
|
this.prependClass();
|
|
5026
5029
|
this.injectCSS();
|
|
5027
5030
|
applyTheme(this.resolvedTheme, this.view.dom);
|
|
@@ -5964,6 +5967,49 @@ function renderNestedMarkdownContent(node, h2, prefixOrGenerator, ctx) {
|
|
|
5964
5967
|
return output.join("\n");
|
|
5965
5968
|
}
|
|
5966
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
|
+
|
|
5967
6013
|
// src/MarkView.ts
|
|
5968
6014
|
function updateMarkViewAttributes(checkMark, editor, attrs = {}) {
|
|
5969
6015
|
const { state } = editor;
|
|
@@ -6444,6 +6490,7 @@ export {
|
|
|
6444
6490
|
getAttributesFromExtensions,
|
|
6445
6491
|
getChangedRanges,
|
|
6446
6492
|
getDebugJSON,
|
|
6493
|
+
getEditorAssets,
|
|
6447
6494
|
getExtensionField,
|
|
6448
6495
|
getHTMLFromFragment,
|
|
6449
6496
|
getMarkAttributes,
|
|
@@ -6502,6 +6549,7 @@ export {
|
|
|
6502
6549
|
parseLayout,
|
|
6503
6550
|
pasteRulesPlugin,
|
|
6504
6551
|
posToDOMRect,
|
|
6552
|
+
refreshAssets,
|
|
6505
6553
|
registerTheme,
|
|
6506
6554
|
removeDuplicates,
|
|
6507
6555
|
renderNestedMarkdownContent,
|