From 25a2f0c29695863fa38cfd3c4aa3298c80929033 Mon Sep 17 00:00:00 2001 From: natamox Date: Mon, 14 Oct 2024 18:54:05 +0800 Subject: [PATCH] feat: enable it to pass getSiblingIndentListOptions --- .../src/lib/transforms/toggleIndentList.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/indent-list/src/lib/transforms/toggleIndentList.ts b/packages/indent-list/src/lib/transforms/toggleIndentList.ts index 38bc22ef45..9ba170bc5c 100644 --- a/packages/indent-list/src/lib/transforms/toggleIndentList.ts +++ b/packages/indent-list/src/lib/transforms/toggleIndentList.ts @@ -1,4 +1,6 @@ import { + ElementEntryOf, + ElementOf, type SlateEditor, type TElement, getBlockAbove, @@ -22,15 +24,20 @@ import { setIndentListNodes } from './setIndentListNodes'; import { setIndentListSiblingNodes } from './setIndentListSiblingNodes'; import { toggleIndentListSet } from './toggleIndentListSet'; import { toggleIndentListUnset } from './toggleIndentListUnset'; +import { GetSiblingIndentListOptions } from '../queries'; /** Toggle indent list. */ -export const toggleIndentList = ( +export const toggleIndentList = < + N extends ElementOf, + E extends SlateEditor = SlateEditor, +>( editor: E, - options: IndentListOptions + options: IndentListOptions, + getSiblingIndentListOptions?: GetSiblingIndentListOptions ) => { const { listStyleType } = options; - const { getSiblingIndentListOptions } = + const { getSiblingIndentListOptions: _getSiblingIndentListOptions } = editor.getOptions(BaseIndentListPlugin); if (isCollapsed(editor.selection)) { @@ -44,8 +51,9 @@ export const toggleIndentList = ( return; } - setIndentListSiblingNodes(editor, entry, { - getSiblingIndentListOptions, + setIndentListSiblingNodes(editor, entry as ElementEntryOf, { + ..._getSiblingIndentListOptions, + ...getSiblingIndentListOptions, listStyleType, });