mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
chore(editor): rename std.doc to std.store (#9596)
This commit is contained in:
@@ -71,7 +71,7 @@ export class FileDropExtension extends LifeCycleWatcher {
|
||||
let result: DropResult | null = null;
|
||||
if (element) {
|
||||
const model = element.model;
|
||||
const parent = this.std.doc.getParent(model);
|
||||
const parent = this.std.store.getParent(model);
|
||||
if (!matchFlavours(parent, ['affine:surface' as BlockSuite.Flavour])) {
|
||||
result = calcDropTarget(point, model, element);
|
||||
}
|
||||
@@ -119,7 +119,7 @@ export class FileDropExtension extends LifeCycleWatcher {
|
||||
}
|
||||
|
||||
get doc() {
|
||||
return this.std.doc;
|
||||
return this.std.store;
|
||||
}
|
||||
|
||||
get editorHost(): EditorHost {
|
||||
@@ -155,7 +155,7 @@ export class FileDropExtension extends LifeCycleWatcher {
|
||||
let result: DropResult | null = null;
|
||||
if (element) {
|
||||
const model = element.model;
|
||||
const parent = this.std.doc.getParent(model);
|
||||
const parent = this.std.store.getParent(model);
|
||||
if (!matchFlavours(parent, ['affine:surface' as BlockSuite.Flavour])) {
|
||||
result = calcDropTarget(point, model, element);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { toast } from '../toast/toast.js';
|
||||
|
||||
function notify(std: BlockStdScope, title: string, message: string) {
|
||||
const notification = std.getOptional(NotificationProvider);
|
||||
const { doc, host } = std;
|
||||
const { store: doc, host } = std;
|
||||
|
||||
if (!notification) {
|
||||
toast(host, title);
|
||||
|
||||
@@ -39,7 +39,7 @@ export function getInlineEditorByModel(
|
||||
) {
|
||||
const blockModel =
|
||||
typeof model === 'string'
|
||||
? editorHost.std.doc.getBlock(model)?.model
|
||||
? editorHost.std.store.getBlock(model)?.model
|
||||
: model;
|
||||
if (!blockModel || matchFlavours(blockModel, ['affine:database'])) {
|
||||
// Not support database model since it's may be have multiple inline editor instances.
|
||||
|
||||
@@ -62,7 +62,7 @@ export const deleteTextCommand: Command<
|
||||
selectedElements
|
||||
.filter(el => el.model.id !== fromElement.model.id)
|
||||
.forEach(el => {
|
||||
ctx.std.doc.deleteBlock(el.model, {
|
||||
ctx.std.store.deleteBlock(el.model, {
|
||||
bringChildrenTo:
|
||||
el.model.id === toElement.model.id ? fromElement.model : undefined,
|
||||
});
|
||||
|
||||
@@ -38,7 +38,7 @@ export class ReferenceNodeConfigProvider {
|
||||
}
|
||||
|
||||
get doc() {
|
||||
return this.std.doc;
|
||||
return this.std.store;
|
||||
}
|
||||
|
||||
get hidePopup() {
|
||||
|
||||
@@ -41,7 +41,7 @@ export const textCommonKeymap = (
|
||||
const text = std.selection.find(TextSelection);
|
||||
if (!text) return;
|
||||
|
||||
const model = std.doc.getBlock(text.from.blockId)?.model;
|
||||
const model = std.store.getBlock(text.from.blockId)?.model;
|
||||
if (!model || !model.text) return;
|
||||
|
||||
ctx.get('keyboardState').raw.preventDefault();
|
||||
@@ -62,7 +62,7 @@ export const textCommonKeymap = (
|
||||
const blockId = blocks.at(-1)?.blockId;
|
||||
|
||||
if (!blockId) return;
|
||||
const model = std.doc.getBlock(blockId)?.model;
|
||||
const model = std.store.getBlock(blockId)?.model;
|
||||
if (!model || !model.text) return;
|
||||
|
||||
ctx.get('keyboardState').raw.preventDefault();
|
||||
|
||||
@@ -21,7 +21,7 @@ export const bracketKeymap = (
|
||||
return {
|
||||
...acc,
|
||||
[pair.right]: ctx => {
|
||||
const { doc, selection } = std;
|
||||
const { store: doc, selection } = std;
|
||||
if (doc.readonly) return;
|
||||
|
||||
const textSelection = selection.find(TextSelection);
|
||||
@@ -47,7 +47,7 @@ export const bracketKeymap = (
|
||||
}
|
||||
},
|
||||
[pair.left]: ctx => {
|
||||
const { doc, selection } = std;
|
||||
const { store: doc, selection } = std;
|
||||
if (doc.readonly) return;
|
||||
|
||||
const textSelection = selection.find(TextSelection);
|
||||
@@ -98,7 +98,7 @@ export const bracketKeymap = (
|
||||
return {
|
||||
...keymap,
|
||||
'`': ctx => {
|
||||
const { doc, selection } = std;
|
||||
const { store: doc, selection } = std;
|
||||
if (doc.readonly) return;
|
||||
|
||||
const textSelection = selection.find(TextSelection);
|
||||
@@ -128,7 +128,7 @@ export const bracketKeymap = (
|
||||
};
|
||||
|
||||
function tryConvertToLinkedDoc(std: BlockStdScope, inlineEditor: InlineEditor) {
|
||||
const root = std.doc.root;
|
||||
const root = std.store.root;
|
||||
if (!root) return false;
|
||||
const linkedDocWidgetEle = std.view.getWidget(
|
||||
'affine-linked-doc-widget',
|
||||
@@ -154,7 +154,7 @@ function tryConvertToLinkedDoc(std: BlockStdScope, inlineEditor: InlineEditor) {
|
||||
});
|
||||
inlineEditor.setInlineRange({ index: inlineRange.index - 1, length: 0 });
|
||||
|
||||
const doc = createDefaultDoc(std.doc.workspace, {
|
||||
const doc = createDefaultDoc(std.store.workspace, {
|
||||
title: docName,
|
||||
});
|
||||
insertLinkedNode({
|
||||
|
||||
@@ -14,7 +14,7 @@ export const textFormatKeymap = (std: BlockStdScope) =>
|
||||
return {
|
||||
...acc,
|
||||
[config.hotkey as string]: ctx => {
|
||||
const { doc, selection } = std;
|
||||
const { store: doc, selection } = std;
|
||||
if (doc.readonly) return;
|
||||
|
||||
const textSelection = selection.find(TextSelection);
|
||||
|
||||
@@ -10,7 +10,7 @@ export function toDivider(
|
||||
model: BlockModel,
|
||||
prefix: string
|
||||
) {
|
||||
const { doc } = std;
|
||||
const { store: doc } = std;
|
||||
if (
|
||||
matchFlavours(model, ['affine:divider']) ||
|
||||
(matchFlavours(model, ['affine:paragraph']) && model.type === 'quote')
|
||||
|
||||
@@ -16,7 +16,7 @@ export function toList(
|
||||
if (!matchFlavours(model, ['affine:paragraph'])) {
|
||||
return;
|
||||
}
|
||||
const { doc } = std;
|
||||
const { store: doc } = std;
|
||||
const parent = doc.getParent(model);
|
||||
if (!parent) return;
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ export function markdownInput(
|
||||
id = text?.from.blockId;
|
||||
}
|
||||
if (!id) return;
|
||||
const model = std.doc.getBlock(id)?.model;
|
||||
const model = std.store.getBlock(id)?.model;
|
||||
if (!model) return;
|
||||
const inline = getInlineEditorByModel(std.host, model);
|
||||
if (!inline) return;
|
||||
|
||||
@@ -12,7 +12,7 @@ export function toParagraph(
|
||||
type: ParagraphType,
|
||||
prefix: string
|
||||
) {
|
||||
const { doc } = std;
|
||||
const { store: doc } = std;
|
||||
if (!matchFlavours(model, ['affine:paragraph'])) {
|
||||
const parent = doc.getParent(model);
|
||||
if (!parent) return;
|
||||
|
||||
@@ -34,6 +34,6 @@ export function beforeConvert(
|
||||
// *<space>| -> undo
|
||||
text.insert(' ', index);
|
||||
focusTextModel(std, model.id, index + 1);
|
||||
std.doc.captureSync();
|
||||
std.store.captureSync();
|
||||
text.delete(0, index + 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user