@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.d.mts
CHANGED
|
@@ -3016,6 +3016,27 @@ declare module '@blockslides/core' {
|
|
|
3016
3016
|
}
|
|
3017
3017
|
declare const unsetMark: RawCommands['unsetMark'];
|
|
3018
3018
|
|
|
3019
|
+
declare module '@blockslides/core' {
|
|
3020
|
+
interface Commands<ReturnType> {
|
|
3021
|
+
updateAssetUrls: {
|
|
3022
|
+
/**
|
|
3023
|
+
* Update asset URLs across the entire document in a single transaction.
|
|
3024
|
+
* The map keys can be either an `assetId` (preferred for imageBlock nodes)
|
|
3025
|
+
* or the current URL (used as a fallback, and for nodes without an assetId
|
|
3026
|
+
* such as slide/columnGroup backgrounds and video embeds).
|
|
3027
|
+
*
|
|
3028
|
+
* @example
|
|
3029
|
+
* editor.commands.updateAssetUrls({
|
|
3030
|
+
* 'asset-123': 'https://cdn.example.com/fresh-url.jpg',
|
|
3031
|
+
* 'https://old.example.com/bg.jpg': 'https://cdn.example.com/fresh-bg.jpg',
|
|
3032
|
+
* })
|
|
3033
|
+
*/
|
|
3034
|
+
updateAssetUrls: (urlMap: Record<string, string>) => ReturnType;
|
|
3035
|
+
};
|
|
3036
|
+
}
|
|
3037
|
+
}
|
|
3038
|
+
declare const updateAssetUrls: RawCommands['updateAssetUrls'];
|
|
3039
|
+
|
|
3019
3040
|
declare module '@blockslides/core' {
|
|
3020
3041
|
interface Commands<ReturnType> {
|
|
3021
3042
|
updateAttributes: {
|
|
@@ -3127,11 +3148,12 @@ declare const index$2_toggleWrap: typeof toggleWrap;
|
|
|
3127
3148
|
declare const index$2_undoInputRule: typeof undoInputRule;
|
|
3128
3149
|
declare const index$2_unsetAllMarks: typeof unsetAllMarks;
|
|
3129
3150
|
declare const index$2_unsetMark: typeof unsetMark;
|
|
3151
|
+
declare const index$2_updateAssetUrls: typeof updateAssetUrls;
|
|
3130
3152
|
declare const index$2_updateAttributes: typeof updateAttributes;
|
|
3131
3153
|
declare const index$2_wrapIn: typeof wrapIn;
|
|
3132
3154
|
declare const index$2_wrapInList: typeof wrapInList;
|
|
3133
3155
|
declare namespace index$2 {
|
|
3134
|
-
export { type index$2_InsertContentAtOptions as InsertContentAtOptions, type index$2_InsertContentOptions as InsertContentOptions, type index$2_SetContentOptions as SetContentOptions, index$2_blur as blur, index$2_clearContent as clearContent, index$2_clearNodes as clearNodes, index$2_command as command, index$2_createParagraphNear as createParagraphNear, index$2_cut as cut, index$2_deleteCurrentNode as deleteCurrentNode, index$2_deleteNode as deleteNode, index$2_deleteRange as deleteRange, index$2_deleteSelection as deleteSelection, index$2_enter as enter, index$2_exitCode as exitCode, index$2_extendMarkRange as extendMarkRange, index$2_first as first, index$2_focus as focus, index$2_forEach as forEach, index$2_insertContent as insertContent, index$2_insertContentAt as insertContentAt, index$2_joinBackward as joinBackward, index$2_joinDown as joinDown, index$2_joinForward as joinForward, index$2_joinItemBackward as joinItemBackward, index$2_joinItemForward as joinItemForward, index$2_joinTextblockBackward as joinTextblockBackward, index$2_joinTextblockForward as joinTextblockForward, index$2_joinUp as joinUp, index$2_keyboardShortcut as keyboardShortcut, index$2_lift as lift, index$2_liftEmptyBlock as liftEmptyBlock, index$2_liftListItem as liftListItem, index$2_newlineInCode as newlineInCode, index$2_resetAttributes as resetAttributes, index$2_scrollIntoView as scrollIntoView, index$2_selectAll as selectAll, index$2_selectNodeBackward as selectNodeBackward, index$2_selectNodeForward as selectNodeForward, index$2_selectParentNode as selectParentNode, index$2_selectTextblockEnd as selectTextblockEnd, index$2_selectTextblockStart as selectTextblockStart, index$2_setContent as setContent, index$2_setMark as setMark, index$2_setMeta as setMeta, index$2_setNode as setNode, index$2_setNodeSelection as setNodeSelection, index$2_setTextSelection as setTextSelection, index$2_sinkListItem as sinkListItem, index$2_splitBlock as splitBlock, index$2_splitListItem as splitListItem, index$2_toggleList as toggleList, index$2_toggleMark as toggleMark, index$2_toggleNode as toggleNode, index$2_toggleWrap as toggleWrap, index$2_undoInputRule as undoInputRule, index$2_unsetAllMarks as unsetAllMarks, index$2_unsetMark as unsetMark, index$2_updateAttributes as updateAttributes, index$2_wrapIn as wrapIn, index$2_wrapInList as wrapInList };
|
|
3156
|
+
export { type index$2_InsertContentAtOptions as InsertContentAtOptions, type index$2_InsertContentOptions as InsertContentOptions, type index$2_SetContentOptions as SetContentOptions, index$2_blur as blur, index$2_clearContent as clearContent, index$2_clearNodes as clearNodes, index$2_command as command, index$2_createParagraphNear as createParagraphNear, index$2_cut as cut, index$2_deleteCurrentNode as deleteCurrentNode, index$2_deleteNode as deleteNode, index$2_deleteRange as deleteRange, index$2_deleteSelection as deleteSelection, index$2_enter as enter, index$2_exitCode as exitCode, index$2_extendMarkRange as extendMarkRange, index$2_first as first, index$2_focus as focus, index$2_forEach as forEach, index$2_insertContent as insertContent, index$2_insertContentAt as insertContentAt, index$2_joinBackward as joinBackward, index$2_joinDown as joinDown, index$2_joinForward as joinForward, index$2_joinItemBackward as joinItemBackward, index$2_joinItemForward as joinItemForward, index$2_joinTextblockBackward as joinTextblockBackward, index$2_joinTextblockForward as joinTextblockForward, index$2_joinUp as joinUp, index$2_keyboardShortcut as keyboardShortcut, index$2_lift as lift, index$2_liftEmptyBlock as liftEmptyBlock, index$2_liftListItem as liftListItem, index$2_newlineInCode as newlineInCode, index$2_resetAttributes as resetAttributes, index$2_scrollIntoView as scrollIntoView, index$2_selectAll as selectAll, index$2_selectNodeBackward as selectNodeBackward, index$2_selectNodeForward as selectNodeForward, index$2_selectParentNode as selectParentNode, index$2_selectTextblockEnd as selectTextblockEnd, index$2_selectTextblockStart as selectTextblockStart, index$2_setContent as setContent, index$2_setMark as setMark, index$2_setMeta as setMeta, index$2_setNode as setNode, index$2_setNodeSelection as setNodeSelection, index$2_setTextSelection as setTextSelection, index$2_sinkListItem as sinkListItem, index$2_splitBlock as splitBlock, index$2_splitListItem as splitListItem, index$2_toggleList as toggleList, index$2_toggleMark as toggleMark, index$2_toggleNode as toggleNode, index$2_toggleWrap as toggleWrap, index$2_undoInputRule as undoInputRule, index$2_unsetAllMarks as unsetAllMarks, index$2_unsetMark as unsetMark, index$2_updateAssetUrls as updateAssetUrls, index$2_updateAttributes as updateAttributes, index$2_wrapIn as wrapIn, index$2_wrapInList as wrapInList };
|
|
3135
3157
|
}
|
|
3136
3158
|
|
|
3137
3159
|
declare const Commands$1: Extension<any, any>;
|
|
@@ -4066,6 +4088,86 @@ declare function objectIncludes(object1: Record<string, any>, object2: Record<st
|
|
|
4066
4088
|
strict: boolean;
|
|
4067
4089
|
}): boolean;
|
|
4068
4090
|
|
|
4091
|
+
/**
|
|
4092
|
+
* The node types that can carry asset URLs.
|
|
4093
|
+
*/
|
|
4094
|
+
type AssetNodeType = 'imageBlock' | 'slide' | 'columnGroup' | 'video';
|
|
4095
|
+
/**
|
|
4096
|
+
* A reference to an asset found in the document.
|
|
4097
|
+
*
|
|
4098
|
+
* - `assetId` is the stable identifier set by the application when the asset
|
|
4099
|
+
* was inserted (only available on `imageBlock` nodes). Use it as the key when
|
|
4100
|
+
* building the URL map for `updateAssetUrls` or `refreshAssets`.
|
|
4101
|
+
* - `currentUrl` is the URL currently stored in the document. Use it as the
|
|
4102
|
+
* key for nodes that have no `assetId` (slides, columnGroups, videos).
|
|
4103
|
+
* - `nodeType` lets you filter by content type if needed.
|
|
4104
|
+
*/
|
|
4105
|
+
interface AssetRef {
|
|
4106
|
+
assetId: string | null;
|
|
4107
|
+
currentUrl: string;
|
|
4108
|
+
nodeType: AssetNodeType;
|
|
4109
|
+
}
|
|
4110
|
+
/**
|
|
4111
|
+
* A map of lookup key → fresh URL passed to `updateAssetUrls` or returned
|
|
4112
|
+
* from an `AssetResolver`. Keys may be either `assetId` values or raw URLs.
|
|
4113
|
+
*/
|
|
4114
|
+
type AssetUrlMap = Record<string, string>;
|
|
4115
|
+
/**
|
|
4116
|
+
* An async function that receives the current assets and returns a map of
|
|
4117
|
+
* fresh URLs. This is the integration point with your storage provider
|
|
4118
|
+
* (S3, Supabase, Cloudflare R2, your own CDN, etc.).
|
|
4119
|
+
*
|
|
4120
|
+
* @example
|
|
4121
|
+
* const resolver: AssetResolver = async (assets) => {
|
|
4122
|
+
* const ids = assets.map(a => a.assetId).filter(Boolean)
|
|
4123
|
+
* const fresh = await myApi.refreshSignedUrls(ids)
|
|
4124
|
+
* return Object.fromEntries(
|
|
4125
|
+
* assets.map(a => [a.assetId ?? a.currentUrl, fresh[a.assetId ?? '']])
|
|
4126
|
+
* )
|
|
4127
|
+
* }
|
|
4128
|
+
*/
|
|
4129
|
+
type AssetResolver = (assets: AssetRef[]) => Promise<AssetUrlMap>;
|
|
4130
|
+
/**
|
|
4131
|
+
* Collect all asset references from the editor document.
|
|
4132
|
+
*
|
|
4133
|
+
* Traverses every node and returns one `AssetRef` per URL-bearing node:
|
|
4134
|
+
* - `imageBlock` nodes (src + optional assetId)
|
|
4135
|
+
* - `slide` nodes with a backgroundImage
|
|
4136
|
+
* - `columnGroup` nodes with a backgroundImage
|
|
4137
|
+
* - `video` nodes (src)
|
|
4138
|
+
*
|
|
4139
|
+
* @example
|
|
4140
|
+
* const assets = getEditorAssets(editor)
|
|
4141
|
+
* // → [{ assetId: 'abc', currentUrl: 'https://...', nodeType: 'imageBlock' }, ...]
|
|
4142
|
+
*/
|
|
4143
|
+
declare function getEditorAssets(editor: SlideEditor): AssetRef[];
|
|
4144
|
+
/**
|
|
4145
|
+
* Refresh all asset URLs in the editor document.
|
|
4146
|
+
*
|
|
4147
|
+
* Collects every asset reference, passes the list to your `resolver` function,
|
|
4148
|
+
* then applies the returned URL map in a single ProseMirror transaction.
|
|
4149
|
+
*
|
|
4150
|
+
* The resolver is where you integrate with your storage provider — fetch
|
|
4151
|
+
* presigned URLs from S3, generate Supabase tokens, call your own API, etc.
|
|
4152
|
+
* Blockslides only handles the document traversal and patching.
|
|
4153
|
+
*
|
|
4154
|
+
* @param editor - The SlideEditor instance.
|
|
4155
|
+
* @param resolver - Async function that receives the asset list and returns
|
|
4156
|
+
* a map of `{ assetId | currentUrl → freshUrl }`.
|
|
4157
|
+
*
|
|
4158
|
+
* @example
|
|
4159
|
+
* import { refreshAssets } from '@blockslides/core'
|
|
4160
|
+
*
|
|
4161
|
+
* await refreshAssets(editor, async (assets) => {
|
|
4162
|
+
* const ids = assets.map(a => a.assetId).filter(Boolean)
|
|
4163
|
+
* const fresh = await myStorage.getSignedUrls(ids)
|
|
4164
|
+
* return Object.fromEntries(
|
|
4165
|
+
* assets.map(a => [a.assetId ?? a.currentUrl, fresh[a.assetId ?? '']])
|
|
4166
|
+
* )
|
|
4167
|
+
* })
|
|
4168
|
+
*/
|
|
4169
|
+
declare function refreshAssets(editor: SlideEditor, resolver: AssetResolver): Promise<void>;
|
|
4170
|
+
|
|
4069
4171
|
/**
|
|
4070
4172
|
* Removes duplicated values within an array.
|
|
4071
4173
|
* Supports numbers, strings and objects.
|
|
@@ -4130,4 +4232,4 @@ interface Commands<ReturnType = any> {
|
|
|
4130
4232
|
interface Storage {
|
|
4131
4233
|
}
|
|
4132
4234
|
|
|
4133
|
-
export { type AnyCommands, type AnyConfig, type AnyExtension, type AtomBlockMarkdownSpecOptions, type Attribute, type Attributes$1 as Attributes, type BlockMarkdownSpecOptions, type BlockParserConfig, type CanCommands, type ChainedCommands, type ChangedRange, type Command, CommandManager, type CommandProps, type CommandSpec, type Commands, type Content, type CreateNodeFromContentOptions, type DOMNode, type DOMOutputSpecArray$1 as DOMOutputSpecArray, type DecorationType, type DecorationWithType, type Diff, type Dispatch, type DocumentType, SlideEditor as Editor, type EditorEvents, type EditorOptions, type EnableRules, Extendable, type ExtendableConfig, type ExtendedRegExpMatchArray, Extension, type ExtensionAttribute, type ExtensionConfig, type Extensions, type FocusPosition, Fragment, type FullMarkdownHelpers, type GlobalAttributes, type HTMLContent, type InlineMarkdownSpecOptions, InputRule, type InputRuleFinder, type InputRuleMatch, type InsertContentAtOptions, type InsertContentOptions, type JSONContent, type KeyboardShortcutCommand, type KeysWithTypeOf, Mark, type MarkConfig, type MarkRange, type MarkType, MarkView, type MarkViewProps, type MarkViewRenderer, type MarkViewRendererOptions, type MarkViewRendererProps, type MarkdownExtensionSpec, type MarkdownHelpers, type MarkdownLexerConfiguration, type MarkdownParseHelpers, type MarkdownParseResult, type MarkdownRendererHelpers, type MarkdownToken, type MarkdownTokenizer, type MaybeReturnType, type MaybeThisParameterType, Node, type NodeConfig, NodePos, type NodeRange, type NodeType, NodeView, type NodeViewProps, type NodeViewRenderer, type NodeViewRendererOptions, type NodeViewRendererProps, type NodeWithPos, type Overwrite, type ParentConfig, type ParsedBlock, type PartialTheme, PasteRule, type PasteRuleFinder, type PasteRuleMatch, type PickValue, type Predicate, type Primitive, type Range, type RawCommands, type RemoveThis, type RenderContext, type ResolvedTheme, type SetContentOptions, type SingleCommands, SlideEditor, type Storage, type TextSerializer, type TextType, type Theme, type ThemeConfig, type ThemeInput, type TiptapEditorHTMLElement, Tracker, type TrackerResult, type UnionCommands, type UnionToIntersection, type ValuesOf, applyAllLayouts, applyLayoutToColumnGroup, applyLayoutToRow, applyTheme, blur, callOrReturn, canInsertNode, clearContent, clearNodes, combineTransactionSteps, command, index$2 as commands, createAtomBlockMarkdownSpec, createBlockMarkdownSpec, createChainableState, createDocument, h as createElement, createInlineMarkdownSpec, createNodeFromContent, createParagraphNear, createStyleTag, cut, darkTheme, defaultBlockAt, deleteCurrentNode, deleteNode, deleteProps, deleteRange, deleteSelection, elementFromString, enter, escapeForRegEx, exitCode, extendMarkRange, index$1 as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, first, flattenExtensions, focus, forEach, fromString, generateHTML, generateJSON, generateText, getAttributes, getAttributesFromExtensions, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAtPosition, getNodeAttributes, getNodeType, getRenderedAttributes, getSchema, getSchemaByResolvedExtensions, getSchemaTypeByName, getSchemaTypeNameByName, getSplittedAttributes, getText, getTextBetween, getTextContentFromNodes, getTextSerializersFromSchema, getTheme, getThemeNames, h, injectExtensionAttributesToParseRule, inputRulesPlugin, insertContent, insertContentAt, isActive, isAndroid, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isString, isTextSelection, isiOS, joinBackward, joinDown, joinForward, joinItemBackward, joinItemForward, joinTextblockBackward, joinTextblockForward, joinUp, keyboardShortcut, lift, liftEmptyBlock, liftListItem, lightTheme, markInputRule, markPasteRule, index as markdown, mergeAttributes, mergeDeep, minMax, newlineInCode, nodeInputRule, nodePasteRule, objectIncludes, parseAttributes, parseIndentedBlocks, parseLayout, pasteRulesPlugin, posToDOMRect, registerTheme, removeDuplicates, renderNestedMarkdownContent, resetAttributes, resolveExtensions, resolveFocusPosition, resolveTheme, rewriteUnknownContent, scrollIntoView, selectAll, selectNodeBackward, selectNodeForward, selectParentNode, selectTextblockEnd, selectTextblockStart, selectionToInsertionEnd, serializeAttributes, setContent, setMark, setMeta, setNode, setNodeSelection, setTextSelection, sinkListItem, sortExtensions, splitBlock, splitExtensions, splitListItem, textInputRule, textPasteRule, textblockTypeInputRule, toggleList, toggleMark, toggleNode, toggleWrap, undoInputRule, unsetAllMarks, unsetMark, updateAttributes, updateMarkViewAttributes, wrapIn, wrapInList, wrappingInputRule };
|
|
4235
|
+
export { type AnyCommands, type AnyConfig, type AnyExtension, type AssetNodeType, type AssetRef, type AssetResolver, type AssetUrlMap, type AtomBlockMarkdownSpecOptions, type Attribute, type Attributes$1 as Attributes, type BlockMarkdownSpecOptions, type BlockParserConfig, type CanCommands, type ChainedCommands, type ChangedRange, type Command, CommandManager, type CommandProps, type CommandSpec, type Commands, type Content, type CreateNodeFromContentOptions, type DOMNode, type DOMOutputSpecArray$1 as DOMOutputSpecArray, type DecorationType, type DecorationWithType, type Diff, type Dispatch, type DocumentType, SlideEditor as Editor, type EditorEvents, type EditorOptions, type EnableRules, Extendable, type ExtendableConfig, type ExtendedRegExpMatchArray, Extension, type ExtensionAttribute, type ExtensionConfig, type Extensions, type FocusPosition, Fragment, type FullMarkdownHelpers, type GlobalAttributes, type HTMLContent, type InlineMarkdownSpecOptions, InputRule, type InputRuleFinder, type InputRuleMatch, type InsertContentAtOptions, type InsertContentOptions, type JSONContent, type KeyboardShortcutCommand, type KeysWithTypeOf, Mark, type MarkConfig, type MarkRange, type MarkType, MarkView, type MarkViewProps, type MarkViewRenderer, type MarkViewRendererOptions, type MarkViewRendererProps, type MarkdownExtensionSpec, type MarkdownHelpers, type MarkdownLexerConfiguration, type MarkdownParseHelpers, type MarkdownParseResult, type MarkdownRendererHelpers, type MarkdownToken, type MarkdownTokenizer, type MaybeReturnType, type MaybeThisParameterType, Node, type NodeConfig, NodePos, type NodeRange, type NodeType, NodeView, type NodeViewProps, type NodeViewRenderer, type NodeViewRendererOptions, type NodeViewRendererProps, type NodeWithPos, type Overwrite, type ParentConfig, type ParsedBlock, type PartialTheme, PasteRule, type PasteRuleFinder, type PasteRuleMatch, type PickValue, type Predicate, type Primitive, type Range, type RawCommands, type RemoveThis, type RenderContext, type ResolvedTheme, type SetContentOptions, type SingleCommands, SlideEditor, type Storage, type TextSerializer, type TextType, type Theme, type ThemeConfig, type ThemeInput, type TiptapEditorHTMLElement, Tracker, type TrackerResult, type UnionCommands, type UnionToIntersection, type ValuesOf, applyAllLayouts, applyLayoutToColumnGroup, applyLayoutToRow, applyTheme, blur, callOrReturn, canInsertNode, clearContent, clearNodes, combineTransactionSteps, command, index$2 as commands, createAtomBlockMarkdownSpec, createBlockMarkdownSpec, createChainableState, createDocument, h as createElement, createInlineMarkdownSpec, createNodeFromContent, createParagraphNear, createStyleTag, cut, darkTheme, defaultBlockAt, deleteCurrentNode, deleteNode, deleteProps, deleteRange, deleteSelection, elementFromString, enter, escapeForRegEx, exitCode, extendMarkRange, index$1 as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, first, flattenExtensions, focus, forEach, fromString, generateHTML, generateJSON, generateText, getAttributes, getAttributesFromExtensions, getChangedRanges, getDebugJSON, getEditorAssets, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAtPosition, getNodeAttributes, getNodeType, getRenderedAttributes, getSchema, getSchemaByResolvedExtensions, getSchemaTypeByName, getSchemaTypeNameByName, getSplittedAttributes, getText, getTextBetween, getTextContentFromNodes, getTextSerializersFromSchema, getTheme, getThemeNames, h, injectExtensionAttributesToParseRule, inputRulesPlugin, insertContent, insertContentAt, isActive, isAndroid, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isString, isTextSelection, isiOS, joinBackward, joinDown, joinForward, joinItemBackward, joinItemForward, joinTextblockBackward, joinTextblockForward, joinUp, keyboardShortcut, lift, liftEmptyBlock, liftListItem, lightTheme, markInputRule, markPasteRule, index as markdown, mergeAttributes, mergeDeep, minMax, newlineInCode, nodeInputRule, nodePasteRule, objectIncludes, parseAttributes, parseIndentedBlocks, parseLayout, pasteRulesPlugin, posToDOMRect, refreshAssets, registerTheme, removeDuplicates, renderNestedMarkdownContent, resetAttributes, resolveExtensions, resolveFocusPosition, resolveTheme, rewriteUnknownContent, scrollIntoView, selectAll, selectNodeBackward, selectNodeForward, selectParentNode, selectTextblockEnd, selectTextblockStart, selectionToInsertionEnd, serializeAttributes, setContent, setMark, setMeta, setNode, setNodeSelection, setTextSelection, sinkListItem, sortExtensions, splitBlock, splitExtensions, splitListItem, textInputRule, textPasteRule, textblockTypeInputRule, toggleList, toggleMark, toggleNode, toggleWrap, undoInputRule, unsetAllMarks, unsetMark, updateAssetUrls, updateAttributes, updateMarkViewAttributes, wrapIn, wrapInList, wrappingInputRule };
|
package/dist/index.d.ts
CHANGED
|
@@ -3016,6 +3016,27 @@ declare module '@blockslides/core' {
|
|
|
3016
3016
|
}
|
|
3017
3017
|
declare const unsetMark: RawCommands['unsetMark'];
|
|
3018
3018
|
|
|
3019
|
+
declare module '@blockslides/core' {
|
|
3020
|
+
interface Commands<ReturnType> {
|
|
3021
|
+
updateAssetUrls: {
|
|
3022
|
+
/**
|
|
3023
|
+
* Update asset URLs across the entire document in a single transaction.
|
|
3024
|
+
* The map keys can be either an `assetId` (preferred for imageBlock nodes)
|
|
3025
|
+
* or the current URL (used as a fallback, and for nodes without an assetId
|
|
3026
|
+
* such as slide/columnGroup backgrounds and video embeds).
|
|
3027
|
+
*
|
|
3028
|
+
* @example
|
|
3029
|
+
* editor.commands.updateAssetUrls({
|
|
3030
|
+
* 'asset-123': 'https://cdn.example.com/fresh-url.jpg',
|
|
3031
|
+
* 'https://old.example.com/bg.jpg': 'https://cdn.example.com/fresh-bg.jpg',
|
|
3032
|
+
* })
|
|
3033
|
+
*/
|
|
3034
|
+
updateAssetUrls: (urlMap: Record<string, string>) => ReturnType;
|
|
3035
|
+
};
|
|
3036
|
+
}
|
|
3037
|
+
}
|
|
3038
|
+
declare const updateAssetUrls: RawCommands['updateAssetUrls'];
|
|
3039
|
+
|
|
3019
3040
|
declare module '@blockslides/core' {
|
|
3020
3041
|
interface Commands<ReturnType> {
|
|
3021
3042
|
updateAttributes: {
|
|
@@ -3127,11 +3148,12 @@ declare const index$2_toggleWrap: typeof toggleWrap;
|
|
|
3127
3148
|
declare const index$2_undoInputRule: typeof undoInputRule;
|
|
3128
3149
|
declare const index$2_unsetAllMarks: typeof unsetAllMarks;
|
|
3129
3150
|
declare const index$2_unsetMark: typeof unsetMark;
|
|
3151
|
+
declare const index$2_updateAssetUrls: typeof updateAssetUrls;
|
|
3130
3152
|
declare const index$2_updateAttributes: typeof updateAttributes;
|
|
3131
3153
|
declare const index$2_wrapIn: typeof wrapIn;
|
|
3132
3154
|
declare const index$2_wrapInList: typeof wrapInList;
|
|
3133
3155
|
declare namespace index$2 {
|
|
3134
|
-
export { type index$2_InsertContentAtOptions as InsertContentAtOptions, type index$2_InsertContentOptions as InsertContentOptions, type index$2_SetContentOptions as SetContentOptions, index$2_blur as blur, index$2_clearContent as clearContent, index$2_clearNodes as clearNodes, index$2_command as command, index$2_createParagraphNear as createParagraphNear, index$2_cut as cut, index$2_deleteCurrentNode as deleteCurrentNode, index$2_deleteNode as deleteNode, index$2_deleteRange as deleteRange, index$2_deleteSelection as deleteSelection, index$2_enter as enter, index$2_exitCode as exitCode, index$2_extendMarkRange as extendMarkRange, index$2_first as first, index$2_focus as focus, index$2_forEach as forEach, index$2_insertContent as insertContent, index$2_insertContentAt as insertContentAt, index$2_joinBackward as joinBackward, index$2_joinDown as joinDown, index$2_joinForward as joinForward, index$2_joinItemBackward as joinItemBackward, index$2_joinItemForward as joinItemForward, index$2_joinTextblockBackward as joinTextblockBackward, index$2_joinTextblockForward as joinTextblockForward, index$2_joinUp as joinUp, index$2_keyboardShortcut as keyboardShortcut, index$2_lift as lift, index$2_liftEmptyBlock as liftEmptyBlock, index$2_liftListItem as liftListItem, index$2_newlineInCode as newlineInCode, index$2_resetAttributes as resetAttributes, index$2_scrollIntoView as scrollIntoView, index$2_selectAll as selectAll, index$2_selectNodeBackward as selectNodeBackward, index$2_selectNodeForward as selectNodeForward, index$2_selectParentNode as selectParentNode, index$2_selectTextblockEnd as selectTextblockEnd, index$2_selectTextblockStart as selectTextblockStart, index$2_setContent as setContent, index$2_setMark as setMark, index$2_setMeta as setMeta, index$2_setNode as setNode, index$2_setNodeSelection as setNodeSelection, index$2_setTextSelection as setTextSelection, index$2_sinkListItem as sinkListItem, index$2_splitBlock as splitBlock, index$2_splitListItem as splitListItem, index$2_toggleList as toggleList, index$2_toggleMark as toggleMark, index$2_toggleNode as toggleNode, index$2_toggleWrap as toggleWrap, index$2_undoInputRule as undoInputRule, index$2_unsetAllMarks as unsetAllMarks, index$2_unsetMark as unsetMark, index$2_updateAttributes as updateAttributes, index$2_wrapIn as wrapIn, index$2_wrapInList as wrapInList };
|
|
3156
|
+
export { type index$2_InsertContentAtOptions as InsertContentAtOptions, type index$2_InsertContentOptions as InsertContentOptions, type index$2_SetContentOptions as SetContentOptions, index$2_blur as blur, index$2_clearContent as clearContent, index$2_clearNodes as clearNodes, index$2_command as command, index$2_createParagraphNear as createParagraphNear, index$2_cut as cut, index$2_deleteCurrentNode as deleteCurrentNode, index$2_deleteNode as deleteNode, index$2_deleteRange as deleteRange, index$2_deleteSelection as deleteSelection, index$2_enter as enter, index$2_exitCode as exitCode, index$2_extendMarkRange as extendMarkRange, index$2_first as first, index$2_focus as focus, index$2_forEach as forEach, index$2_insertContent as insertContent, index$2_insertContentAt as insertContentAt, index$2_joinBackward as joinBackward, index$2_joinDown as joinDown, index$2_joinForward as joinForward, index$2_joinItemBackward as joinItemBackward, index$2_joinItemForward as joinItemForward, index$2_joinTextblockBackward as joinTextblockBackward, index$2_joinTextblockForward as joinTextblockForward, index$2_joinUp as joinUp, index$2_keyboardShortcut as keyboardShortcut, index$2_lift as lift, index$2_liftEmptyBlock as liftEmptyBlock, index$2_liftListItem as liftListItem, index$2_newlineInCode as newlineInCode, index$2_resetAttributes as resetAttributes, index$2_scrollIntoView as scrollIntoView, index$2_selectAll as selectAll, index$2_selectNodeBackward as selectNodeBackward, index$2_selectNodeForward as selectNodeForward, index$2_selectParentNode as selectParentNode, index$2_selectTextblockEnd as selectTextblockEnd, index$2_selectTextblockStart as selectTextblockStart, index$2_setContent as setContent, index$2_setMark as setMark, index$2_setMeta as setMeta, index$2_setNode as setNode, index$2_setNodeSelection as setNodeSelection, index$2_setTextSelection as setTextSelection, index$2_sinkListItem as sinkListItem, index$2_splitBlock as splitBlock, index$2_splitListItem as splitListItem, index$2_toggleList as toggleList, index$2_toggleMark as toggleMark, index$2_toggleNode as toggleNode, index$2_toggleWrap as toggleWrap, index$2_undoInputRule as undoInputRule, index$2_unsetAllMarks as unsetAllMarks, index$2_unsetMark as unsetMark, index$2_updateAssetUrls as updateAssetUrls, index$2_updateAttributes as updateAttributes, index$2_wrapIn as wrapIn, index$2_wrapInList as wrapInList };
|
|
3135
3157
|
}
|
|
3136
3158
|
|
|
3137
3159
|
declare const Commands$1: Extension<any, any>;
|
|
@@ -4066,6 +4088,86 @@ declare function objectIncludes(object1: Record<string, any>, object2: Record<st
|
|
|
4066
4088
|
strict: boolean;
|
|
4067
4089
|
}): boolean;
|
|
4068
4090
|
|
|
4091
|
+
/**
|
|
4092
|
+
* The node types that can carry asset URLs.
|
|
4093
|
+
*/
|
|
4094
|
+
type AssetNodeType = 'imageBlock' | 'slide' | 'columnGroup' | 'video';
|
|
4095
|
+
/**
|
|
4096
|
+
* A reference to an asset found in the document.
|
|
4097
|
+
*
|
|
4098
|
+
* - `assetId` is the stable identifier set by the application when the asset
|
|
4099
|
+
* was inserted (only available on `imageBlock` nodes). Use it as the key when
|
|
4100
|
+
* building the URL map for `updateAssetUrls` or `refreshAssets`.
|
|
4101
|
+
* - `currentUrl` is the URL currently stored in the document. Use it as the
|
|
4102
|
+
* key for nodes that have no `assetId` (slides, columnGroups, videos).
|
|
4103
|
+
* - `nodeType` lets you filter by content type if needed.
|
|
4104
|
+
*/
|
|
4105
|
+
interface AssetRef {
|
|
4106
|
+
assetId: string | null;
|
|
4107
|
+
currentUrl: string;
|
|
4108
|
+
nodeType: AssetNodeType;
|
|
4109
|
+
}
|
|
4110
|
+
/**
|
|
4111
|
+
* A map of lookup key → fresh URL passed to `updateAssetUrls` or returned
|
|
4112
|
+
* from an `AssetResolver`. Keys may be either `assetId` values or raw URLs.
|
|
4113
|
+
*/
|
|
4114
|
+
type AssetUrlMap = Record<string, string>;
|
|
4115
|
+
/**
|
|
4116
|
+
* An async function that receives the current assets and returns a map of
|
|
4117
|
+
* fresh URLs. This is the integration point with your storage provider
|
|
4118
|
+
* (S3, Supabase, Cloudflare R2, your own CDN, etc.).
|
|
4119
|
+
*
|
|
4120
|
+
* @example
|
|
4121
|
+
* const resolver: AssetResolver = async (assets) => {
|
|
4122
|
+
* const ids = assets.map(a => a.assetId).filter(Boolean)
|
|
4123
|
+
* const fresh = await myApi.refreshSignedUrls(ids)
|
|
4124
|
+
* return Object.fromEntries(
|
|
4125
|
+
* assets.map(a => [a.assetId ?? a.currentUrl, fresh[a.assetId ?? '']])
|
|
4126
|
+
* )
|
|
4127
|
+
* }
|
|
4128
|
+
*/
|
|
4129
|
+
type AssetResolver = (assets: AssetRef[]) => Promise<AssetUrlMap>;
|
|
4130
|
+
/**
|
|
4131
|
+
* Collect all asset references from the editor document.
|
|
4132
|
+
*
|
|
4133
|
+
* Traverses every node and returns one `AssetRef` per URL-bearing node:
|
|
4134
|
+
* - `imageBlock` nodes (src + optional assetId)
|
|
4135
|
+
* - `slide` nodes with a backgroundImage
|
|
4136
|
+
* - `columnGroup` nodes with a backgroundImage
|
|
4137
|
+
* - `video` nodes (src)
|
|
4138
|
+
*
|
|
4139
|
+
* @example
|
|
4140
|
+
* const assets = getEditorAssets(editor)
|
|
4141
|
+
* // → [{ assetId: 'abc', currentUrl: 'https://...', nodeType: 'imageBlock' }, ...]
|
|
4142
|
+
*/
|
|
4143
|
+
declare function getEditorAssets(editor: SlideEditor): AssetRef[];
|
|
4144
|
+
/**
|
|
4145
|
+
* Refresh all asset URLs in the editor document.
|
|
4146
|
+
*
|
|
4147
|
+
* Collects every asset reference, passes the list to your `resolver` function,
|
|
4148
|
+
* then applies the returned URL map in a single ProseMirror transaction.
|
|
4149
|
+
*
|
|
4150
|
+
* The resolver is where you integrate with your storage provider — fetch
|
|
4151
|
+
* presigned URLs from S3, generate Supabase tokens, call your own API, etc.
|
|
4152
|
+
* Blockslides only handles the document traversal and patching.
|
|
4153
|
+
*
|
|
4154
|
+
* @param editor - The SlideEditor instance.
|
|
4155
|
+
* @param resolver - Async function that receives the asset list and returns
|
|
4156
|
+
* a map of `{ assetId | currentUrl → freshUrl }`.
|
|
4157
|
+
*
|
|
4158
|
+
* @example
|
|
4159
|
+
* import { refreshAssets } from '@blockslides/core'
|
|
4160
|
+
*
|
|
4161
|
+
* await refreshAssets(editor, async (assets) => {
|
|
4162
|
+
* const ids = assets.map(a => a.assetId).filter(Boolean)
|
|
4163
|
+
* const fresh = await myStorage.getSignedUrls(ids)
|
|
4164
|
+
* return Object.fromEntries(
|
|
4165
|
+
* assets.map(a => [a.assetId ?? a.currentUrl, fresh[a.assetId ?? '']])
|
|
4166
|
+
* )
|
|
4167
|
+
* })
|
|
4168
|
+
*/
|
|
4169
|
+
declare function refreshAssets(editor: SlideEditor, resolver: AssetResolver): Promise<void>;
|
|
4170
|
+
|
|
4069
4171
|
/**
|
|
4070
4172
|
* Removes duplicated values within an array.
|
|
4071
4173
|
* Supports numbers, strings and objects.
|
|
@@ -4130,4 +4232,4 @@ interface Commands<ReturnType = any> {
|
|
|
4130
4232
|
interface Storage {
|
|
4131
4233
|
}
|
|
4132
4234
|
|
|
4133
|
-
export { type AnyCommands, type AnyConfig, type AnyExtension, type AtomBlockMarkdownSpecOptions, type Attribute, type Attributes$1 as Attributes, type BlockMarkdownSpecOptions, type BlockParserConfig, type CanCommands, type ChainedCommands, type ChangedRange, type Command, CommandManager, type CommandProps, type CommandSpec, type Commands, type Content, type CreateNodeFromContentOptions, type DOMNode, type DOMOutputSpecArray$1 as DOMOutputSpecArray, type DecorationType, type DecorationWithType, type Diff, type Dispatch, type DocumentType, SlideEditor as Editor, type EditorEvents, type EditorOptions, type EnableRules, Extendable, type ExtendableConfig, type ExtendedRegExpMatchArray, Extension, type ExtensionAttribute, type ExtensionConfig, type Extensions, type FocusPosition, Fragment, type FullMarkdownHelpers, type GlobalAttributes, type HTMLContent, type InlineMarkdownSpecOptions, InputRule, type InputRuleFinder, type InputRuleMatch, type InsertContentAtOptions, type InsertContentOptions, type JSONContent, type KeyboardShortcutCommand, type KeysWithTypeOf, Mark, type MarkConfig, type MarkRange, type MarkType, MarkView, type MarkViewProps, type MarkViewRenderer, type MarkViewRendererOptions, type MarkViewRendererProps, type MarkdownExtensionSpec, type MarkdownHelpers, type MarkdownLexerConfiguration, type MarkdownParseHelpers, type MarkdownParseResult, type MarkdownRendererHelpers, type MarkdownToken, type MarkdownTokenizer, type MaybeReturnType, type MaybeThisParameterType, Node, type NodeConfig, NodePos, type NodeRange, type NodeType, NodeView, type NodeViewProps, type NodeViewRenderer, type NodeViewRendererOptions, type NodeViewRendererProps, type NodeWithPos, type Overwrite, type ParentConfig, type ParsedBlock, type PartialTheme, PasteRule, type PasteRuleFinder, type PasteRuleMatch, type PickValue, type Predicate, type Primitive, type Range, type RawCommands, type RemoveThis, type RenderContext, type ResolvedTheme, type SetContentOptions, type SingleCommands, SlideEditor, type Storage, type TextSerializer, type TextType, type Theme, type ThemeConfig, type ThemeInput, type TiptapEditorHTMLElement, Tracker, type TrackerResult, type UnionCommands, type UnionToIntersection, type ValuesOf, applyAllLayouts, applyLayoutToColumnGroup, applyLayoutToRow, applyTheme, blur, callOrReturn, canInsertNode, clearContent, clearNodes, combineTransactionSteps, command, index$2 as commands, createAtomBlockMarkdownSpec, createBlockMarkdownSpec, createChainableState, createDocument, h as createElement, createInlineMarkdownSpec, createNodeFromContent, createParagraphNear, createStyleTag, cut, darkTheme, defaultBlockAt, deleteCurrentNode, deleteNode, deleteProps, deleteRange, deleteSelection, elementFromString, enter, escapeForRegEx, exitCode, extendMarkRange, index$1 as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, first, flattenExtensions, focus, forEach, fromString, generateHTML, generateJSON, generateText, getAttributes, getAttributesFromExtensions, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAtPosition, getNodeAttributes, getNodeType, getRenderedAttributes, getSchema, getSchemaByResolvedExtensions, getSchemaTypeByName, getSchemaTypeNameByName, getSplittedAttributes, getText, getTextBetween, getTextContentFromNodes, getTextSerializersFromSchema, getTheme, getThemeNames, h, injectExtensionAttributesToParseRule, inputRulesPlugin, insertContent, insertContentAt, isActive, isAndroid, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isString, isTextSelection, isiOS, joinBackward, joinDown, joinForward, joinItemBackward, joinItemForward, joinTextblockBackward, joinTextblockForward, joinUp, keyboardShortcut, lift, liftEmptyBlock, liftListItem, lightTheme, markInputRule, markPasteRule, index as markdown, mergeAttributes, mergeDeep, minMax, newlineInCode, nodeInputRule, nodePasteRule, objectIncludes, parseAttributes, parseIndentedBlocks, parseLayout, pasteRulesPlugin, posToDOMRect, registerTheme, removeDuplicates, renderNestedMarkdownContent, resetAttributes, resolveExtensions, resolveFocusPosition, resolveTheme, rewriteUnknownContent, scrollIntoView, selectAll, selectNodeBackward, selectNodeForward, selectParentNode, selectTextblockEnd, selectTextblockStart, selectionToInsertionEnd, serializeAttributes, setContent, setMark, setMeta, setNode, setNodeSelection, setTextSelection, sinkListItem, sortExtensions, splitBlock, splitExtensions, splitListItem, textInputRule, textPasteRule, textblockTypeInputRule, toggleList, toggleMark, toggleNode, toggleWrap, undoInputRule, unsetAllMarks, unsetMark, updateAttributes, updateMarkViewAttributes, wrapIn, wrapInList, wrappingInputRule };
|
|
4235
|
+
export { type AnyCommands, type AnyConfig, type AnyExtension, type AssetNodeType, type AssetRef, type AssetResolver, type AssetUrlMap, type AtomBlockMarkdownSpecOptions, type Attribute, type Attributes$1 as Attributes, type BlockMarkdownSpecOptions, type BlockParserConfig, type CanCommands, type ChainedCommands, type ChangedRange, type Command, CommandManager, type CommandProps, type CommandSpec, type Commands, type Content, type CreateNodeFromContentOptions, type DOMNode, type DOMOutputSpecArray$1 as DOMOutputSpecArray, type DecorationType, type DecorationWithType, type Diff, type Dispatch, type DocumentType, SlideEditor as Editor, type EditorEvents, type EditorOptions, type EnableRules, Extendable, type ExtendableConfig, type ExtendedRegExpMatchArray, Extension, type ExtensionAttribute, type ExtensionConfig, type Extensions, type FocusPosition, Fragment, type FullMarkdownHelpers, type GlobalAttributes, type HTMLContent, type InlineMarkdownSpecOptions, InputRule, type InputRuleFinder, type InputRuleMatch, type InsertContentAtOptions, type InsertContentOptions, type JSONContent, type KeyboardShortcutCommand, type KeysWithTypeOf, Mark, type MarkConfig, type MarkRange, type MarkType, MarkView, type MarkViewProps, type MarkViewRenderer, type MarkViewRendererOptions, type MarkViewRendererProps, type MarkdownExtensionSpec, type MarkdownHelpers, type MarkdownLexerConfiguration, type MarkdownParseHelpers, type MarkdownParseResult, type MarkdownRendererHelpers, type MarkdownToken, type MarkdownTokenizer, type MaybeReturnType, type MaybeThisParameterType, Node, type NodeConfig, NodePos, type NodeRange, type NodeType, NodeView, type NodeViewProps, type NodeViewRenderer, type NodeViewRendererOptions, type NodeViewRendererProps, type NodeWithPos, type Overwrite, type ParentConfig, type ParsedBlock, type PartialTheme, PasteRule, type PasteRuleFinder, type PasteRuleMatch, type PickValue, type Predicate, type Primitive, type Range, type RawCommands, type RemoveThis, type RenderContext, type ResolvedTheme, type SetContentOptions, type SingleCommands, SlideEditor, type Storage, type TextSerializer, type TextType, type Theme, type ThemeConfig, type ThemeInput, type TiptapEditorHTMLElement, Tracker, type TrackerResult, type UnionCommands, type UnionToIntersection, type ValuesOf, applyAllLayouts, applyLayoutToColumnGroup, applyLayoutToRow, applyTheme, blur, callOrReturn, canInsertNode, clearContent, clearNodes, combineTransactionSteps, command, index$2 as commands, createAtomBlockMarkdownSpec, createBlockMarkdownSpec, createChainableState, createDocument, h as createElement, createInlineMarkdownSpec, createNodeFromContent, createParagraphNear, createStyleTag, cut, darkTheme, defaultBlockAt, deleteCurrentNode, deleteNode, deleteProps, deleteRange, deleteSelection, elementFromString, enter, escapeForRegEx, exitCode, extendMarkRange, index$1 as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, first, flattenExtensions, focus, forEach, fromString, generateHTML, generateJSON, generateText, getAttributes, getAttributesFromExtensions, getChangedRanges, getDebugJSON, getEditorAssets, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAtPosition, getNodeAttributes, getNodeType, getRenderedAttributes, getSchema, getSchemaByResolvedExtensions, getSchemaTypeByName, getSchemaTypeNameByName, getSplittedAttributes, getText, getTextBetween, getTextContentFromNodes, getTextSerializersFromSchema, getTheme, getThemeNames, h, injectExtensionAttributesToParseRule, inputRulesPlugin, insertContent, insertContentAt, isActive, isAndroid, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isString, isTextSelection, isiOS, joinBackward, joinDown, joinForward, joinItemBackward, joinItemForward, joinTextblockBackward, joinTextblockForward, joinUp, keyboardShortcut, lift, liftEmptyBlock, liftListItem, lightTheme, markInputRule, markPasteRule, index as markdown, mergeAttributes, mergeDeep, minMax, newlineInCode, nodeInputRule, nodePasteRule, objectIncludes, parseAttributes, parseIndentedBlocks, parseLayout, pasteRulesPlugin, posToDOMRect, refreshAssets, registerTheme, removeDuplicates, renderNestedMarkdownContent, resetAttributes, resolveExtensions, resolveFocusPosition, resolveTheme, rewriteUnknownContent, scrollIntoView, selectAll, selectNodeBackward, selectNodeForward, selectParentNode, selectTextblockEnd, selectTextblockStart, selectionToInsertionEnd, serializeAttributes, setContent, setMark, setMeta, setNode, setNodeSelection, setTextSelection, sinkListItem, sortExtensions, splitBlock, splitExtensions, splitListItem, textInputRule, textPasteRule, textblockTypeInputRule, toggleList, toggleMark, toggleNode, toggleWrap, undoInputRule, unsetAllMarks, unsetMark, updateAssetUrls, updateAttributes, updateMarkViewAttributes, wrapIn, wrapInList, wrappingInputRule };
|
package/dist/index.js
CHANGED
|
@@ -70,6 +70,7 @@ __export(index_exports, {
|
|
|
70
70
|
getAttributesFromExtensions: () => getAttributesFromExtensions,
|
|
71
71
|
getChangedRanges: () => getChangedRanges,
|
|
72
72
|
getDebugJSON: () => getDebugJSON,
|
|
73
|
+
getEditorAssets: () => getEditorAssets,
|
|
73
74
|
getExtensionField: () => getExtensionField,
|
|
74
75
|
getHTMLFromFragment: () => getHTMLFromFragment,
|
|
75
76
|
getMarkAttributes: () => getMarkAttributes,
|
|
@@ -128,6 +129,7 @@ __export(index_exports, {
|
|
|
128
129
|
parseLayout: () => parseLayout,
|
|
129
130
|
pasteRulesPlugin: () => pasteRulesPlugin,
|
|
130
131
|
posToDOMRect: () => posToDOMRect,
|
|
132
|
+
refreshAssets: () => refreshAssets,
|
|
131
133
|
registerTheme: () => registerTheme,
|
|
132
134
|
removeDuplicates: () => removeDuplicates,
|
|
133
135
|
renderNestedMarkdownContent: () => renderNestedMarkdownContent,
|
|
@@ -346,6 +348,7 @@ __export(commands_exports, {
|
|
|
346
348
|
undoInputRule: () => undoInputRule,
|
|
347
349
|
unsetAllMarks: () => unsetAllMarks,
|
|
348
350
|
unsetMark: () => unsetMark,
|
|
351
|
+
updateAssetUrls: () => updateAssetUrls,
|
|
349
352
|
updateAttributes: () => updateAttributes,
|
|
350
353
|
wrapIn: () => wrapIn,
|
|
351
354
|
wrapInList: () => wrapInList
|
|
@@ -2831,6 +2834,37 @@ var unsetMark = (typeOrName, options = {}) => ({ tr, state, dispatch }) => {
|
|
|
2831
2834
|
return true;
|
|
2832
2835
|
};
|
|
2833
2836
|
|
|
2837
|
+
// src/commands/updateAssetUrls.ts
|
|
2838
|
+
var updateAssetUrls = (urlMap) => ({ tr, state, dispatch }) => {
|
|
2839
|
+
if (dispatch) {
|
|
2840
|
+
state.doc.descendants((node, pos) => {
|
|
2841
|
+
if (node.type.name === "imageBlock" && node.attrs.src) {
|
|
2842
|
+
const key = node.attrs.assetId && urlMap[node.attrs.assetId] ? node.attrs.assetId : node.attrs.src;
|
|
2843
|
+
const newUrl = urlMap[key];
|
|
2844
|
+
if (newUrl) {
|
|
2845
|
+
tr.setNodeMarkup(pos, void 0, { ...node.attrs, src: newUrl });
|
|
2846
|
+
}
|
|
2847
|
+
}
|
|
2848
|
+
if ((node.type.name === "slide" || node.type.name === "columnGroup") && node.attrs.backgroundImage) {
|
|
2849
|
+
const newUrl = urlMap[node.attrs.backgroundImage];
|
|
2850
|
+
if (newUrl) {
|
|
2851
|
+
tr.setNodeMarkup(pos, void 0, {
|
|
2852
|
+
...node.attrs,
|
|
2853
|
+
backgroundImage: newUrl
|
|
2854
|
+
});
|
|
2855
|
+
}
|
|
2856
|
+
}
|
|
2857
|
+
if (node.type.name === "video" && node.attrs.src) {
|
|
2858
|
+
const newUrl = urlMap[node.attrs.src];
|
|
2859
|
+
if (newUrl) {
|
|
2860
|
+
tr.setNodeMarkup(pos, void 0, { ...node.attrs, src: newUrl });
|
|
2861
|
+
}
|
|
2862
|
+
}
|
|
2863
|
+
});
|
|
2864
|
+
}
|
|
2865
|
+
return true;
|
|
2866
|
+
};
|
|
2867
|
+
|
|
2834
2868
|
// src/commands/updateAttributes.ts
|
|
2835
2869
|
var updateAttributes = (typeOrName, attributes = {}) => ({ tr, state, dispatch }) => {
|
|
2836
2870
|
let nodeType = null;
|
|
@@ -4726,7 +4760,6 @@ function createStyleTag(style2, nonce, suffix) {
|
|
|
4726
4760
|
// src/SlideEditor.ts
|
|
4727
4761
|
var SlideEditor = class extends EventEmitter {
|
|
4728
4762
|
constructor(options = {}) {
|
|
4729
|
-
console.log("[Core SlideEditor] Constructor called with options:", options);
|
|
4730
4763
|
super();
|
|
4731
4764
|
this.css = null;
|
|
4732
4765
|
this.editorView = null;
|
|
@@ -4776,15 +4809,10 @@ var SlideEditor = class extends EventEmitter {
|
|
|
4776
4809
|
this.isCapturingTransaction = false;
|
|
4777
4810
|
this.capturedTransaction = null;
|
|
4778
4811
|
this.setOptions(options);
|
|
4779
|
-
console.log("[Core SlideEditor] this.options.enableCoreExtensions:", this.options.enableCoreExtensions);
|
|
4780
4812
|
this.resolvedTheme = resolveTheme(this.options.theme);
|
|
4781
|
-
console.log("[Core SlideEditor] Theme resolved:", this.resolvedTheme);
|
|
4782
4813
|
this.createExtensionManager();
|
|
4783
|
-
console.log("[Core SlideEditor] Extension manager created");
|
|
4784
4814
|
this.createCommandManager();
|
|
4785
|
-
console.log("[Core SlideEditor] Command manager created");
|
|
4786
4815
|
this.createSchema();
|
|
4787
|
-
console.log("[Core SlideEditor] Schema created");
|
|
4788
4816
|
this.on("beforeCreate", this.options.onBeforeCreate);
|
|
4789
4817
|
this.emit("beforeCreate", { editor: this });
|
|
4790
4818
|
this.on("mount", this.options.onMount);
|
|
@@ -4803,29 +4831,21 @@ var SlideEditor = class extends EventEmitter {
|
|
|
4803
4831
|
);
|
|
4804
4832
|
this.on("paste", ({ event, slice }) => this.options.onPaste(event, slice));
|
|
4805
4833
|
this.on("delete", this.options.onDelete);
|
|
4806
|
-
console.log("[Core SlideEditor] Event handlers registered");
|
|
4807
4834
|
const initialDoc = this.createDoc();
|
|
4808
|
-
console.log("[Core SlideEditor] Initial doc created:", initialDoc);
|
|
4809
4835
|
const selection = resolveFocusPosition(initialDoc, this.options.autofocus);
|
|
4810
4836
|
this.editorState = import_state21.EditorState.create({
|
|
4811
4837
|
doc: initialDoc,
|
|
4812
4838
|
schema: this.schema,
|
|
4813
4839
|
selection: selection || void 0
|
|
4814
4840
|
});
|
|
4815
|
-
console.log("[Core SlideEditor] Editor state created:", this.editorState);
|
|
4816
4841
|
if (this.options.element) {
|
|
4817
|
-
console.log("[Core SlideEditor] Element provided, calling mount");
|
|
4818
4842
|
this.mount(this.options.element);
|
|
4819
|
-
} else {
|
|
4820
|
-
console.log("[Core SlideEditor] No element provided, skipping mount");
|
|
4821
4843
|
}
|
|
4822
|
-
console.log("[Core SlideEditor] \u2705 Constructor complete");
|
|
4823
4844
|
}
|
|
4824
4845
|
/**
|
|
4825
4846
|
* Attach the editor to the DOM, creating a new editor view.
|
|
4826
4847
|
*/
|
|
4827
4848
|
mount(el) {
|
|
4828
|
-
console.log("[Core SlideEditor] mount() called with element:", el);
|
|
4829
4849
|
if (typeof document === "undefined") {
|
|
4830
4850
|
throw new Error(
|
|
4831
4851
|
`[blockslides error]: The editor cannot be mounted because there is no 'document' defined in this environment.`
|
|
@@ -4837,15 +4857,9 @@ var SlideEditor = class extends EventEmitter {
|
|
|
4837
4857
|
document.head.appendChild(this.css);
|
|
4838
4858
|
}
|
|
4839
4859
|
window.setTimeout(() => {
|
|
4840
|
-
var _a;
|
|
4841
4860
|
if (this.isDestroyed) {
|
|
4842
4861
|
return;
|
|
4843
4862
|
}
|
|
4844
|
-
console.log("[mount setTimeout] this:", this);
|
|
4845
|
-
console.log("[mount setTimeout] this.commandManager:", this.commandManager);
|
|
4846
|
-
console.log("[mount setTimeout] this.commands:", this.commands);
|
|
4847
|
-
console.log("[mount setTimeout] typeof this.commands:", typeof this.commands);
|
|
4848
|
-
console.log("[mount setTimeout] this.commands.focus:", (_a = this.commands) == null ? void 0 : _a.focus);
|
|
4849
4863
|
this.commands.focus(this.options.autofocus);
|
|
4850
4864
|
this.emit("create", { editor: this });
|
|
4851
4865
|
this.isInitialized = true;
|
|
@@ -5045,7 +5059,6 @@ var SlideEditor = class extends EventEmitter {
|
|
|
5045
5059
|
*/
|
|
5046
5060
|
createExtensionManager() {
|
|
5047
5061
|
var _a, _b;
|
|
5048
|
-
console.log("[Core SlideEditor] createExtensionManager - enableCoreExtensions:", this.options.enableCoreExtensions);
|
|
5049
5062
|
const coreExtensions = this.options.enableCoreExtensions ? [
|
|
5050
5063
|
Editable,
|
|
5051
5064
|
ClipboardTextSerializer.configure({
|
|
@@ -5064,8 +5077,6 @@ var SlideEditor = class extends EventEmitter {
|
|
|
5064
5077
|
}
|
|
5065
5078
|
return true;
|
|
5066
5079
|
}) : [];
|
|
5067
|
-
console.log("[Core SlideEditor] coreExtensions:", coreExtensions.map((e) => e.name));
|
|
5068
|
-
console.log("[Core SlideEditor] this.options.extensions:", this.options.extensions.map((e) => e.name));
|
|
5069
5080
|
const allExtensions = [
|
|
5070
5081
|
...coreExtensions,
|
|
5071
5082
|
...this.options.extensions
|
|
@@ -5138,8 +5149,6 @@ var SlideEditor = class extends EventEmitter {
|
|
|
5138
5149
|
*/
|
|
5139
5150
|
createView(element) {
|
|
5140
5151
|
var _a;
|
|
5141
|
-
console.log("[Core SlideEditor] createView() called with element:", element);
|
|
5142
|
-
console.log("[Core SlideEditor] editorState:", this.editorState);
|
|
5143
5152
|
this.editorView = new import_view.EditorView(element, {
|
|
5144
5153
|
...this.options.editorProps,
|
|
5145
5154
|
attributes: {
|
|
@@ -5152,14 +5161,10 @@ var SlideEditor = class extends EventEmitter {
|
|
|
5152
5161
|
markViews: this.extensionManager.markViews,
|
|
5153
5162
|
nodeViews: this.extensionManager.nodeViews
|
|
5154
5163
|
});
|
|
5155
|
-
console.log("[Core SlideEditor] EditorView created:", this.editorView);
|
|
5156
|
-
console.log("[Core SlideEditor] EditorView.dom:", this.editorView.dom);
|
|
5157
5164
|
const newState = this.state.reconfigure({
|
|
5158
5165
|
plugins: this.extensionManager.plugins
|
|
5159
5166
|
});
|
|
5160
|
-
console.log("[Core SlideEditor] Reconfigured state with plugins");
|
|
5161
5167
|
this.view.updateState(newState);
|
|
5162
|
-
console.log("[Core SlideEditor] \u2705 View state updated");
|
|
5163
5168
|
this.prependClass();
|
|
5164
5169
|
this.injectCSS();
|
|
5165
5170
|
applyTheme(this.resolvedTheme, this.view.dom);
|
|
@@ -6102,6 +6107,49 @@ function renderNestedMarkdownContent(node, h2, prefixOrGenerator, ctx) {
|
|
|
6102
6107
|
return output.join("\n");
|
|
6103
6108
|
}
|
|
6104
6109
|
|
|
6110
|
+
// src/utilities/assetRefresh.ts
|
|
6111
|
+
function getEditorAssets(editor) {
|
|
6112
|
+
const assets = [];
|
|
6113
|
+
editor.state.doc.descendants((node) => {
|
|
6114
|
+
var _a;
|
|
6115
|
+
if (node.type.name === "imageBlock" && node.attrs.src) {
|
|
6116
|
+
assets.push({
|
|
6117
|
+
assetId: (_a = node.attrs.assetId) != null ? _a : null,
|
|
6118
|
+
currentUrl: node.attrs.src,
|
|
6119
|
+
nodeType: "imageBlock"
|
|
6120
|
+
});
|
|
6121
|
+
}
|
|
6122
|
+
if (node.type.name === "slide" && node.attrs.backgroundImage) {
|
|
6123
|
+
assets.push({
|
|
6124
|
+
assetId: null,
|
|
6125
|
+
currentUrl: node.attrs.backgroundImage,
|
|
6126
|
+
nodeType: "slide"
|
|
6127
|
+
});
|
|
6128
|
+
}
|
|
6129
|
+
if (node.type.name === "columnGroup" && node.attrs.backgroundImage) {
|
|
6130
|
+
assets.push({
|
|
6131
|
+
assetId: null,
|
|
6132
|
+
currentUrl: node.attrs.backgroundImage,
|
|
6133
|
+
nodeType: "columnGroup"
|
|
6134
|
+
});
|
|
6135
|
+
}
|
|
6136
|
+
if (node.type.name === "video" && node.attrs.src) {
|
|
6137
|
+
assets.push({
|
|
6138
|
+
assetId: null,
|
|
6139
|
+
currentUrl: node.attrs.src,
|
|
6140
|
+
nodeType: "video"
|
|
6141
|
+
});
|
|
6142
|
+
}
|
|
6143
|
+
});
|
|
6144
|
+
return assets;
|
|
6145
|
+
}
|
|
6146
|
+
async function refreshAssets(editor, resolver) {
|
|
6147
|
+
const assets = getEditorAssets(editor);
|
|
6148
|
+
if (assets.length === 0) return;
|
|
6149
|
+
const urlMap = await resolver(assets);
|
|
6150
|
+
editor.commands.updateAssetUrls(urlMap);
|
|
6151
|
+
}
|
|
6152
|
+
|
|
6105
6153
|
// src/MarkView.ts
|
|
6106
6154
|
function updateMarkViewAttributes(checkMark, editor, attrs = {}) {
|
|
6107
6155
|
const { state } = editor;
|
|
@@ -6583,6 +6631,7 @@ var Tracker = class {
|
|
|
6583
6631
|
getAttributesFromExtensions,
|
|
6584
6632
|
getChangedRanges,
|
|
6585
6633
|
getDebugJSON,
|
|
6634
|
+
getEditorAssets,
|
|
6586
6635
|
getExtensionField,
|
|
6587
6636
|
getHTMLFromFragment,
|
|
6588
6637
|
getMarkAttributes,
|
|
@@ -6641,6 +6690,7 @@ var Tracker = class {
|
|
|
6641
6690
|
parseLayout,
|
|
6642
6691
|
pasteRulesPlugin,
|
|
6643
6692
|
posToDOMRect,
|
|
6693
|
+
refreshAssets,
|
|
6644
6694
|
registerTheme,
|
|
6645
6695
|
removeDuplicates,
|
|
6646
6696
|
renderNestedMarkdownContent,
|