Skip to content

Commit

Permalink
feat: enable it to pass getSiblingIndentListOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
natamox committed Oct 14, 2024
1 parent dc3c491 commit 25a2f0c
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions packages/indent-list/src/lib/transforms/toggleIndentList.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {
ElementEntryOf,
ElementOf,
type SlateEditor,
type TElement,
getBlockAbove,
Expand All @@ -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 = <E extends SlateEditor>(
export const toggleIndentList = <
N extends ElementOf<E>,
E extends SlateEditor = SlateEditor,
>(
editor: E,
options: IndentListOptions<E>
options: IndentListOptions<E>,
getSiblingIndentListOptions?: GetSiblingIndentListOptions<N, E>
) => {
const { listStyleType } = options;

const { getSiblingIndentListOptions } =
const { getSiblingIndentListOptions: _getSiblingIndentListOptions } =
editor.getOptions(BaseIndentListPlugin);

if (isCollapsed(editor.selection)) {
Expand All @@ -44,8 +51,9 @@ export const toggleIndentList = <E extends SlateEditor>(
return;
}

setIndentListSiblingNodes(editor, entry, {
getSiblingIndentListOptions,
setIndentListSiblingNodes(editor, entry as ElementEntryOf<E>, {
..._getSiblingIndentListOptions,
...getSiblingIndentListOptions,
listStyleType,
});

Expand Down

0 comments on commit 25a2f0c

Please sign in to comment.