refactor(editor): align rich text util apis (#11039)

This commit is contained in:
Saul-Mirone
2025-03-20 10:40:11 +00:00
parent 77e659d0b0
commit 66ea3038af
18 changed files with 57 additions and 73 deletions
@@ -15,7 +15,7 @@ export const splitParagraphCommand: Command<
}
> = (ctx, next) => {
const { std } = ctx;
const { store, host, selection } = std;
const { store, selection } = std;
let blockId = ctx.blockId;
if (!blockId) {
const text = selection.find(TextSelection);
@@ -26,7 +26,7 @@ export const splitParagraphCommand: Command<
const model = store.getBlock(blockId)?.model;
if (!model || !matchModels(model, [ParagraphBlockModel])) return;
const inlineEditor = getInlineEditorByModel(host, model);
const inlineEditor = getInlineEditorByModel(std, model);
const range = inlineEditor?.getInlineRange();
if (!range) return;
@@ -83,10 +83,7 @@ export const ParagraphKeymapExtension = KeymapExtension(
matchModels(model.parent, [CalloutBlockModel])
)
return;
const inlineEditor = getInlineEditorByModel(
std.host,
text.from.blockId
);
const inlineEditor = getInlineEditorByModel(std, text.from.blockId);
const inlineRange = inlineEditor?.getInlineRange();
if (!inlineRange || !inlineEditor) return;
const raw = ctx.get('keyboardState').raw;
@@ -115,10 +112,7 @@ export const ParagraphKeymapExtension = KeymapExtension(
matchModels(model.parent, [CalloutBlockModel])
)
return;
const inlineEditor = getInlineEditorByModel(
std.host,
text.from.blockId
);
const inlineEditor = getInlineEditorByModel(std, text.from.blockId);
const inlineRange = inlineEditor?.getInlineRange();
if (!inlineRange || !inlineEditor) return;
@@ -77,7 +77,7 @@ export function mergeWithPrev(editorHost: EditorHost, model: BlockModel) {
doc.deleteBlock(model, {
bringChildrenTo: parent,
});
asyncSetInlineRange(editorHost, prevBlock, {
asyncSetInlineRange(editorHost.std, prevBlock, {
index: lengthBeforeJoin,
length: 0,
}).catch(console.error);