Skip to content

Commit 289cf4c

Browse files
committed
feat: support upgrade AI Max
1 parent 8c9d531 commit 289cf4c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+925
-469
lines changed

cypress.config.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
import { defineConfig } from 'cypress';
2-
import registerCodeCoverageTasks from '@cypress/code-coverage/task';
3-
4-
import { addMatchImageSnapshotPlugin } from 'cypress-image-snapshot/plugin';
52

63
export default defineConfig({
74
env: {
@@ -16,8 +13,6 @@ export default defineConfig({
1613
bundler: 'vite',
1714
},
1815
setupNodeEvents(on, config) {
19-
registerCodeCoverageTasks(on, config);
20-
addMatchImageSnapshotPlugin(on, config);
2116
return config;
2217
},
2318
supportFile: 'cypress/support/component.ts',

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
"coverage": "pnpm run test:unit && pnpm run test:components"
1919
},
2020
"dependencies": {
21-
"@appflowyinc/ai-chat": "0.0.18",
22-
"@appflowyinc/editor": "^0.1.6",
21+
"@appflowyinc/ai-chat": "0.1.24",
22+
"@appflowyinc/editor": "^0.1.10",
2323
"@atlaskit/primitives": "^5.5.3",
2424
"@emoji-mart/data": "^1.1.2",
2525
"@emoji-mart/react": "^1.1.1",

pnpm-lock.yaml

Lines changed: 13 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/@types/translations/en.json

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2983,6 +2983,21 @@
29832983
"priceIn": "Price in ",
29842984
"free": "Free",
29852985
"pro": "Pro",
2986+
"getAIMax": "Get AI Max",
2987+
"upgradeAIMax": "Upgrade to AI Max",
2988+
"unlock": "Unlock",
2989+
"AIMax": {
2990+
"label": "AI Max",
2991+
"removeTitle": "Remove AI Max",
2992+
"removeDescription": "Are you sure you want to remove AI Max? You will lose access to the features and benefits of AI Max immediately.",
2993+
"description": "Access the most advanced AI models including GPT-4o, GPT-o3-mini, DeepSeek R1, and Claude 3.5 Sonnet",
2994+
"pricing": "per member per month\nbilled annually",
2995+
"points": {
2996+
"first": "Unlimited AI responses",
2997+
"second": "Unlimited file uploads",
2998+
"third": "50 AI images per month"
2999+
}
3000+
},
29863001
"freeDescription": "For individuals up to 2 members to organize everything",
29873002
"proDescription": "For small teams to manage projects and team knowledge",
29883003
"proDuration": {
@@ -3000,15 +3015,17 @@
30003015
"three": "5 GB storage",
30013016
"four": "Intelligent search",
30023017
"five": "10 AI responses",
3003-
"six": "Mobile app",
3004-
"seven": "Real-time collaboration"
3018+
"six": "2 AI images",
3019+
"seven": "Mobile app",
3020+
"eight": "Real-time collaboration"
30053021
},
30063022
"proPoints": {
30073023
"first": "Unlimited storage",
30083024
"second": "Up to 10 workspace members",
30093025
"three": "Unlimited AI responses",
3010-
"four": "Unlimited file uploads",
3011-
"five": "Custom namespace"
3026+
"four": "10 AI images per month",
3027+
"five": "Unlimited file uploads",
3028+
"six": "Custom namespace"
30123029
},
30133030
"cancelPlan": {
30143031
"title": "Sorry to see you go",

src/application/slate-yjs/command/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,12 @@ export const CustomEditor = {
5353
}).join('\n');
5454
},
5555

56-
getSelectionContent(editor: YjsEditor) {
57-
const range = editor.selection;
56+
getSelectionContent(editor: YjsEditor, range?: Range) {
57+
const at = range || editor.selection;
5858

59-
if(!range) return '';
60-
return editor.string(range);
59+
if(!at) return '';
60+
61+
return editor.string(at);
6162
},
6263
// Get the text content of a block node, including the text content of its children and formula nodes
6364
getBlockTextContent(node: Node, depth: number = Infinity): string {

src/application/slate-yjs/utils/applyToSlate.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ export function translateYEvents(editor: YjsEditor, events: Array<YEvent>) {
1717

1818
events.forEach((event) => {
1919
console.log(event.path);
20-
if (isEqual(event.path, ['document', 'blocks'])) {
20+
if(isEqual(event.path, ['document', 'blocks'])) {
2121
applyBlocksYEvent(editor, event as BlockMapEvent);
2222
}
2323

24-
if (isEqual((event.path), ['document', 'blocks', event.path[2]])) {
24+
if(isEqual((event.path), ['document', 'blocks', event.path[2]])) {
2525
const blockId = event.path[2] as string;
2626

2727
applyUpdateBlockYEvent(editor, blockId, event as YMapEvent<unknown>);
2828
}
2929

30-
if (isEqual(event.path, ['document', 'meta', 'text_map', event.path[3]])) {
30+
if(isEqual(event.path, ['document', 'meta', 'text_map', event.path[3]])) {
3131
const textId = event.path[3] as string;
3232

3333
applyTextYEvent(editor, textId, event as YTextEvent);
@@ -42,7 +42,7 @@ function applyUpdateBlockYEvent(editor: YjsEditor, blockId: string, event: YMapE
4242
const newData = dataStringTOJson(block.get(YjsEditorKey.block_data));
4343
const entry = findSlateEntryByBlockId(editor, blockId);
4444

45-
if (!entry) {
45+
if(!entry) {
4646
console.error('Block node not found', blockId);
4747
return [];
4848
}
@@ -75,7 +75,7 @@ function applyTextYEvent(editor: YjsEditor, textId: string, event: YTextEvent) {
7575
});
7676

7777
console.log('=== Applying text Yjs event ===', entry);
78-
if (!entry) {
78+
if(!entry) {
7979
console.error('Text node not found', textId);
8080
return [];
8181
}
@@ -107,14 +107,14 @@ function applyBlocksYEvent(editor: YjsEditor, event: BlockMapEvent) {
107107
keysChanged.forEach((key: string) => {
108108
const value = keys.get(key);
109109

110-
if (!value) return;
110+
if(!value) return;
111111

112-
if (value.action === 'add') {
112+
if(value.action === 'add') {
113113
handleNewBlock(editor, key, keyPath);
114114

115-
} else if (value.action === 'delete') {
115+
} else if(value.action === 'delete') {
116116
handleDeleteNode(editor, key);
117-
} else if (value.action === 'update') {
117+
} else if(value.action === 'update') {
118118
console.log('=== Applying block update Yjs event ===', key);
119119
}
120120
});
@@ -127,7 +127,7 @@ function handleNewBlock(editor: YjsEditor, key: string, keyPath: Record<string,
127127
const pageId = getPageId(editor.sharedRoot);
128128
const parent = getBlock(parentId, editor.sharedRoot);
129129

130-
if (!parent) {
130+
if(!parent) {
131131
console.error('Parent block not found', parentId, block.toJSON());
132132
return;
133133
}
@@ -139,11 +139,11 @@ function handleNewBlock(editor: YjsEditor, key: string, keyPath: Record<string,
139139
const yText = getText(textId, editor.sharedRoot);
140140
let textNode: Element | undefined;
141141

142-
if (yText) {
142+
if(yText) {
143143
const delta = yText?.toDelta();
144144
const slateDelta = delta.flatMap(deltaInsertToSlateNode);
145145

146-
if (slateDelta.length === 0) {
146+
if(slateDelta.length === 0) {
147147
slateDelta.push({
148148
text: '',
149149
});
@@ -158,15 +158,15 @@ function handleNewBlock(editor: YjsEditor, key: string, keyPath: Record<string,
158158

159159
let path = [index];
160160

161-
if (parentId !== pageId) {
161+
if(parentId !== pageId) {
162162
const [parentEntry] = editor.nodes({
163163
match: (n) => !Editor.isEditor(n) && Element.isElement(n) && n.blockId === parentId,
164164
mode: 'all',
165165
at: [],
166166
});
167167

168-
if (!parentEntry) {
169-
if (keyPath[parentId]) {
168+
if(!parentEntry) {
169+
if(keyPath[parentId]) {
170170
path = [...keyPath[parentId], index + 1];
171171
} else {
172172
console.error('Parent block not found', parentId);
@@ -198,7 +198,7 @@ function handleDeleteNode(editor: YjsEditor, key: string) {
198198
match: (n) => !Editor.isEditor(n) && Element.isElement(n) && n.blockId === key,
199199
});
200200

201-
if (!entry) {
201+
if(!entry) {
202202
console.error('Block not found');
203203
return [];
204204
}

0 commit comments

Comments
 (0)