mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-18 06:47:02 +08:00
refactor(editor): align rich text util apis (#11039)
This commit is contained in:
@@ -37,7 +37,7 @@ export const defaultSlashMenuConfig: SlashMenuConfig = {
|
||||
description: formatDate(now),
|
||||
group: '6_Date@0',
|
||||
action: ({ std, model }) => {
|
||||
insertContent(std.host, model, formatDate(now));
|
||||
insertContent(std, model, formatDate(now));
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -49,7 +49,7 @@ export const defaultSlashMenuConfig: SlashMenuConfig = {
|
||||
action: ({ std, model }) => {
|
||||
const tomorrow = new Date();
|
||||
tomorrow.setDate(tomorrow.getDate() + 1);
|
||||
insertContent(std.host, model, formatDate(tomorrow));
|
||||
insertContent(std, model, formatDate(tomorrow));
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -61,7 +61,7 @@ export const defaultSlashMenuConfig: SlashMenuConfig = {
|
||||
action: ({ std, model }) => {
|
||||
const yesterday = new Date();
|
||||
yesterday.setDate(yesterday.getDate() - 1);
|
||||
insertContent(std.host, model, formatDate(yesterday));
|
||||
insertContent(std, model, formatDate(yesterday));
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -71,7 +71,7 @@ export const defaultSlashMenuConfig: SlashMenuConfig = {
|
||||
description: formatTime(now),
|
||||
group: '6_Date@3',
|
||||
action: ({ std, model }) => {
|
||||
insertContent(std.host, model, formatTime(now));
|
||||
insertContent(std, model, formatTime(now));
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -56,7 +56,7 @@ export class SlashMenu extends WithDisposable(LitElement) {
|
||||
// We must to do clean the slash string before we do the action
|
||||
// Otherwise, the action may change the model and cause the slash string to be changed
|
||||
cleanSpecifiedTail(
|
||||
this.host,
|
||||
this.context.std,
|
||||
this.context.model,
|
||||
AFFINE_SLASH_MENU_TRIGGER_KEY + (this._query || '')
|
||||
);
|
||||
@@ -496,7 +496,7 @@ export class InnerSlashMenu extends WithDisposable(LitElement) {
|
||||
});
|
||||
|
||||
const inlineEditor = getInlineEditorByModel(
|
||||
this.context.std.host,
|
||||
this.context.std,
|
||||
this.context.model
|
||||
);
|
||||
|
||||
|
||||
@@ -39,10 +39,7 @@ const showSlashMenu = debounce(
|
||||
disposables.dispose()
|
||||
);
|
||||
|
||||
const inlineEditor = getInlineEditorByModel(
|
||||
context.std.host,
|
||||
context.model
|
||||
);
|
||||
const inlineEditor = getInlineEditorByModel(context.std, context.model);
|
||||
if (!inlineEditor) return;
|
||||
const slashMenu = new SlashMenu(inlineEditor, abortController);
|
||||
disposables.add(() => slashMenu.remove());
|
||||
@@ -84,7 +81,7 @@ export class AffineSlashMenuWidget extends WidgetComponent {
|
||||
const model = this.host.doc.getBlock(textSelection.blockId)?.model;
|
||||
if (!model) return;
|
||||
|
||||
return getInlineEditorByModel(this.host, model);
|
||||
return getInlineEditorByModel(this.std, model);
|
||||
};
|
||||
|
||||
private readonly _handleInput = (
|
||||
|
||||
Reference in New Issue
Block a user