Skip to content

Commit

Permalink
feat: expose gfm table params through the table plugin (#645)
Browse files Browse the repository at this point in the history
* add params and pass them on

* directly reference options

why limit ourselves

* Improve naming

* Add defaults
  • Loading branch information
moritztim authored Dec 2, 2024
1 parent e8baa67 commit da50ea9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/plugins/table/index.ts
Original file line number Diff line number Diff line change
@@ -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$,
Expand Down Expand Up @@ -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<GfmTableOptions>({
init(realm, params) {
realm.pubIn({
// import
[addMdastExtension$]: gfmTableFromMarkdown(),
Expand All @@ -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 })

Check failure on line 92 in src/plugins/table/index.ts

View workflow job for this annotation

GitHub Actions / Release

Replace `·tableCellPadding:·params?.tableCellPadding·??·true,·tablePipeAlign:·params?.tablePipeAlign·??·true` with `⏎········tableCellPadding:·params?.tableCellPadding·??·true,⏎········tablePipeAlign:·params?.tablePipeAlign·??·true⏎·····`
})
}
})

0 comments on commit da50ea9

Please sign in to comment.