Jelajahi Sumber

Merge pull request #8978 from weseek/fix/sync-latest-revision-body-menu-item

fix: Sync the editor text with the latest revision menu (2)
Yuki Takei 1 tahun lalu
induk
melakukan
9f9f9d7358

+ 3 - 2
apps/app/public/static/locales/en_US/translation.json

@@ -9,7 +9,6 @@
   "delete_all": "Delete all",
   "delete_all": "Delete all",
   "Duplicate": "Duplicate",
   "Duplicate": "Duplicate",
   "PathRecovery": "Path recovery",
   "PathRecovery": "Path recovery",
-  "SyncLatestRevisionBody": "Sync editor with latest body",
   "Copy": "Copy",
   "Copy": "Copy",
   "preview": "Preview",
   "preview": "Preview",
   "desktop": "Desktop",
   "desktop": "Desktop",
@@ -851,10 +850,12 @@
   "create_page": {
   "create_page": {
     "untitled": "Untitled"
     "untitled": "Untitled"
   },
   },
-  "sync-latest-reevision-body": {
+  "sync-latest-revision-body": {
+    "menuitem": "Sync the editor text with the latest revision body",
     "confirm": "Delete the draft data being entered into the editor and synchronize the latest text. Are you sure you want to run it?",
     "confirm": "Delete the draft data being entered into the editor and synchronize the latest text. Are you sure you want to run it?",
     "alert": "The latest text may not have been synchronized. Please reload and check again.",
     "alert": "The latest text may not have been synchronized. Please reload and check again.",
     "success-toaster": "Latest text synchronized",
     "success-toaster": "Latest text synchronized",
+    "skipped-toaster": "Skipped synchronizing since the editor is not activated. Please open the editor and try again.",
     "error-toaster": "Synchronization of the latest text failed"
     "error-toaster": "Synchronization of the latest text failed"
   }
   }
 }
 }

+ 3 - 2
apps/app/public/static/locales/fr_FR/translation.json

@@ -9,7 +9,6 @@
   "delete_all": "Tout supprimer",
   "delete_all": "Tout supprimer",
   "Duplicate": "Dupliquer",
   "Duplicate": "Dupliquer",
   "PathRecovery": "Récupération de chemin",
   "PathRecovery": "Récupération de chemin",
-  "SyncLatestRevisionBody": "Synchroniser l'éditeur avec le dernier corps",
   "Copy": "Copier",
   "Copy": "Copier",
   "preview": "Prévisualiser",
   "preview": "Prévisualiser",
   "desktop": "Ordinateur",
   "desktop": "Ordinateur",
@@ -842,10 +841,12 @@
     "size_s": "Taille: P",
     "size_s": "Taille: P",
     "size_l": "Taille: G"
     "size_l": "Taille: G"
   },
   },
-  "sync-latest-reevision-body": {
+  "sync-latest-revision-body": {
+    "menuitem": "Synchroniser le texte de l'éditeur avec le corps de la dernière révision",
     "confirm": "Delete the draft data being entered into the editor and synchronize the latest text. Are you sure you want to run it?",
     "confirm": "Delete the draft data being entered into the editor and synchronize the latest text. Are you sure you want to run it?",
     "alert": "Il se peut que le texte le plus récent n'ait pas été synchronisé. Veuillez recharger et vérifier à nouveau.",
     "alert": "Il se peut que le texte le plus récent n'ait pas été synchronisé. Veuillez recharger et vérifier à nouveau.",
     "success-toaster": "Dernier texte synchronisé",
     "success-toaster": "Dernier texte synchronisé",
+    "skipped-toaster": "Synchronisation ignorée car l'éditeur n'est pas activé. Ouvrir l'éditeur et réessayer.",
     "error-toaster": "La synchronisation du dernier texte a échoué"
     "error-toaster": "La synchronisation du dernier texte a échoué"
   }
   }
 }
 }

+ 3 - 2
apps/app/public/static/locales/ja_JP/translation.json

@@ -9,7 +9,6 @@
   "delete_all": "全て削除",
   "delete_all": "全て削除",
   "Duplicate": "複製",
   "Duplicate": "複製",
   "PathRecovery": "パスを修復",
   "PathRecovery": "パスを修復",
-  "SyncLatestRevisionBody": "エディターを最新の本文に同期",
   "Copy": "コピー",
   "Copy": "コピー",
   "preview": "プレビュー",
   "preview": "プレビュー",
   "desktop": "パソコン",
   "desktop": "パソコン",
@@ -884,10 +883,12 @@
   "create_page": {
   "create_page": {
     "untitled": "無題のページ"
     "untitled": "無題のページ"
   },
   },
-  "sync-latest-reevision-body": {
+  "sync-latest-revision-body": {
+    "menuitem": "最新のリビジョンの本文とエディタのテキストを同期",
     "confirm": "エディターに入力中のドラフトデータを削除して最新の本文を同期します。実行しますか?",
     "confirm": "エディターに入力中のドラフトデータを削除して最新の本文を同期します。実行しますか?",
     "alert": "最新の本文が同期されていない可能性があります。リロードして再度ご確認ください。",
     "alert": "最新の本文が同期されていない可能性があります。リロードして再度ご確認ください。",
     "success-toaster": "最新の本文を同期しました",
     "success-toaster": "最新の本文を同期しました",
+    "skipped-toaster": "エディターがアクティブではないため、同期をスキップしました。エディターを開いて再度お試しください。",
     "error-toaster": "最新の本文の同期に失敗しました"
     "error-toaster": "最新の本文の同期に失敗しました"
   }
   }
 }
 }

+ 3 - 2
apps/app/public/static/locales/zh_CN/translation.json

@@ -9,7 +9,6 @@
   "delete_all": "删除所有",
   "delete_all": "删除所有",
   "Duplicate": "复制",
   "Duplicate": "复制",
   "PathRecovery": "路径恢复",
   "PathRecovery": "路径恢复",
-  "SyncLatestRevisionBody": "将编辑器与最新机身同步",
   "Copy": "复制",
   "Copy": "复制",
   "preview": "预览",
   "preview": "预览",
   "desktop": "电脑",
   "desktop": "电脑",
@@ -854,10 +853,12 @@
   "create_page": {
   "create_page": {
     "untitled": "Untitled"
     "untitled": "Untitled"
   },
   },
-  "sync-latest-reevision-body": {
+  "sync-latest-revision-body": {
+    "menuitem": "同步编辑器文本与最新修订正文",
     "confirm": "删除输入编辑器的草稿数据,同步最新文本。 您真的想运行它吗?",
     "confirm": "删除输入编辑器的草稿数据,同步最新文本。 您真的想运行它吗?",
     "alert": "最新文本可能尚未同步。 请重新加载并再次检查。",
     "alert": "最新文本可能尚未同步。 请重新加载并再次检查。",
     "success-toaster": "同步最新文本",
     "success-toaster": "同步最新文本",
+    "skipped-toaster": "由于编辑器未激活,因此跳过同步。 请打开编辑器并重试。",
     "error-toaster": "同步最新文本失败"
     "error-toaster": "同步最新文本失败"
   }
   }
 }
 }

+ 13 - 16
apps/app/src/client/components/Navbar/GrowiContextualSubNavigation.tsx

@@ -25,7 +25,7 @@ import {
   useCurrentPathname,
   useCurrentPathname,
   useCurrentUser, useIsGuestUser, useIsReadOnlyUser, useIsSharedUser, useShareLinkId,
   useCurrentUser, useIsGuestUser, useIsReadOnlyUser, useIsSharedUser, useShareLinkId,
 } from '~/stores-universal/context';
 } from '~/stores-universal/context';
-import { EditorMode, useEditorMode } from '~/stores-universal/ui';
+import { useEditorMode } from '~/stores-universal/ui';
 import {
 import {
   usePageAccessoriesModal, PageAccessoriesModalContents, type IPageForPageDuplicateModal,
   usePageAccessoriesModal, PageAccessoriesModalContents, type IPageForPageDuplicateModal,
   usePageDuplicateModal, usePageRenameModal, usePageDeleteModal, usePagePresentationModal,
   usePageDuplicateModal, usePageRenameModal, usePageDeleteModal, usePagePresentationModal,
@@ -72,7 +72,6 @@ const PageOperationMenuItems = (props: PageOperationMenuItemsProps): JSX.Element
     pageId, revisionId, isLinkSharingDisabled,
     pageId, revisionId, isLinkSharingDisabled,
   } = props;
   } = props;
 
 
-  const { data: editorMode } = useEditorMode();
   const { data: isGuestUser } = useIsGuestUser();
   const { data: isGuestUser } = useIsGuestUser();
   const { data: isReadOnlyUser } = useIsReadOnlyUser();
   const { data: isReadOnlyUser } = useIsReadOnlyUser();
   const { data: isSharedUser } = useIsSharedUser();
   const { data: isSharedUser } = useIsSharedUser();
@@ -84,42 +83,40 @@ const PageOperationMenuItems = (props: PageOperationMenuItemsProps): JSX.Element
 
 
   const syncLatestRevisionBodyHandler = useCallback(async() => {
   const syncLatestRevisionBodyHandler = useCallback(async() => {
     // eslint-disable-next-line no-alert
     // eslint-disable-next-line no-alert
-    const answer = window.confirm(t('sync-latest-reevision-body.confirm'));
+    const answer = window.confirm(t('sync-latest-revision-body.confirm'));
     if (answer) {
     if (answer) {
       try {
       try {
         const editingMarkdownLength = codeMirrorEditor?.getDoc().length;
         const editingMarkdownLength = codeMirrorEditor?.getDoc().length;
         const res = await syncLatestRevisionBody(pageId, editingMarkdownLength);
         const res = await syncLatestRevisionBody(pageId, editingMarkdownLength);
 
 
         if (!res.synced) {
         if (!res.synced) {
-          toastWarning('Skipped synchronizing since the page is not being edited.');
+          toastWarning(t('sync-latest-revision-body.skipped-toaster'));
           return;
           return;
         }
         }
 
 
         if (res?.isYjsDataBroken) {
         if (res?.isYjsDataBroken) {
           // eslint-disable-next-line no-alert
           // eslint-disable-next-line no-alert
-          window.alert(t('sync-latest-reevision-body.alert'));
+          window.alert(t('sync-latest-revision-body.alert'));
           return;
           return;
         }
         }
 
 
-        toastSuccess(t('sync-latest-reevision-body.success-toaster'));
+        toastSuccess(t('sync-latest-revision-body.success-toaster'));
       }
       }
       catch {
       catch {
-        toastError(t('sync-latest-reevision-body.error-toaster'));
+        toastError(t('sync-latest-revision-body.error-toaster'));
       }
       }
     }
     }
   }, [codeMirrorEditor, pageId, t]);
   }, [codeMirrorEditor, pageId, t]);
 
 
   return (
   return (
     <>
     <>
-      { editorMode === EditorMode.Editor && (
-        <DropdownItem
-          onClick={() => syncLatestRevisionBodyHandler()}
-          className="grw-page-control-dropdown-item"
-        >
-          <span className="material-symbols-outlined me-1 grw-page-control-dropdown-icon">sync</span>
-          {t('SyncLatestRevisionBody')}
-        </DropdownItem>
-      ) }
+      <DropdownItem
+        onClick={() => syncLatestRevisionBodyHandler()}
+        className="grw-page-control-dropdown-item"
+      >
+        <span className="material-symbols-outlined me-1 grw-page-control-dropdown-icon">sync</span>
+        {t('sync-latest-revision-body.menuitem')}
+      </DropdownItem>
 
 
       {/* Presentation */}
       {/* Presentation */}
       <DropdownItem
       <DropdownItem