Skip to content

Commit 9971061

Browse files
authored
feat: support publish (#7)
1 parent 4070e4f commit 9971061

File tree

30 files changed

+626
-196
lines changed

30 files changed

+626
-196
lines changed

cypress/support/document.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as Y from 'yjs';
66
export interface FromBlockJSON {
77
type: string;
88
children: FromBlockJSON[];
9-
data: Record<string, number | string | boolean>;
9+
data: Record<string, number | string | boolean | null>;
1010
text: Op[];
1111
}
1212

src/@types/translations/en.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@
307307
"openMenu": "Click to open menu",
308308
"dragRow": "Drag to reorder the row",
309309
"viewDataBase": "View database",
310-
"referencePage": "This {name} is referenced",
310+
"referencePage": "This {{name}} is referenced",
311311
"addBlockBelow": "Add a block below",
312312
"aiGenerate": "Generate"
313313
},
@@ -1524,7 +1524,7 @@
15241524
"cannotFindCreatableField": "Cannot find a suitable field to sort by",
15251525
"deleteAllSorts": "Delete all sorts",
15261526
"addSort": "Add sort",
1527-
"sortsActive": "Cannot {intention} while sorting",
1527+
"sortsActive": "Cannot {{intention}} while sorting",
15281528
"removeSorting": "Would you like to remove all the sorts in this view and continue?",
15291529
"fieldInUse": "You are already sorting by this field"
15301530
},
@@ -1734,7 +1734,7 @@
17341734
"toggleList": "Toggle list",
17351735
"emptyToggleHeading": "Empty toggle h{}. Click to add content.",
17361736
"emptyToggleList": "Empty toggle list. Click to add content.",
1737-
"emptyToggleHeadingWeb": "Empty toggle h{level}. Click to add content",
1737+
"emptyToggleHeadingWeb": "Empty toggle h{{level}}. Click to add content",
17381738
"quoteList": "Quote list",
17391739
"numberedList": "Numbered list",
17401740
"bulletedList": "Bulleted list",
@@ -2171,8 +2171,8 @@
21712171
},
21722172
"unSupportBlock": "The current version does not support this Block.",
21732173
"views": {
2174-
"deleteContentTitle": "Are you sure want to delete the {pageType}?",
2175-
"deleteContentCaption": "if you delete this {pageType}, you can restore it from the trash."
2174+
"deleteContentTitle": "Are you sure want to delete the {{pageType}}?",
2175+
"deleteContentCaption": "if you delete this {{pageType}}, you can restore it from the trash."
21762176
},
21772177
"colors": {
21782178
"custom": "Custom",
@@ -2678,8 +2678,8 @@
26782678
"signInError": "Sign in error",
26792679
"login": "Sign up or log in",
26802680
"fileBlock": {
2681-
"uploadedAt": "Uploaded on {time}",
2682-
"linkedAt": "Link added on {time}",
2681+
"uploadedAt": "Uploaded on {{time}}",
2682+
"linkedAt": "Link added on {{time}}",
26832683
"empty": "Upload or embed a file",
26842684
"uploadFailed": "Upload failed, please try again",
26852685
"retry": "Retry"
@@ -2747,7 +2747,7 @@
27472747
"featured": "PIN to Featured",
27482748
"relatedTemplates": "Related Templates",
27492749
"requiredField": "{field} is required",
2750-
"addCategory": "Add \"{category}\"",
2750+
"addCategory": "Add \"{{category}}\"",
27512751
"addNewCategory": "Add new category",
27522752
"addNewCreator": "Add new creator",
27532753
"deleteCategory": "Delete category",
@@ -2787,7 +2787,7 @@
27872787
"addRelatedTemplate": "Add related template",
27882788
"removeRelatedTemplate": "Remove related template",
27892789
"uploadAvatar": "Upload avatar",
2790-
"searchInCategory": "Search in {category}",
2790+
"searchInCategory": "Search in {{category}}",
27912791
"label": "Templates"
27922792
},
27932793
"fileDropzone": {
@@ -2825,7 +2825,7 @@
28252825
"alreadyAccepted": "You've already accepted the invitation",
28262826
"errorModal": {
28272827
"title": "Something went wrong",
2828-
"description": "Your current account {email} may not have access to this workspace. Please log in with the correct account or contact the workspace owner for help.",
2828+
"description": "Your current account {{email}} may not have access to this workspace. Please log in with the correct account or contact the workspace owner for help.",
28292829
"contactOwner": "Contact owner",
28302830
"close": "Back to home",
28312831
"changeAccount": "Change account"
@@ -2867,7 +2867,7 @@
28672867
},
28682868
"upgradePlanModal": {
28692869
"title": "Upgrade to Pro",
2870-
"message": "{name} has reached the free member limit. Upgrade to the Pro Plan to invite more members.",
2870+
"message": "{{name}} has reached the free member limit. Upgrade to the Pro Plan to invite more members.",
28712871
"upgradeSteps": "How to upgrade your plan on AppFlowy:",
28722872
"step1": "1. Go to Settings",
28732873
"step2": "2. Click on 'Plan'",
@@ -2947,7 +2947,7 @@
29472947
"upgrade": "upgrade",
29482948
29492949
"requestInvites": "Send invites",
2950-
"inviteAlready": "You've already invited this email: {email}",
2950+
"inviteAlready": "You've already invited this email: {{email}}",
29512951
"inviteSuccess": "Invitation sent successfully",
29522952
"description": "Input emails below with commas between them. Charges are based on member count.",
29532953
"emails": "Email"

src/application/services/js-services/http/http_api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ export async function getPublishView (publishNamespace: string, publishName: str
533533
}
534534

535535
export async function getPublishInfoWithViewId (viewId: string) {
536-
const url = `/api/workspace/published-info/${viewId}`;
536+
const url = `/api/workspace/v1/published-info/${viewId}`;
537537
const response = await axiosInstance?.get<{
538538
code: number;
539539
data?: {

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

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import {
4646

4747
export const CustomEditor = {
4848
// Get the text content of a block node, including the text content of its children and formula nodes
49-
getBlockTextContent(node: Node, depth: number = Infinity): string {
49+
getBlockTextContent (node: Node, depth: number = Infinity): string {
5050
if (Text.isText(node)) {
5151
if (node.formula) {
5252
return node.formula;
@@ -77,7 +77,7 @@ export const CustomEditor = {
7777
.join('');
7878
},
7979

80-
setBlockData<T = BlockData>(editor: YjsEditor, blockId: string, updateData: T, select?: boolean) {
80+
setBlockData<T = BlockData> (editor: YjsEditor, blockId: string, updateData: T, select?: boolean) {
8181

8282
if (editor.readOnly) {
8383
return;
@@ -118,7 +118,7 @@ export const CustomEditor = {
118118

119119
},
120120
// Insert break line at the specified path
121-
insertBreak(editor: YjsEditor, at?: BaseRange) {
121+
insertBreak (editor: YjsEditor, at?: BaseRange) {
122122
const sharedRoot = getSharedRoot(editor);
123123
const newAt = getSelectionOrThrow(editor, at);
124124

@@ -132,7 +132,7 @@ export const CustomEditor = {
132132

133133
},
134134

135-
deleteBlockBackward(editor: YjsEditor, at?: BaseRange) {
135+
deleteBlockBackward (editor: YjsEditor, at?: BaseRange) {
136136
console.trace('deleteBlockBackward', editor.selection, at);
137137

138138
const sharedRoot = getSharedRoot(editor);
@@ -172,7 +172,7 @@ export const CustomEditor = {
172172
}
173173
},
174174

175-
deleteBlockForward(editor: YjsEditor, at?: BaseRange) {
175+
deleteBlockForward (editor: YjsEditor, at?: BaseRange) {
176176
const sharedRoot = getSharedRoot(editor);
177177
const newAt = getSelectionOrThrow(editor, at);
178178

@@ -192,15 +192,15 @@ export const CustomEditor = {
192192
}
193193
},
194194

195-
deleteEntireDocument(editor: YjsEditor) {
195+
deleteEntireDocument (editor: YjsEditor) {
196196
handleDeleteEntireDocumentWithTxn(editor);
197197
},
198198

199-
removeRange(editor: YjsEditor, at: BaseRange) {
199+
removeRange (editor: YjsEditor, at: BaseRange) {
200200
removeRangeWithTxn(editor, getSharedRoot(editor), at);
201201
},
202202

203-
tabEvent(editor: YjsEditor, event: KeyboardEvent) {
203+
tabEvent (editor: YjsEditor, event: KeyboardEvent) {
204204
const type = event.shiftKey ? 'tabBackward' : 'tabForward';
205205
const sharedRoot = getSharedRoot(editor);
206206
const { selection } = editor;
@@ -286,7 +286,7 @@ export const CustomEditor = {
286286
});
287287
},
288288

289-
toggleToggleList(editor: YjsEditor, blockId: string) {
289+
toggleToggleList (editor: YjsEditor, blockId: string) {
290290
const sharedRoot = getSharedRoot(editor);
291291
const data = dataStringTOJson(getBlock(blockId, sharedRoot).get(YjsEditorKey.block_data)) as ToggleListBlockData;
292292
const { selection } = editor;
@@ -310,7 +310,7 @@ export const CustomEditor = {
310310
}, selected);
311311
},
312312

313-
toggleTodoList(editor: YjsEditor, blockId: string, shiftKey: boolean) {
313+
toggleTodoList (editor: YjsEditor, blockId: string, shiftKey: boolean) {
314314
const sharedRoot = getSharedRoot(editor);
315315
const block = getBlock(blockId, sharedRoot);
316316
const data = dataStringTOJson(block.get(YjsEditorKey.block_data)) as TodoListBlockData;
@@ -344,7 +344,7 @@ export const CustomEditor = {
344344
});
345345
},
346346

347-
toggleMark(editor: ReactEditor, {
347+
toggleMark (editor: ReactEditor, {
348348
key, value,
349349
}: {
350350
key: EditorMarkFormat, value: boolean | string
@@ -358,23 +358,23 @@ export const CustomEditor = {
358358
}
359359
},
360360

361-
getTextNodes(editor: ReactEditor) {
361+
getTextNodes (editor: ReactEditor) {
362362
return getSelectionTexts(editor);
363363
},
364364

365-
addMark(editor: ReactEditor, {
365+
addMark (editor: ReactEditor, {
366366
key, value,
367367
}: {
368368
key: EditorMarkFormat, value: boolean | string | Mention
369369
}) {
370370
editor.addMark(key, value);
371371
},
372372

373-
removeMark(editor: ReactEditor, key: EditorMarkFormat) {
373+
removeMark (editor: ReactEditor, key: EditorMarkFormat) {
374374
editor.removeMark(key);
375375
},
376376

377-
turnToBlock<T extends BlockData>(editor: YjsEditor, blockId: string, type: BlockType, data: T) {
377+
turnToBlock<T extends BlockData> (editor: YjsEditor, blockId: string, type: BlockType, data: T) {
378378
const operations: (() => void)[] = [];
379379
const sharedRoot = getSharedRoot(editor);
380380
const sourceBlock = getBlock(blockId, sharedRoot);
@@ -395,7 +395,7 @@ export const CustomEditor = {
395395
return newBlockId;
396396
},
397397

398-
isBlockActive(editor: YjsEditor, type: BlockType) {
398+
isBlockActive (editor: YjsEditor, type: BlockType) {
399399
try {
400400
const [node] = getBlockEntry(editor);
401401

@@ -405,7 +405,7 @@ export const CustomEditor = {
405405
}
406406
},
407407

408-
hasMark(editor: ReactEditor, key: string) {
408+
hasMark (editor: ReactEditor, key: string) {
409409
const selection = editor.selection;
410410

411411
if (!selection) return false;
@@ -429,7 +429,7 @@ export const CustomEditor = {
429429
return marks ? !!marks[key] : false;
430430
},
431431

432-
getAllMarks(editor: ReactEditor) {
432+
getAllMarks (editor: ReactEditor) {
433433
const selection = editor.selection;
434434

435435
if (!selection) return [];
@@ -452,7 +452,7 @@ export const CustomEditor = {
452452
return [marks];
453453
},
454454

455-
isMarkActive(editor: ReactEditor, key: string) {
455+
isMarkActive (editor: ReactEditor, key: string) {
456456
const selection = editor.selection;
457457

458458
if (!selection) return false;
@@ -476,7 +476,7 @@ export const CustomEditor = {
476476
return marks ? !!marks[key] : false;
477477
},
478478

479-
addChildBlock(editor: YjsEditor, blockId: string, type: BlockType, data: BlockData) {
479+
addChildBlock (editor: YjsEditor, blockId: string, type: BlockType, data: BlockData) {
480480
const sharedRoot = getSharedRoot(editor);
481481
const parent = getBlock(blockId, sharedRoot);
482482

@@ -510,7 +510,7 @@ export const CustomEditor = {
510510
}
511511
},
512512

513-
addBlock(editor: YjsEditor, blockId: string, direction: 'below' | 'above', type: BlockType, data: BlockData) {
513+
addBlock (editor: YjsEditor, blockId: string, direction: 'below' | 'above', type: BlockType, data: BlockData) {
514514
const parent = getParent(blockId, editor.sharedRoot);
515515
const index = getBlockIndex(blockId, editor.sharedRoot);
516516

@@ -540,15 +540,15 @@ export const CustomEditor = {
540540
}
541541
},
542542

543-
addBelowBlock(editor: YjsEditor, blockId: string, type: BlockType, data: BlockData) {
543+
addBelowBlock (editor: YjsEditor, blockId: string, type: BlockType, data: BlockData) {
544544
return CustomEditor.addBlock(editor, blockId, 'below', type, data);
545545
},
546546

547-
addAboveBlock(editor: YjsEditor, blockId: string, type: BlockType, data: BlockData) {
547+
addAboveBlock (editor: YjsEditor, blockId: string, type: BlockType, data: BlockData) {
548548
return CustomEditor.addBlock(editor, blockId, 'above', type, data);
549549
},
550550

551-
deleteBlock(editor: YjsEditor, blockId: string) {
551+
deleteBlock (editor: YjsEditor, blockId: string) {
552552
const sharedRoot = getSharedRoot(editor);
553553
const parent = getParent(blockId, sharedRoot);
554554

@@ -601,7 +601,7 @@ export const CustomEditor = {
601601
ReactEditor.focus(editor);
602602
},
603603

604-
duplicateBlock(editor: YjsEditor, blockId: string, prevId?: string) {
604+
duplicateBlock (editor: YjsEditor, blockId: string, prevId?: string) {
605605
const sharedRoot = getSharedRoot(editor);
606606
const block = getBlock(blockId, sharedRoot);
607607

@@ -631,7 +631,7 @@ export const CustomEditor = {
631631
return newBlockId;
632632
},
633633

634-
pastedText(editor: YjsEditor, text: string) {
634+
pastedText (editor: YjsEditor, text: string) {
635635
if (!beforePasted(editor))
636636
return;
637637

@@ -640,7 +640,7 @@ export const CustomEditor = {
640640
Transforms.insertNodes(editor, { text }, { at: point, select: true, voids: false });
641641
},
642642

643-
highlight(editor: ReactEditor) {
643+
highlight (editor: ReactEditor) {
644644
const selection = editor.selection;
645645

646646
if (!selection) return;

0 commit comments

Comments
 (0)