Skip to content

Commit

Permalink
refactor: rename gpt to ask
Browse files Browse the repository at this point in the history
  • Loading branch information
lynhan318 committed Feb 25, 2024
1 parent 41425ab commit 83dbe8e
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/little-ears-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@nextlint/svelte': major
---

rename gpt plugin to ask
6 changes: 3 additions & 3 deletions packages/svelte/src/lib/Editor.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts" context="module">
export type PluginOptions = {
image?: ImagePluginOptions;
gpt?: GPTOptions;
ask?: AskOptions;
dropCursor?: DropcursorOptions;
};
</script>
Expand All @@ -12,7 +12,7 @@
import {LinkExtension} from '$lib/plugins/link';
import {NextlintCodeBlock} from '$lib/plugins/codeBlock';
import {PluginGPT, type GPTOptions} from '$lib/plugins/gpt';
import {PluginAsk, type AskOptions} from '$lib/plugins/ask';
import {FigureExtension} from '$lib/plugins/figure';
import {
SelectImageExtension,
Expand Down Expand Up @@ -58,7 +58,7 @@
BubbleMenuExtension.configure({
component: BubbleMenu
}),
plugins.gpt && PluginGPT.configure(plugins.gpt)
plugins.ask && PluginAsk.configure(plugins.ask)
]
.concat(extensions)
.filter(Boolean)
Expand Down
1 change: 1 addition & 0 deletions packages/svelte/src/lib/plugins/ask/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './plugin-ask';
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import {Plugin, PluginKey} from '@tiptap/pm/state';

import {Renderer} from './Renderer';

export interface GPTOptions {
export interface AskOptions {
query: (question: string) => Promise<string>;
}

export const PluginGPT = Node.create<GPTOptions>({
name: 'openAI',
export const PluginAsk = Node.create<AskOptions>({
name: 'ask',

addProseMirrorPlugins() {
const renderer = new Renderer(this.editor.view, this.editor, this.options);
return [
new Plugin<{isEmpty: boolean}>({
key: new PluginKey('openAI'),
key: new PluginKey('ask'),
state: {
apply: (tr, prev, oldState, state) => {
const node = state.selection.$head.node(1);
Expand Down
1 change: 0 additions & 1 deletion packages/svelte/src/lib/plugins/gpt/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/svelte/src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ This is NOT a component library. It's a collection of re-usable components that
},
triggerOnMount: false
},
gpt: {query: submitPromt}
ask: {query: submitPromt}
}}
/>
</div>

0 comments on commit 83dbe8e

Please sign in to comment.