tiptapify 0.1.5 → 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 (43) hide show
  1. package/README.md +1 -1
  2. package/dist/tiptapify.css +1 -1
  3. package/dist/tiptapify.mjs +30351 -26471
  4. package/dist/tiptapify.umd.js +57 -52
  5. package/index.d.ts +71 -1
  6. package/package.json +52 -45
  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 +9 -3
  11. package/src/components/index.ts +4 -3
  12. package/src/constants/style.test.ts +49 -0
  13. package/src/extensions/PickerEventBus.test.ts +38 -0
  14. package/src/extensions/components/ai/Button.vue +42 -0
  15. package/src/extensions/components/ai/Dialog.vue +262 -0
  16. package/src/extensions/components/media/link/LinkDialog.vue +5 -5
  17. package/src/i18n/locales/ar.json +29 -0
  18. package/src/i18n/locales/ch.json +29 -0
  19. package/src/i18n/locales/cz.json +29 -0
  20. package/src/i18n/locales/de.json +29 -0
  21. package/src/i18n/locales/en.json +29 -0
  22. package/src/i18n/locales/es.json +29 -0
  23. package/src/i18n/locales/fi.json +29 -0
  24. package/src/i18n/locales/fr.json +29 -0
  25. package/src/i18n/locales/hu.json +29 -0
  26. package/src/i18n/locales/it.json +29 -0
  27. package/src/i18n/locales/ja.json +29 -0
  28. package/src/i18n/locales/ko.json +29 -0
  29. package/src/i18n/locales/la.json +29 -0
  30. package/src/i18n/locales/lt.json +29 -0
  31. package/src/i18n/locales/nl.json +29 -0
  32. package/src/i18n/locales/pl.json +29 -0
  33. package/src/i18n/locales/pt.json +29 -0
  34. package/src/i18n/locales/ru.json +29 -0
  35. package/src/i18n/locales/se.json +29 -0
  36. package/src/i18n/locales/th.json +29 -0
  37. package/src/i18n/locales/tr.json +29 -0
  38. package/src/i18n/locales/uk.json +29 -0
  39. package/src/i18n/locales/vi.json +29 -0
  40. package/src/index.ts +15 -1
  41. package/src/types/editor.ts +74 -1
  42. package/src/types/toolbarTypes.ts +2 -1
  43. package/src/utils/helpers.test.ts +32 -0
@@ -172,5 +172,34 @@
172
172
  "footer": {
173
173
  "words": "単語数",
174
174
  "chars": "文字数"
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
  }
@@ -172,5 +172,34 @@
172
172
  "footer": {
173
173
  "words": "단어",
174
174
  "chars": "글자"
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
  }
@@ -172,5 +172,34 @@
172
172
  "footer": {
173
173
  "words": "vārdi",
174
174
  "chars": "zīmes"
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
  }
@@ -172,5 +172,34 @@
172
172
  "footer": {
173
173
  "words": "žodžiai",
174
174
  "chars": "simboliai"
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
  }
@@ -172,5 +172,34 @@
172
172
  "footer": {
173
173
  "words": "woorden",
174
174
  "chars": "tekens"
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
  }
@@ -172,5 +172,34 @@
172
172
  "footer": {
173
173
  "words": "słowa",
174
174
  "chars": "znaki"
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
  }
@@ -172,5 +172,34 @@
172
172
  "footer": {
173
173
  "words": "palavras",
174
174
  "chars": "caracteres"
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
  }
@@ -172,5 +172,34 @@
172
172
  "footer": {
173
173
  "words": "слова",
174
174
  "chars": "символы"
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
  }
@@ -172,5 +172,34 @@
172
172
  "footer": {
173
173
  "words": "ord",
174
174
  "chars": "tecken"
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
  }
@@ -172,5 +172,34 @@
172
172
  "footer": {
173
173
  "words": "คำ",
174
174
  "chars": "ตัวอักษร"
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
  }
@@ -172,5 +172,34 @@
172
172
  "footer": {
173
173
  "words": "kelime",
174
174
  "chars": "karakter"
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
  }
@@ -172,5 +172,34 @@
172
172
  "footer": {
173
173
  "words": "слова",
174
174
  "chars": "символи"
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
  }
@@ -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[]
@@ -0,0 +1,32 @@
1
+ import { describe, it, expect } from 'vitest'
2
+ import helpers from './helpers'
3
+
4
+ describe('ucFirst', () => {
5
+ it('capitalizes the first character of a string', () => {
6
+ expect(helpers.ucFirst('hello')).toBe('Hello')
7
+ })
8
+
9
+ it('returns empty string for empty input', () => {
10
+ expect(helpers.ucFirst('')).toBe('')
11
+ })
12
+
13
+ it('converts snake_case to words and capitalizes', () => {
14
+ expect(helpers.ucFirst('hello_world', true)).toBe('Hello world')
15
+ })
16
+
17
+ it('converts kebab-case to words and capitalizes', () => {
18
+ expect(helpers.ucFirst('hello-world', false, true)).toBe('Hello world')
19
+ })
20
+
21
+ it('converts both snake_case and kebab-case', () => {
22
+ expect(helpers.ucFirst('hello_world-test', true, true)).toBe('Hello world test')
23
+ })
24
+
25
+ it('handles already capitalized string', () => {
26
+ expect(helpers.ucFirst('Hello')).toBe('Hello')
27
+ })
28
+
29
+ it('handles single character', () => {
30
+ expect(helpers.ucFirst('a')).toBe('A')
31
+ })
32
+ })