From 36169e924c1be0df7ca3bff79b0dcf758e4e63f0 Mon Sep 17 00:00:00 2001 From: Adam Obuchowicz Date: Tue, 21 Jan 2025 10:57:25 +0100 Subject: [PATCH] Fix header rename (#12064) Fixes #11150 The fix consist of two parts: 1. The state of editing is kept in the widget, not in particular header components; the communication is done in a vue fashion - the headers calls callback if they _want_ to be edited/not edited. 2. Copied the AgGridVue component and make it _not_ mount header components by itself, but use our VueComponentHost instead (which also as improved a bit, so we have more guarantees of preserving components). --- CHANGELOG.md | 3 + app/common/src/utilities/data/object.ts | 21 -- .../components/CodeEditor/CodeEditorImpl.vue | 10 +- .../components/CodeEditor/tooltips.ts | 2 +- .../GraphEditor/widgets/WidgetTableEditor.vue | 94 ++++--- .../widgets/WidgetTableEditor/TableHeader.vue | 109 ++++---- .../__tests__/tableInputArgument.test.ts | 10 +- .../WidgetTableEditor/tableInputArgument.ts | 28 +- .../MarkdownEditor/MarkdownEditorImpl.vue | 8 +- .../markdown/decoration/linksAndImages.ts | 2 +- .../markdown/decoration/table.ts | 2 +- .../markdown/decoration/treeStateDecorator.ts | 2 +- .../markdown/decoration/treeViewDecorator.ts | 2 +- .../PlainTextEditor/PlainTextEditorImpl.vue | 8 +- .../components/VueComponentHost.vue | 39 --- .../project-view/components/VueHostRender.vue | 54 ++++ .../components/shared/AgGridTableView.vue | 68 ++++- .../shared/AgGridTableView/AgGridVue.ts | 262 ++++++++++++++++++ .../shared/AgGridTableView/Utils.ts | 122 ++++++++ .../src/project-view/util/codemirror/index.ts | 2 +- .../util/codemirror/linkEditPopup.ts | 2 +- .../util/codemirror/vueHostExt.ts | 2 +- 22 files changed, 649 insertions(+), 203 deletions(-) delete mode 100644 app/gui/src/project-view/components/VueComponentHost.vue create mode 100644 app/gui/src/project-view/components/VueHostRender.vue create mode 100644 app/gui/src/project-view/components/shared/AgGridTableView/AgGridVue.ts create mode 100644 app/gui/src/project-view/components/shared/AgGridTableView/Utils.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 099bda81269a..0faf697cbdf3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,12 +9,15 @@ - [Quick Fix Import Button][12051]. - [Fixed nodes being selected after deleting other nodes or connections.][11902] - [Redo stack is no longer lost when interacting with text literals][11908]. +- [Fixed bug when clicking header in Table Editor Widget didn't start editing + it][12064] [11889]: https://github.com/enso-org/enso/pull/11889 [11836]: https://github.com/enso-org/enso/pull/11836 [12051]: https://github.com/enso-org/enso/pull/12051 [11902]: https://github.com/enso-org/enso/pull/11902 [11908]: https://github.com/enso-org/enso/pull/11908 +[12064]: https://github.com/enso-org/enso/pull/12064 #### Enso Standard Library diff --git a/app/common/src/utilities/data/object.ts b/app/common/src/utilities/data/object.ts index a60e6051050b..44279a04d2b3 100644 --- a/app/common/src/utilities/data/object.ts +++ b/app/common/src/utilities/data/object.ts @@ -193,27 +193,6 @@ export type ExtractKeys = { /** An instance method of the given type. */ export type MethodOf = (this: T, ...args: never) => unknown -// =================== -// === useObjectId === -// =================== - -/** Composable providing support for managing object identities. */ -export function useObjectId() { - let lastId = 0 - const idNumbers = new WeakMap() - /** @returns A value that can be used to compare object identity. */ - function objectId(o: object): number { - const id = idNumbers.get(o) - if (id == null) { - lastId += 1 - idNumbers.set(o, lastId) - return lastId - } - return id - } - return { objectId } -} - /** * Returns the union of `A` and `B`, with a type-level assertion that `A` and `B` don't have any keys in common; this * can be used to splice together objects without the risk of collisions. diff --git a/app/gui/src/project-view/components/CodeEditor/CodeEditorImpl.vue b/app/gui/src/project-view/components/CodeEditor/CodeEditorImpl.vue index 25f3451aafb5..7f0e28d22ba9 100644 --- a/app/gui/src/project-view/components/CodeEditor/CodeEditorImpl.vue +++ b/app/gui/src/project-view/components/CodeEditor/CodeEditorImpl.vue @@ -4,7 +4,7 @@ import { ensoSyntax } from '@/components/CodeEditor/ensoSyntax' import { useEnsoSourceSync } from '@/components/CodeEditor/sync' import { ensoHoverTooltip } from '@/components/CodeEditor/tooltips' import CodeMirrorRoot from '@/components/CodeMirrorRoot.vue' -import VueComponentHost from '@/components/VueComponentHost.vue' +import VueHostRender, { VueHost } from '@/components/VueHostRender.vue' import { useGraphStore } from '@/stores/graph' import { useProjectStore } from '@/stores/project' import { useSuggestionDbStore } from '@/stores/suggestionDatabase' @@ -31,8 +31,6 @@ const projectStore = useProjectStore() const graphStore = useGraphStore() const suggestionDbStore = useSuggestionDbStore() -const vueComponentHost = - useTemplateRef>('vueComponentHost') const editorRoot = useTemplateRef>('editorRoot') const rootElement = computed(() => editorRoot.value?.rootElement) useAutoBlur(rootElement) @@ -42,7 +40,7 @@ const autoindentOnEnter = { run: insertNewlineKeepIndent, } -const vueHost = computed(() => vueComponentHost.value || undefined) +const vueHost = new VueHost() const { editorView, setExtraExtensions } = useCodeMirror(editorRoot, { extensions: [ keymap.of([indentWithTab, autoindentOnEnter]), @@ -55,7 +53,7 @@ const { editorView, setExtraExtensions } = useCodeMirror(editorRoot, { highlightStyle(useCssModule()), ensoHoverTooltip(graphStore, suggestionDbStore, vueHost), ], - vueHost, + vueHost: () => vueHost, }) ;(window as any).__codeEditorApi = testSupport(editorView) const { updateListener, connectModuleListener } = useEnsoSourceSync( @@ -74,7 +72,7 @@ onMounted(() => {