From da50ea9a90de6ccf4fd290f8f86296711807175b Mon Sep 17 00:00:00 2001 From: "Moritz Tim W." <90388353+moritztim@users.noreply.github.com> Date: Mon, 2 Dec 2024 05:38:33 +0100 Subject: [PATCH] feat: expose gfm table params through the table plugin (#645) * add params and pass them on * directly reference options why limit ourselves * Improve naming * Add defaults --- src/plugins/table/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/table/index.ts b/src/plugins/table/index.ts index 1c3837e6..cc08793e 100644 --- a/src/plugins/table/index.ts +++ b/src/plugins/table/index.ts @@ -1,7 +1,7 @@ import { realmPlugin } from '../../RealmWithPlugins' import { Signal, map } from '@mdxeditor/gurx' import * as Mdast from 'mdast' -import { gfmTableFromMarkdown, gfmTableToMarkdown } from 'mdast-util-gfm-table' +import { gfmTableFromMarkdown, gfmTableToMarkdown, Options as GfmTableOptions } from 'mdast-util-gfm-table' import { gfmTable } from 'micromark-extension-gfm-table' import { addExportVisitor$, @@ -79,8 +79,8 @@ export const insertTable$ = Signal<{ * A plugin that adds support for tables to the editor. * @group Table */ -export const tablePlugin = realmPlugin({ - init(realm) { +export const tablePlugin = realmPlugin({ + init(realm, params) { realm.pubIn({ // import [addMdastExtension$]: gfmTableFromMarkdown(), @@ -89,7 +89,7 @@ export const tablePlugin = realmPlugin({ // export [addLexicalNode$]: TableNode, [addExportVisitor$]: LexicalTableVisitor, - [addToMarkdownExtension$]: gfmTableToMarkdown({ tableCellPadding: true, tablePipeAlign: true }) + [addToMarkdownExtension$]: gfmTableToMarkdown({ tableCellPadding: params?.tableCellPadding ?? true, tablePipeAlign: params?.tablePipeAlign ?? true }) }) } })