fix(core): doc reference error in ai answer (#13141)

Close [AI-303](https://linear.app/affine-design/issue/AI-303)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Introduced a new AI configuration hook to streamline AI-related
features and integrations.
* Integrated enhanced AI specifications into chat components for
improved AI chat experiences.

* **Refactor**
* Updated chat panels to use the new AI configuration hook, simplifying
extension management and improving maintainability.

* **Chores**
* Improved options handling in the editor view extension for more
flexible configuration.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Wu Yue
2025-07-10 19:44:30 +08:00
committed by GitHub
parent f655e6e8bf
commit 9d5c7dd1e9
4 changed files with 80 additions and 15 deletions
@@ -44,6 +44,8 @@ const optionsSchema = z.object({
.args(z.custom<ConfirmModalProps>().optional(), z.any().optional()),
closeConfirmModal: z.function(),
}),
scope: z.enum(['doc', 'workspace']).optional(),
});
export type AffineEditorViewOptions = z.infer<typeof optionsSchema>;
@@ -93,16 +95,7 @@ export class AffineEditorViewExtension extends ViewExtensionProvider<AffineEdito
if (!options) {
return;
}
const {
framework,
reactToLit,
confirmModal,
} = options;
const docService = framework.get(DocService);
const docsService = framework.get(DocsService);
const editorService = framework.get(EditorService);
const { framework, reactToLit, confirmModal, scope = 'doc' } = options;
const referenceRenderer = this._getCustomReferenceRenderer(framework);
@@ -112,12 +105,20 @@ export class AffineEditorViewExtension extends ViewExtensionProvider<AffineEdito
patchNotificationService(confirmModal),
patchOpenDocExtension(),
patchSideBarService(framework),
patchDocModeService(docService, docsService, editorService),
patchFileSizeLimitExtension(framework),
buildDocDisplayMetaExtension(framework),
patchForAudioEmbedView(reactToLit),
])
.register(patchDocUrlExtensions(framework))
.register(patchQuickSearchService(framework));
if (scope === 'doc') {
const docService = framework.get(DocService);
const docsService = framework.get(DocsService);
const editorService = framework.get(EditorService);
context.register([
patchDocModeService(docService, docsService, editorService),
]);
}
}
}