Skip to content

Commit

Permalink
chore(editor): update AiActionExecutor and main.ts
Browse files Browse the repository at this point in the history
- Update AiActionExecutor to handle editor null check
- Add OutputForm, PromptCompiler, and BuiltinFunctionExecutor to main.ts
  • Loading branch information
phodal committed Sep 23, 2024
1 parent 603206d commit 99e3b2a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion web/core/lib/editor/action/AiActionExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class AiActionExecutor {
* TODO: will according the {@link PromptAction.useModel} to return the endpoint in future
* @param action
*/
endpoint(action: PromptAction) {
endpoint(_action: PromptAction) {
return this.endpointUrl;
}

Expand Down Expand Up @@ -63,6 +63,11 @@ export class AiActionExecutor {
})
);

if (this.editor == null) {
console.error('editor is not, can not insert content');
return;
}

const pos = actionPosition(action, this.editor.state.selection);
this.editor.chain().focus()?.insertContentAt(pos, buffer).run();

Expand Down
3 changes: 3 additions & 0 deletions web/core/lib/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ export { AdviceManager } from '@/editor/extensions/advice/advice-manager';
export { AdviceView } from '@/editor/extensions/advice/advice-view';
export { Settings } from '@/editor/components/settings';
export { AiActionExecutor } from '@/editor/action/AiActionExecutor.ts';
export { OutputForm } from '@/editor/defs/custom-action.type';
export { actionPosition, PromptCompiler } from '@/editor/action/PromptCompiler';
export { BuiltinFunctionExecutor } from '@/editor/action/BuiltinFunctionExecutor';

0 comments on commit 99e3b2a

Please sign in to comment.