diff --git a/packages/core/client/src/filter-provider/FilterProvider.tsx b/packages/core/client/src/filter-provider/FilterProvider.tsx index 6d1d9231ce..9b5e821195 100644 --- a/packages/core/client/src/filter-provider/FilterProvider.tsx +++ b/packages/core/client/src/filter-provider/FilterProvider.tsx @@ -19,6 +19,7 @@ import { mergeFilter, useAssociatedFields } from './utils'; // @ts-ignore import React, { createContext, useCallback, useEffect, useMemo, useRef } from 'react'; +import { useAllDataBlocks } from '../schema-component/antd/page/AllDataBlocksProvider'; enum FILTER_OPERATOR { AND = '$and', @@ -71,6 +72,10 @@ export interface DataBlock { * manual: 只有当点击了筛选按钮,才会请求数据 */ dataLoadingMode?: 'auto' | 'manual'; + /** 让整个区块悬浮起来 */ + highlightBlock: () => void; + /** 取消悬浮 */ + unhighlightBlock: () => void; } interface FilterContextValue { @@ -124,7 +129,7 @@ export const DataBlockCollector = ({ const field = useField(); const fieldSchema = useFieldSchema(); const associatedFields = useAssociatedFields(); - const container = useRef(null); + const container = useRef(null); const dataLoadingMode = useDataLoadingMode(); const shouldApplyFilter = @@ -172,6 +177,34 @@ export const DataBlockCollector = ({ field.data?.clearSelectedRowKeys?.(); } }, + highlightBlock() { + const dom = container.current; + + if (!dom) return; + + const designer = dom.querySelector('.ant-nb-schema-toolbar'); + if (designer) { + designer.classList.remove(process.env.__E2E__ ? 'hidden-e2e' : 'hidden'); + } + dom.style.boxShadow = '0 3px 12px rgba(0, 0, 0, 0.15)'; + dom.style.transition = 'box-shadow 0.3s ease, transform 0.2s ease'; + dom.scrollIntoView?.({ + behavior: 'smooth', + block: 'start', + }); + }, + unhighlightBlock() { + const dom = container.current; + + if (!dom) return; + + const designer = dom.querySelector('.ant-nb-schema-toolbar'); + if (designer) { + designer.classList.add(process.env.__E2E__ ? 'hidden-e2e' : 'hidden'); + } + dom.style.boxShadow = 'none'; + dom.style.transition = 'box-shadow 0.3s ease, transform 0.2s ease'; + } }); }, [ associatedFields, @@ -197,12 +230,14 @@ export const DataBlockCollector = ({ */ export const useFilterBlock = () => { const ctx = React.useContext(FilterContext); + const allDataBlocksCtx = useAllDataBlocks(); // 有可能存在页面没有提供 FilterBlockProvider 的情况,比如内部使用的数据表管理页面 const getDataBlocks = useCallback<() => DataBlock[]>(() => ctx?.getDataBlocks() || [], [ctx]); const recordDataBlocks = useCallback( (block: DataBlock) => { + allDataBlocksCtx.recordDataBlocks(block); const existingBlock = ctx?.getDataBlocks().find((item) => item.uid === block.uid); if (existingBlock) { @@ -218,6 +253,7 @@ export const useFilterBlock = () => { const removeDataBlock = useCallback( (uid: string) => { + allDataBlocksCtx.removeDataBlock(uid); if (ctx?.getDataBlocks().every((item) => item.uid !== uid)) return; ctx?.setDataBlocks((prev) => prev.filter((item) => item.uid !== uid)); }, diff --git a/packages/core/client/src/filter-provider/highlightBlock.ts b/packages/core/client/src/filter-provider/highlightBlock.ts new file mode 100644 index 0000000000..1e02301461 --- /dev/null +++ b/packages/core/client/src/filter-provider/highlightBlock.ts @@ -0,0 +1,47 @@ +let container: HTMLElement | null = null; + +export const highlightBlock = (clonedBlockDom: HTMLElement, boxRect: DOMRect) => { + if (!container) { + container = document.createElement('div'); + document.body.appendChild(container); + container.style.position = 'absolute'; + container.style.transition = 'opacity 0.3s ease'; + container.style.pointerEvents = 'none'; + } + + container.appendChild(clonedBlockDom); + container.style.opacity = '1'; + container.style.width = `${boxRect.width}px`; + container.style.height = `${boxRect.height}px`; + container.style.top = `${boxRect.top}px`; + container.style.left = `${boxRect.left}px`; + container.style.zIndex = '2000'; +} + +export const unhighlightBlock = () => { + if (container) { + container.style.opacity = '0'; + container.innerHTML = ''; + } +} + +export const startScrollEndTracking = (dom: HTMLElement & { _prevRect?: DOMRect; _timer?: any }, callback: () => void) => { + dom._timer = setInterval(() => { + const prevRect = dom._prevRect; + const currentRect = dom.getBoundingClientRect(); + + if (!prevRect || currentRect.top !== prevRect.top) { + dom._prevRect = currentRect; + } else { + clearInterval(dom._timer); + callback(); + } + }, 100) +} + +export const stopScrollEndTracking = (dom: HTMLElement & { _timer?: any }) => { + if (dom._timer) { + clearInterval(dom._timer); + dom._timer = null; + } +} diff --git a/packages/core/client/src/locale/de-DE.json b/packages/core/client/src/locale/de-DE.json index 6ba834ee1b..fe9b43dd49 100644 --- a/packages/core/client/src/locale/de-DE.json +++ b/packages/core/client/src/locale/de-DE.json @@ -886,5 +886,8 @@ "Are you sure you want to hide this tab?": "Sind Sie sicher, dass Sie diesen Tab ausblenden möchten?", "After hiding, this tab will no longer appear in the tab bar. To show it again, you need to go to the route management page to set it.": "Nach dem Ausblenden wird dieser Tab nicht mehr in der Tableiste angezeigt. Um ihn wieder anzuzeigen, müssen Sie zur Routenverwaltungsseite gehen, um ihn einzustellen.", "No pages yet, please configure first": "Noch keine Seiten, bitte zuerst konfigurieren", - "Click the \"UI Editor\" icon in the upper right corner to enter the UI Editor mode": "Klicken Sie auf das \"UI-Editor\"-Symbol in der oberen rechten Ecke, um den UI-Editor-Modus zu betreten" + "Click the \"UI Editor\" icon in the upper right corner to enter the UI Editor mode": "Klicken Sie auf das \"UI-Editor\"-Symbol in der oberen rechten Ecke, um den UI-Editor-Modus zu betreten", + "Refresh data blocks": "Aktualisieren Sie die Datenblöcke", + "Select data blocks to refresh": "Wählen Sie die Datenblöcke aus, die aktualisiert werden sollen.", + "After successful submission, the selected data blocks will be automatically refreshed.": "Nach erfolgreicher Übermittlung werden die ausgewählten Datenblöcke automatisch aktualisiert." } diff --git a/packages/core/client/src/locale/en-US.json b/packages/core/client/src/locale/en-US.json index a6a79589d7..01eb15ae86 100644 --- a/packages/core/client/src/locale/en-US.json +++ b/packages/core/client/src/locale/en-US.json @@ -890,5 +890,9 @@ "Click the \"UI Editor\" icon in the upper right corner to enter the UI Editor mode": "Click the \"UI Editor\" icon in the upper right corner to enter the UI Editor mode", "Deprecated": "Deprecated", "The following old template features have been deprecated and will be removed in next version.": "The following old template features have been deprecated and will be removed in next version.", - "Full permissions": "Full permissions" + "Full permissions": "Full permissions", + "Refresh data blocks": "Refresh data blocks", + "Select data blocks to refresh": "Select data blocks to refresh", + "After successful submission, the selected data blocks will be automatically refreshed.": "After successful submission, the selected data blocks will be automatically refreshed." + } diff --git a/packages/core/client/src/locale/es-ES.json b/packages/core/client/src/locale/es-ES.json index 249f150243..06e30c4dfa 100644 --- a/packages/core/client/src/locale/es-ES.json +++ b/packages/core/client/src/locale/es-ES.json @@ -807,5 +807,8 @@ "Click the \"UI Editor\" icon in the upper right corner to enter the UI Editor mode": "Haga clic en el icono \"Editor de UI\" en la esquina superior derecha para entrar en el modo de Editor de UI.", "Deprecated": "Obsoleto", "The following old template features have been deprecated and will be removed in next version.": "Las siguientes características de plantilla antigua han quedado obsoletas y se eliminarán en la próxima versión.", - "Full permissions": "Todos los derechos" + "Full permissions": "Todos los derechos", + "Refresh data blocks": "Actualizar bloques de datos", + "Select data blocks to refresh": "Actualizar bloques de datos", + "After successful submission, the selected data blocks will be automatically refreshed.": "Después de enviar correctamente, los bloques de datos seleccionados se actualizarán automáticamente." } diff --git a/packages/core/client/src/locale/fr-FR.json b/packages/core/client/src/locale/fr-FR.json index 90ea8c5fb4..ab2c5fb444 100644 --- a/packages/core/client/src/locale/fr-FR.json +++ b/packages/core/client/src/locale/fr-FR.json @@ -827,5 +827,8 @@ "Click the \"UI Editor\" icon in the upper right corner to enter the UI Editor mode": "Cliquez sur l'icône \"Éditeur d'interface utilisateur\" dans le coin supérieur droit pour entrer en mode Éditeur d'interface utilisateur", "Deprecated": "Déprécié", "The following old template features have been deprecated and will be removed in next version.": "Les fonctionnalités des anciens modèles ont été dépréciées et seront supprimées dans la prochaine version.", - "Full permissions": "Tous les droits" + "Full permissions": "Tous les droits", + "Refresh data blocks": "Actualiser les blocs de données", + "Select data blocks to refresh": "Actualiser les blocs de données", + "After successful submission, the selected data blocks will be automatically refreshed.": "Après une soumission réussie, les blocs de données sélectionnés seront automatiquement actualisés." } diff --git a/packages/core/client/src/locale/it-IT.json b/packages/core/client/src/locale/it-IT.json index 74b1d739f8..05a64aba8e 100644 --- a/packages/core/client/src/locale/it-IT.json +++ b/packages/core/client/src/locale/it-IT.json @@ -1082,5 +1082,8 @@ "Are you sure you want to hide this tab?": "Sei sicuro di voler nascondere questa scheda?", "After hiding, this tab will no longer appear in the tab bar. To show it again, you need to go to the route management page to set it.": "Dopo averla nascosta, questa scheda non apparirà più nella barra delle schede. Per mostrarla di nuovo, devi andare alla pagina di gestione dei percorsi per configurarlo.", "No pages yet, please configure first": "Nessuna pagina ancora, si prega di configurare prima", - "Click the \"UI Editor\" icon in the upper right corner to enter the UI Editor mode": "Cliquez sur l'icône \"Éditeur d'interface utilisateur\" dans le coin supérieur droit pour entrer en mode Éditeur d'interface utilisateur" + "Click the \"UI Editor\" icon in the upper right corner to enter the UI Editor mode": "Cliquez sur l'icône \"Éditeur d'interface utilisateur\" dans le coin supérieur droit pour entrer en mode Éditeur d'interface utilisateur", + "Refresh data blocks": "Aggiorna blocchi di dati", + "Select data blocks to refresh": "Aggiorna blocchi di dati", + "After successful submission, the selected data blocks will be automatically refreshed.": "Dopo una soumission réussie, les blocs de données sélectionnés seront automatiquement actualisés." } diff --git a/packages/core/client/src/locale/ja-JP.json b/packages/core/client/src/locale/ja-JP.json index 91e8b63b41..1918d9968f 100644 --- a/packages/core/client/src/locale/ja-JP.json +++ b/packages/core/client/src/locale/ja-JP.json @@ -1045,5 +1045,8 @@ "Click the \"UI Editor\" icon in the upper right corner to enter the UI Editor mode": "ユーザーインターフェースエディターモードに入るには、右上隅の「UIエディタ」アイコンをクリックしてください", "Deprecated": "非推奨", "The following old template features have been deprecated and will be removed in next version.": "次の古いテンプレート機能は非推奨になり、次のバージョンで削除されます。", - "Full permissions": "すべての権限" + "Full permissions": "すべての権限", + "Refresh data blocks": "データブロックを更新", + "Select data blocks to refresh": "データブロックを選択して更新", + "After successful submission, the selected data blocks will be automatically refreshed.": "送信後、選択したデータブロックが自動的に更新されます。" } diff --git a/packages/core/client/src/locale/ko-KR.json b/packages/core/client/src/locale/ko-KR.json index 4efe35e20f..e007ae97f7 100644 --- a/packages/core/client/src/locale/ko-KR.json +++ b/packages/core/client/src/locale/ko-KR.json @@ -918,5 +918,8 @@ "Click the \"UI Editor\" icon in the upper right corner to enter the UI Editor mode": "사용자 인터페이스 편집기 모드에 들어가려면 오른쪽 상단의 \"UI 편집기\" 아이콘을 클릭하십시오", "Deprecated": "사용 중단됨", "The following old template features have been deprecated and will be removed in next version.": "다음 오래된 템플릿 기능은 사용 중단되었으며 다음 버전에서 제거될 것입니다.", - "Full permissions": "모든 권한" + "Full permissions": "모든 권한", + "Refresh data blocks": "데이터 블록 새로 고침", + "Select data blocks to refresh": "데이터 블록을 선택하여 새로 고침", + "After successful submission, the selected data blocks will be automatically refreshed.": "전송 후, 선택한 데이터 블록이 자동으로 새로 고쳐집니다." } diff --git a/packages/core/client/src/locale/nl-NL.json b/packages/core/client/src/locale/nl-NL.json index 9a945ea0bb..1e58c0bd68 100644 --- a/packages/core/client/src/locale/nl-NL.json +++ b/packages/core/client/src/locale/nl-NL.json @@ -1,7 +1,7 @@ { "Display <1><0>10<1>20<2>50<3>100 items per page": "Toon <1><0>10<1>20<2>50<3>100 items per pagina", "Page number": "Paginanummer", - "Page size": "Paginagrootte", + "Page size": "Paginagrootte", "Meet <1><0>All<1>Any conditions in the group": "Voldoe aan <1><0>Alle<1>Een voorwaarde(n) in de groep", "Open in<1><0>Modal<1>Drawer<2>Window": "Open in<1><0>Modal<1>Drawer<2>Venster", "{{count}} filter items": "{{count}} filter items", @@ -1054,5 +1054,8 @@ "Font Size(px)": "Lettergrootte(px)", "Font Weight": "Letterdikte", "Font Style": "Letterstijl", - "Italic": "Cursief" -} \ No newline at end of file + "Italic": "Cursief", + "Refresh data blocks": "Vernieuw gegevensblokken", + "Select data blocks to refresh": "Selecteer gegevensblokken om te vernieuwen", + "After successful submission, the selected data blocks will be automatically refreshed.": "Na succesvolle indiening worden de geselecteerde gegevensblokken automatisch vernieuwd." +} diff --git a/packages/core/client/src/locale/pt-BR.json b/packages/core/client/src/locale/pt-BR.json index 2b07be5950..1909aaaa92 100644 --- a/packages/core/client/src/locale/pt-BR.json +++ b/packages/core/client/src/locale/pt-BR.json @@ -784,5 +784,8 @@ "The following old template features have been deprecated and will be removed in next version.": "As seguintes funcionalidades de modelo antigo foram descontinuadas e serão removidas na próxima versão.", "Full permissions": "Todas as permissões", "No pages yet, please configure first": "Ainda não há páginas, por favor configure primeiro", - "Click the \"UI Editor\" icon in the upper right corner to enter the UI Editor mode": "Cliquez sur l'icône \"Éditeur d'interface utilisateur\" dans le coin supérieur droit pour entrer en mode Éditeur d'interface utilisateur" + "Click the \"UI Editor\" icon in the upper right corner to enter the UI Editor mode": "Cliquez sur l'icône \"Éditeur d'interface utilisateur\" dans le coin supérieur droit pour entrer en mode Éditeur d'interface utilisateur", + "Refresh data blocks": "Atualizar blocos de dados", + "Select data blocks to refresh": "Selecionar blocos de dados para atualizar", + "After successful submission, the selected data blocks will be automatically refreshed.": "Após a atualização em massa bem sucedida." } diff --git a/packages/core/client/src/locale/ru-RU.json b/packages/core/client/src/locale/ru-RU.json index ec108187f0..22c864ac35 100644 --- a/packages/core/client/src/locale/ru-RU.json +++ b/packages/core/client/src/locale/ru-RU.json @@ -613,5 +613,8 @@ "The following old template features have been deprecated and will be removed in next version.": "Следующие старые функции шаблонов устарели и будут удалены в следующей версии.", "Full permissions": "Полные права", "No pages yet, please configure first": "Пока нет страниц, пожалуйста, настройте сначала", - "Click the \"UI Editor\" icon in the upper right corner to enter the UI Editor mode": "Нажмите на значок \"Редактор пользовательского интерфейса\" в правом верхнем углу, чтобы войти в режим редактора пользовательского интерфейса" + "Click the \"UI Editor\" icon in the upper right corner to enter the UI Editor mode": "Нажмите на значок \"Редактор пользовательского интерфейса\" в правом верхнем углу, чтобы войти в режим редактора пользовательского интерфейса", + "Refresh data blocks": "Обновить блоки данных", + "Select data blocks to refresh": "Выберите блоки данных для обновления", + "After successful submission, the selected data blocks will be automatically refreshed.": "После успешной отправки выбранные блоки данных будут автоматически обновлены." } diff --git a/packages/core/client/src/locale/tr-TR.json b/packages/core/client/src/locale/tr-TR.json index 9a8d090dec..390c4ca0f2 100644 --- a/packages/core/client/src/locale/tr-TR.json +++ b/packages/core/client/src/locale/tr-TR.json @@ -611,5 +611,8 @@ "The following old template features have been deprecated and will be removed in next version.": "Aşağıdaki eski şablon özellikleri kullanımdan kaldırıldı ve gelecek sürümlerde kaldırılacaktır.", "Full permissions": "Tüm izinler", "No pages yet, please configure first": "Henüz sayfa yok, lütfen önce yapılandırın", - "Click the \"UI Editor\" icon in the upper right corner to enter the UI Editor mode": "Kullanıcı arayüzü düzenleyici moduna girmek için sağ üst köşedeki \"Kullanıcı Arayüzü Düzenleyici\" simgesine tıklayın" + "Click the \"UI Editor\" icon in the upper right corner to enter the UI Editor mode": "Kullanıcı arayüzü düzenleyici moduna girmek için sağ üst köşedeki \"Kullanıcı Arayüzü Düzenleyici\" simgesine tıklayın", + "Refresh data blocks": "Yenile veri blokları", + "Select data blocks to refresh": "Veri bloklarını yenilemek için seçin", + "After successful submission, the selected data blocks will be automatically refreshed.": "Başarılı bir şekilde gönderildikten sonra, seçilen veri blokları otomatik olarak yenilenecektir." } diff --git a/packages/core/client/src/locale/uk-UA.json b/packages/core/client/src/locale/uk-UA.json index 6d1d8c7ad5..91bf069e1d 100644 --- a/packages/core/client/src/locale/uk-UA.json +++ b/packages/core/client/src/locale/uk-UA.json @@ -827,5 +827,8 @@ "The following old template features have been deprecated and will be removed in next version.": "Наступні старі функції шаблонів були застарілі і будуть видалені в наступній версії.", "Full permissions": "Повні права", "No pages yet, please configure first": "Ще немає сторінок, будь ласка, спочатку налаштуйте", - "Click the \"UI Editor\" icon in the upper right corner to enter the UI Editor mode": "Натисніть на значок \"Редактор користувацького інтерфейсу\" в правому верхньому куті, щоб увійти в режим редактора користувацького інтерфейсу." + "Click the \"UI Editor\" icon in the upper right corner to enter the UI Editor mode": "Натисніть на значок \"Редактор користувацького інтерфейсу\" в правому верхньому куті, щоб увійти в режим редактора користувацького інтерфейсу.", + "Refresh data blocks": "Оновити дані блоків", + "Select data blocks to refresh": "Виберіть блоки даних для оновлення", + "After successful submission, the selected data blocks will be automatically refreshed.": "Після успішної подачі вибрані блоки даних будуть автоматично оновлені." } diff --git a/packages/core/client/src/locale/zh-CN.json b/packages/core/client/src/locale/zh-CN.json index ccfd6649a2..8e27dc701d 100644 --- a/packages/core/client/src/locale/zh-CN.json +++ b/packages/core/client/src/locale/zh-CN.json @@ -167,6 +167,8 @@ "Year": "年", "QuarterYear": "季度", "Select grouping field": "选择分组字段", + "Refresh data blocks": "刷新数据区块", + "Select data blocks to refresh": "选择要刷新的数据区块", "Media": "多媒体", "Markdown": "Markdown", "Wysiwyg": "富文本", @@ -1099,5 +1101,6 @@ "Response record":"响应结果记录", "Colon":"冒号", "No pages yet, please configure first": "暂无页面,请先配置", - "Click the \"UI Editor\" icon in the upper right corner to enter the UI Editor mode": "点击右上角的“界面配置”图标,进入界面配置模式" + "Click the \"UI Editor\" icon in the upper right corner to enter the UI Editor mode": "点击右上角的“界面配置”图标,进入界面配置模式", + "After successful submission, the selected data blocks will be automatically refreshed.": "提交成功后,会自动刷新这里选中的数据区块。" } diff --git a/packages/core/client/src/locale/zh-TW.json b/packages/core/client/src/locale/zh-TW.json index a7b342631e..77a012fe3f 100644 --- a/packages/core/client/src/locale/zh-TW.json +++ b/packages/core/client/src/locale/zh-TW.json @@ -918,5 +918,8 @@ "The following old template features have been deprecated and will be removed in next version.": "以下舊的模板功能已棄用,將在下個版本移除。", "Full permissions": "完全權限", "No pages yet, please configure first": "尚未配置頁面,請先配置", - "Click the \"UI Editor\" icon in the upper right corner to enter the UI Editor mode": "點擊右上角的 \"介面設定\" 圖示進入介面設定模式" + "Click the \"UI Editor\" icon in the upper right corner to enter the UI Editor mode": "點擊右上角的 \"介面設定\" 圖示進入介面設定模式", + "Refresh data blocks": "刷新數據區塊", + "Select data blocks to refresh": "選擇要刷新的數據區塊", + "After successful submission, the selected data blocks will be automatically refreshed.": "提交成功後,選中的數據區塊將自動刷新。" } diff --git a/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx b/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx index cc37a46860..0f24cf6b72 100644 --- a/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx +++ b/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx @@ -9,14 +9,16 @@ import { ISchema, useField, useFieldSchema } from '@formily/react'; import { isValid, uid } from '@formily/shared'; -import { ModalProps } from 'antd'; -import React, { useCallback } from 'react'; +import { ModalProps, Select } from 'antd'; +import React, { useCallback, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { useCompile, useDesignable } from '../..'; -import { isInitializersSame, useApp } from '../../../application'; +import { isInitializersSame, useApp, usePlugin } from '../../../application'; +import { useGlobalVariable } from '../../../application/hooks/useGlobalVariable'; import { SchemaSettingOptions, SchemaSettings } from '../../../application/schema-settings'; import { useSchemaToolbar } from '../../../application/schema-toolbar'; import { useCollectionManager_deprecated, useCollection_deprecated } from '../../../collection-manager'; +import { highlightBlock, startScrollEndTracking, stopScrollEndTracking, unhighlightBlock } from '../../../filter-provider/highlightBlock'; import { FlagProvider } from '../../../flag-provider'; import { SaveMode } from '../../../modules/actions/submit/createSubmitActionSettings'; import { useOpenModeContext } from '../../../modules/popup/OpenModeProvider'; @@ -32,10 +34,10 @@ import { SchemaSettingsSwitchItem, } from '../../../schema-settings/SchemaSettings'; import { DefaultValueProvider } from '../../../schema-settings/hooks/useIsAllowToSetDefaultValue'; +import { useAllDataBlocks } from '../page/AllDataBlocksProvider'; import { useLinkageAction } from './hooks'; -import { requestSettingsSchema } from './utils'; import { useAfterSuccessOptions } from './hooks/useGetAfterSuccessVariablesOptions'; -import { useGlobalVariable } from '../../../application/hooks/useGlobalVariable'; +import { requestSettingsSchema } from './utils'; const MenuGroup = (props) => { return props.children; @@ -294,27 +296,105 @@ const useVariableProps = (environmentVariables) => { }; }; +const hideDialog = (dialogClassName: string) => { + const dialogMask = document.querySelector(`.${dialogClassName} > .ant-modal-mask`); + const dialogWrap = document.querySelector(`.${dialogClassName} > .ant-modal-wrap`); + if (dialogMask) { + dialogMask.style.opacity = '0'; + dialogMask.style.transition = 'opacity 0.5s ease'; + } + if (dialogWrap) { + dialogWrap.style.opacity = '0'; + dialogWrap.style.transition = 'opacity 0.5s ease'; + } +} + +const showDialog = (dialogClassName: string) => { + const dialogMask = document.querySelector(`.${dialogClassName} > .ant-modal-mask`); + const dialogWrap = document.querySelector(`.${dialogClassName} > .ant-modal-wrap`); + if (dialogMask) { + dialogMask.style.opacity = '1'; + dialogMask.style.transition = 'opacity 0.5s ease'; + } + if (dialogWrap) { + dialogWrap.style.opacity = '1'; + dialogWrap.style.transition = 'opacity 0.5s ease'; + } +} + +export const BlocksSelector = (props) => { + const { getAllDataBlocks } = useAllDataBlocks(); + const allDataBlocks = getAllDataBlocks(); + const compile = useCompile(); + const { t } = useTranslation(); + + // 转换 allDataBlocks 为 Select 选项 + const options = useMemo(() => { + return allDataBlocks.map(block => { + // 防止列表中出现已关闭的弹窗中的区块 + if (!block.dom?.isConnected) { + return null; + } + + const title = `${compile(block.collection.title)} #${block.uid.slice(0, 4)}`; + return { + label: title, + value: block.uid, + onMouseEnter() { + block.highlightBlock(); + hideDialog('dialog-after-successful-submission'); + startScrollEndTracking(block.dom, () => { + highlightBlock(block.dom.cloneNode(true) as HTMLElement, block.dom.getBoundingClientRect()); + }); + }, + onMouseLeave() { + block.unhighlightBlock(); + showDialog('dialog-after-successful-submission'); + stopScrollEndTracking(block.dom); + unhighlightBlock(); + } + } + }).filter(Boolean); + }, [allDataBlocks, t]); + + return ( +