tiptapify 0.1.6 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +1 -1
  2. package/dist/tiptapify.css +1 -1
  3. package/dist/tiptapify.mjs +25885 -22016
  4. package/dist/tiptapify.umd.js +55 -50
  5. package/index.d.ts +70 -1
  6. package/package.json +2 -2
  7. package/src/components/Tiptapify.vue +38 -1
  8. package/src/components/Toolbar/ai.ts +13 -0
  9. package/src/components/Toolbar/items.ts +2 -0
  10. package/src/components/editorExtensions.ts +7 -3
  11. package/src/components/index.ts +4 -3
  12. package/src/extensions/components/ai/Button.vue +42 -0
  13. package/src/extensions/components/ai/Dialog.vue +262 -0
  14. package/src/i18n/locales/ar.json +29 -0
  15. package/src/i18n/locales/ch.json +29 -0
  16. package/src/i18n/locales/cz.json +29 -0
  17. package/src/i18n/locales/de.json +29 -0
  18. package/src/i18n/locales/en.json +29 -0
  19. package/src/i18n/locales/es.json +29 -0
  20. package/src/i18n/locales/fi.json +29 -0
  21. package/src/i18n/locales/fr.json +29 -0
  22. package/src/i18n/locales/hu.json +29 -0
  23. package/src/i18n/locales/it.json +29 -0
  24. package/src/i18n/locales/ja.json +29 -0
  25. package/src/i18n/locales/ko.json +29 -0
  26. package/src/i18n/locales/la.json +29 -0
  27. package/src/i18n/locales/lt.json +29 -0
  28. package/src/i18n/locales/nl.json +29 -0
  29. package/src/i18n/locales/pl.json +29 -0
  30. package/src/i18n/locales/pt.json +29 -0
  31. package/src/i18n/locales/ru.json +29 -0
  32. package/src/i18n/locales/se.json +29 -0
  33. package/src/i18n/locales/th.json +29 -0
  34. package/src/i18n/locales/tr.json +29 -0
  35. package/src/i18n/locales/uk.json +29 -0
  36. package/src/i18n/locales/vi.json +29 -0
  37. package/src/index.ts +15 -1
  38. package/src/types/editor.ts +74 -1
  39. package/src/types/toolbarTypes.ts +2 -1
@@ -172,5 +172,34 @@
172
172
  "footer": {
173
173
  "words": "từ ngữ",
174
174
  "chars": "ký tự"
175
+ },
176
+ "ai": {
177
+ "title": "AI assistant",
178
+ "prompt": "Prompt",
179
+ "examples": "Examples",
180
+ "generate": "Generate",
181
+ "apply": "Apply",
182
+ "result": "Result",
183
+ "loading": "Generating...",
184
+ "unavailable": "Configure an AI provider to use this action",
185
+ "error": "AI generation failed",
186
+ "defaultExamples": {
187
+ "improve": {
188
+ "title": "Improve writing",
189
+ "prompt": "Improve the clarity and tone of this text."
190
+ },
191
+ "proofReading": {
192
+ "title": "Proof-reading",
193
+ "prompt": "Correct grammar, spelling, and punctuation without changing the meaning."
194
+ },
195
+ "summarize": {
196
+ "title": "Summarize",
197
+ "prompt": "Summarize this text in a concise paragraph."
198
+ },
199
+ "expand": {
200
+ "title": "Expand",
201
+ "prompt": "Expand this into a more detailed version."
202
+ }
203
+ }
175
204
  }
176
205
  }
package/src/index.ts CHANGED
@@ -40,4 +40,18 @@ export {
40
40
  mergeAttributes,
41
41
  }
42
42
 
43
- export type { CommandProps, InputRuleMatch, PasteRuleMatch }
43
+ export type { CommandProps, InputRuleMatch, PasteRuleMatch }
44
+ export type {
45
+ TiptapifyAiMode,
46
+ TiptapifyAiOptions,
47
+ TiptapifyAiChatMessage,
48
+ TiptapifyAiChatRole,
49
+ TiptapifyAiEditorContext,
50
+ TiptapifyAiOpenAiResponse,
51
+ TiptapifyAiPromptExample,
52
+ TiptapifyAiProvider,
53
+ TiptapifyAiRequest,
54
+ TiptapifyAiResponse,
55
+ TiptapifyAiStorage,
56
+ TiptapifyAiTokenProvider,
57
+ } from '@tiptapify/types/editor'
@@ -7,4 +7,77 @@ declare class TiptapifyEditor extends Editor {
7
7
  export { TiptapifyEditor }
8
8
 
9
9
  export type variantBtnTypes = 'outlined' | 'plain' | 'flat' | 'text' | 'elevated' | 'tonal' | undefined
10
- export type variantFieldTypes = 'outlined' | 'plain' | 'filled' | 'solo' | 'solo-filled' | 'solo-inverted' | 'underlined' | undefined
10
+ export type variantFieldTypes = 'outlined' | 'plain' | 'filled' | 'solo' | 'solo-filled' | 'solo-inverted' | 'underlined' | undefined
11
+
12
+ export type TiptapifyAiMode = 'insert' | 'replace' | 'append'
13
+
14
+ export type TiptapifyAiPromptExample = {
15
+ title: string,
16
+ prompt: string,
17
+ }
18
+
19
+ export type TiptapifyAiChatRole = 'system' | 'user' | 'assistant' | 'developer' | 'tool'
20
+
21
+ export type TiptapifyAiChatMessage = {
22
+ role: TiptapifyAiChatRole,
23
+ content: string,
24
+ }
25
+
26
+ export type TiptapifyAiEditorContext = {
27
+ prompt: string,
28
+ selectedText: string,
29
+ text: string,
30
+ html: string,
31
+ json: object,
32
+ mode: TiptapifyAiMode,
33
+ }
34
+
35
+ export type TiptapifyAiRequest = {
36
+ model?: string,
37
+ messages: TiptapifyAiChatMessage[],
38
+ temperature?: number,
39
+ stream?: false,
40
+ [key: string]: unknown,
41
+ }
42
+
43
+ export type TiptapifyAiResponse = {
44
+ content: string,
45
+ }
46
+
47
+ export type TiptapifyAiOpenAiResponse = {
48
+ choices?: Array<{
49
+ message?: {
50
+ content?: string,
51
+ },
52
+ text?: string,
53
+ }>,
54
+ }
55
+
56
+ export type TiptapifyAiProvider = (request: TiptapifyAiRequest, context: TiptapifyAiEditorContext) => Promise<TiptapifyAiResponse | TiptapifyAiOpenAiResponse | string>
57
+
58
+ export type TiptapifyAiTokenProvider = () => Promise<string | null> | string | null
59
+
60
+ export type TiptapifyAiStorage = {
61
+ getItem: (key: string) => string | null | Promise<string | null>,
62
+ setItem: (key: string, value: string) => void | Promise<void>,
63
+ removeItem: (key: string) => void | Promise<void>,
64
+ }
65
+
66
+ export type TiptapifyAiOptions = {
67
+ aiProvider?: TiptapifyAiProvider,
68
+ model?: string,
69
+ promptExamples?: TiptapifyAiPromptExample[],
70
+ mode?: TiptapifyAiMode,
71
+ defaultPrompt?: string,
72
+ systemPrompt?: string,
73
+ temperature?: number,
74
+ chatCompletionOptions?: Record<string, unknown>,
75
+ createMessages?: (context: TiptapifyAiEditorContext) => TiptapifyAiChatMessage[],
76
+ tokenProvider?: TiptapifyAiTokenProvider,
77
+ storage?: TiptapifyAiStorage,
78
+ }
79
+
80
+ export type TiptapifyAiResolvedOptions = TiptapifyAiOptions & {
81
+ enabled: boolean,
82
+ promptExamples: TiptapifyAiPromptExample[],
83
+ }
@@ -2,6 +2,7 @@ import { Component } from 'vue'
2
2
 
3
3
  export enum ToolbarSectionsEnum {
4
4
  actions = 'actions',
5
+ ai = 'ai',
5
6
  alignment = 'alignment',
6
7
  extra = 'extra',
7
8
  formatExtra = 'formatExtra',
@@ -27,4 +28,4 @@ export type section = {
27
28
 
28
29
  export type toolbarSections = Array<section>
29
30
 
30
- export type itemsPropType = { [key: string]: string[] } | string[]
31
+ export type itemsPropType = { [key: string]: string[] } | string[]