From edd0fc98dbf7d4e8e2810fa0df8c6f68c3678968 Mon Sep 17 00:00:00 2001 From: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Date: Thu, 16 Apr 2026 11:23:10 +0530 Subject: [PATCH] feat: Table support in article editor (#13974) --- .../Pages/ArticleEditorPage/ArticleEditor.vue | 15 ++++--- .../widgets/WootWriter/FullEditor.vue | 3 +- app/javascript/dashboard/constants/editor.js | 1 + .../api/v1/portals/articles/show.html.erb | 39 ++++++++++++++++++- lib/custom_markdown_renderer.rb | 6 +++ package.json | 2 +- pnpm-lock.yaml | 10 ++--- 7 files changed, 60 insertions(+), 16 deletions(-) diff --git a/app/javascript/dashboard/components-next/HelpCenter/Pages/ArticleEditorPage/ArticleEditor.vue b/app/javascript/dashboard/components-next/HelpCenter/Pages/ArticleEditorPage/ArticleEditor.vue index 2f06ea01e..22cb1441a 100644 --- a/app/javascript/dashboard/components-next/HelpCenter/Pages/ArticleEditorPage/ArticleEditor.vue +++ b/app/javascript/dashboard/components-next/HelpCenter/Pages/ArticleEditorPage/ArticleEditor.vue @@ -161,8 +161,12 @@ const handleCreateArticle = event => { } .editor-root .has-selection { + .ProseMirror-menubar:not(:has(*)) { + display: none !important; + } + .ProseMirror-menubar { - @apply h-8 rounded-lg !px-2 z-50 bg-n-solid-3 items-center gap-4 ml-0 mb-0 shadow-md outline outline-1 outline-n-weak; + @apply rounded-lg !px-3 !py-1.5 z-50 bg-n-background items-center gap-4 ml-0 mb-0 shadow-md outline outline-1 outline-n-weak; display: flex; top: var(--selection-top, auto) !important; left: var(--selection-left, 0) !important; @@ -170,15 +174,10 @@ const handleCreateArticle = event => { position: absolute !important; .ProseMirror-menuitem { - @apply mr-0; + @apply ltr:mr-0 rtl:ml-0 size-4 flex items-center; .ProseMirror-icon { - @apply p-0 mt-0 !mr-0; - - svg { - width: 20px !important; - height: 20px !important; - } + @apply p-0.5 flex-shrink-0 ltr:mr-2 rtl:ml-2; } } diff --git a/app/javascript/dashboard/components/widgets/WootWriter/FullEditor.vue b/app/javascript/dashboard/components/widgets/WootWriter/FullEditor.vue index 976ed3270..64f6136c2 100644 --- a/app/javascript/dashboard/components/widgets/WootWriter/FullEditor.vue +++ b/app/javascript/dashboard/components/widgets/WootWriter/FullEditor.vue @@ -262,7 +262,8 @@ export default { // Get the editor's width const editorWidth = editor.offsetWidth; - const menubarWidth = 480; // Menubar width (adjust as needed (px)) + const menubar = editor.querySelector('.ProseMirror-menubar'); + const menubarWidth = menubar ? menubar.scrollWidth : 480; // Get the end position of the selection const { bottom: endBottom, right: endRight } = editorView.coordsAtPos(to); diff --git a/app/javascript/dashboard/constants/editor.js b/app/javascript/dashboard/constants/editor.js index d33af1a11..3969f43a7 100644 --- a/app/javascript/dashboard/constants/editor.js +++ b/app/javascript/dashboard/constants/editor.js @@ -182,6 +182,7 @@ export const ARTICLE_EDITOR_MENU_OPTIONS = [ 'h3', 'imageUpload', 'code', + 'insertTable', ]; /** diff --git a/app/views/public/api/v1/portals/articles/show.html.erb b/app/views/public/api/v1/portals/articles/show.html.erb index 5ca116f89..784817c9c 100644 --- a/app/views/public/api/v1/portals/articles/show.html.erb +++ b/app/views/public/api/v1/portals/articles/show.html.erb @@ -36,7 +36,7 @@ <% end %>