From 1d23f4db1522f92dee7bd0c10cc11c70b572100e Mon Sep 17 00:00:00 2001 From: Leto Date: Wed, 18 Sep 2024 18:20:40 +0800 Subject: [PATCH 1/3] fix(dashboard): fte shouldnt submit stale value --- .../widgets/rich-text-editor/custom-rich-text-editor.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dashboard/src/components/widgets/rich-text-editor/custom-rich-text-editor.tsx b/dashboard/src/components/widgets/rich-text-editor/custom-rich-text-editor.tsx index 5e11c023b..991df393c 100644 --- a/dashboard/src/components/widgets/rich-text-editor/custom-rich-text-editor.tsx +++ b/dashboard/src/components/widgets/rich-text-editor/custom-rich-text-editor.tsx @@ -24,6 +24,7 @@ import { ColorMappingControl, ColorMappingMark } from './color-mapping-mark'; import { ColorPickerControl } from './color-picker-control'; import { DynamicColorControl, DynamicColorMark } from './dynamic-color-mark'; import { ChooseFontSize, FontSize } from './font-size-extension'; +import { useBoolean } from 'ahooks'; const RTEContentStyle: Sx = { 'dynamic-color': { @@ -110,6 +111,7 @@ export const CustomRichTextEditor = forwardRef( return ret; }, [inPanelContext]); + const [focused, { setTrue, setFalse }] = useBoolean(false); const [content, setContent] = useState(value); const editor = useEditor({ extensions, @@ -123,6 +125,8 @@ export const CustomRichTextEditor = forwardRef( editor.view.dom.setAttribute('autocomplete', 'off'); editor.view.dom.setAttribute('autocapitalize', 'off'); }, + onFocus: setTrue, + onBlur: setFalse, }); useEffect(() => { @@ -142,11 +146,11 @@ export const CustomRichTextEditor = forwardRef( const changed = value !== content; useEffect(() => { - if (!autoSubmit) { + if (!autoSubmit || !focused) { return; } submit(); - }, [autoSubmit, changed]); + }, [autoSubmit, changed, focused]); const finalStyles = useMemo(() => { return _.defaultsDeep({}, { content: { ...CommonHTMLContentStyle, ...RTEContentStyle } }, styles); From cf7b4759b1b261bc6a362440af5e2371c5cc7740 Mon Sep 17 00:00:00 2001 From: Leto Date: Wed, 18 Sep 2024 18:34:32 +0800 Subject: [PATCH 2/3] fix(dashboard): switching between 2 stats panels would throw errors --- .../viz-components/stats/viz-stats.tsx | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/dashboard/src/components/plugins/viz-components/stats/viz-stats.tsx b/dashboard/src/components/plugins/viz-components/stats/viz-stats.tsx index 28c788d7e..4f4bd9aae 100644 --- a/dashboard/src/components/plugins/viz-components/stats/viz-stats.tsx +++ b/dashboard/src/components/plugins/viz-components/stats/viz-stats.tsx @@ -1,7 +1,6 @@ import { Box, Flex, Sx } from '@mantine/core'; import { useCallback, useEffect, useMemo, useRef } from 'react'; -import { defaults } from 'lodash'; import { observer } from 'mobx-react-lite'; import { useStorageData } from '~/components/plugins/hooks'; import { ReadonlyRichText } from '~/components/widgets'; @@ -10,7 +9,7 @@ import { useCurrentInteractionManager, useTriggerSnapshotList } from '~/interact import { VizViewProps } from '~/types/plugin'; import { parseRichTextContent } from '~/utils'; import { ClickStats } from './triggers'; -import { DEFAULT_CONFIG, IVizStatsConf } from './type'; +import { IVizStatsConf } from './type'; const verticalAlignments = { top: 'flex-start', @@ -31,7 +30,8 @@ function getWrapperSx(triggersCount: number) { return ret; } -export const VizStats = observer(({ context, instance }: VizViewProps) => { +type RenderProps = VizViewProps; +export const Render = observer(({ context, instance }: RenderProps) => { const ref = useRef(null); const interactionManager = useCurrentInteractionManager({ vizManager: context.vizManager, @@ -41,18 +41,20 @@ export const VizStats = observer(({ context, instance }: VizViewProps) => { const triggers = useTriggerSnapshotList(interactionManager.triggerManager, ClickStats.id); const contentModel = useRenderContentModelContext(); - const { value: confValue = DEFAULT_CONFIG } = useStorageData(context.instanceData, 'config'); + const { panel } = useRenderPanelContext(); + const conf = panel.viz.conf.config as IVizStatsConf; + const { data, variables } = context; const { width, height } = context.viewport; const richTextContent = useMemo(() => { - const conf = defaults({}, confValue, DEFAULT_CONFIG); + const conf = panel.viz.conf.config; if (!conf.content) { return ''; } return parseRichTextContent(conf.content, variables, contentModel.payloadForViz, data); - }, [data, confValue, variables, contentModel.payloadForViz]); + }, [data, panel, variables, contentModel.payloadForViz]); const handleContentClick = useCallback(() => { triggers.forEach((t) => { @@ -83,7 +85,7 @@ export const VizStats = observer(({ context, instance }: VizViewProps) => { width, height, }} - align={verticalAlignments[confValue.vertical_align]} + align={verticalAlignments[conf.vertical_align]} direction="row" > @@ -120,3 +122,14 @@ export const VizStats = observer(({ context, instance }: VizViewProps) => { ); }); + +export const VizStats = (props: VizViewProps) => { + const { context } = props; + const { value: conf } = useStorageData(context.instanceData, 'config'); + + if (!conf) { + return null; + } + + return ; +}; From 775b609bb037f189b73557174e89567fe00c4561 Mon Sep 17 00:00:00 2001 From: Leto Date: Wed, 18 Sep 2024 18:36:01 +0800 Subject: [PATCH 3/3] chore: publish v13.41.1 --- api/package.json | 2 +- dashboard/package.json | 2 +- package.json | 2 +- settings-form/package.json | 2 +- website/package.json | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api/package.json b/api/package.json index 11d550475..94d7ea0cb 100644 --- a/api/package.json +++ b/api/package.json @@ -1,6 +1,6 @@ { "name": "@devtable/api", - "version": "13.41.0", + "version": "13.41.1", "description": "", "main": "index.js", "scripts": { diff --git a/dashboard/package.json b/dashboard/package.json index c09d84474..462216355 100644 --- a/dashboard/package.json +++ b/dashboard/package.json @@ -1,6 +1,6 @@ { "name": "@devtable/dashboard", - "version": "13.41.0", + "version": "13.41.1", "license": "Apache-2.0", "publishConfig": { "access": "public", diff --git a/package.json b/package.json index 5fc04bcf9..6e1cc1555 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtable/root", - "version": "13.41.0", + "version": "13.41.1", "private": true, "workspaces": [ "api", diff --git a/settings-form/package.json b/settings-form/package.json index e9d2c1caf..ff8f16ca7 100644 --- a/settings-form/package.json +++ b/settings-form/package.json @@ -1,6 +1,6 @@ { "name": "@devtable/settings-form", - "version": "13.41.0", + "version": "13.41.1", "license": "Apache-2.0", "publishConfig": { "access": "public", diff --git a/website/package.json b/website/package.json index fdec24ccd..124ee0ccb 100644 --- a/website/package.json +++ b/website/package.json @@ -2,7 +2,7 @@ "name": "@devtable/website", "private": true, "license": "Apache-2.0", - "version": "13.41.0", + "version": "13.41.1", "scripts": { "dev": "vite", "preview": "vite preview"