From e57256d45ab53c7fb1cb76b8824e815301ee10c0 Mon Sep 17 00:00:00 2001 From: zbeyens Date: Sat, 21 Dec 2024 19:48:42 +0100 Subject: [PATCH] fix --- .changeset/cuddly-swans-doubt.md | 5 ++++ config/tsup.config.bundled_9puzttys2to.mjs | 0 config/tsup.config.bundled_zhu6hjrub7s.mjs | 0 packages/common/src/type.spec.ts | 10 ++++++++ .../src/lib/isType.spec.tsx} | 3 ++- .../slate-react/src/types/TEditableProps.ts | 24 ++++++++++++++++--- 6 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 .changeset/cuddly-swans-doubt.md delete mode 100644 config/tsup.config.bundled_9puzttys2to.mjs delete mode 100644 config/tsup.config.bundled_zhu6hjrub7s.mjs create mode 100644 packages/common/src/type.spec.ts rename packages/{slate-utils/src/queries/__tests__/isType/type.spec.tsx => plate-utils/src/lib/isType.spec.tsx} (89%) diff --git a/.changeset/cuddly-swans-doubt.md b/.changeset/cuddly-swans-doubt.md new file mode 100644 index 0000000000..3455f31088 --- /dev/null +++ b/.changeset/cuddly-swans-doubt.md @@ -0,0 +1,5 @@ +--- +'@udecode/slate-react': patch +--- + +Type diff --git a/config/tsup.config.bundled_9puzttys2to.mjs b/config/tsup.config.bundled_9puzttys2to.mjs deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/config/tsup.config.bundled_zhu6hjrub7s.mjs b/config/tsup.config.bundled_zhu6hjrub7s.mjs deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/common/src/type.spec.ts b/packages/common/src/type.spec.ts new file mode 100644 index 0000000000..4ff7edca59 --- /dev/null +++ b/packages/common/src/type.spec.ts @@ -0,0 +1,10 @@ +import { createSlateEditor } from '@udecode/plate-core'; +import { isType } from '@udecode/plate-utils'; + +it('should not throw', () => { + const editor = createSlateEditor(); + + expect( + isType(createSlateEditor({ editor }), editor.children[0], 'p') + ).toEqual(true); +}); diff --git a/packages/slate-utils/src/queries/__tests__/isType/type.spec.tsx b/packages/plate-utils/src/lib/isType.spec.tsx similarity index 89% rename from packages/slate-utils/src/queries/__tests__/isType/type.spec.tsx rename to packages/plate-utils/src/lib/isType.spec.tsx index 32f49bb1d9..a0d20141b6 100644 --- a/packages/slate-utils/src/queries/__tests__/isType/type.spec.tsx +++ b/packages/plate-utils/src/lib/isType.spec.tsx @@ -1,7 +1,8 @@ /** @jsx jsxt */ import { type SlateEditor, createSlateEditor } from '@udecode/plate-core'; import { jsxt } from '@udecode/plate-test-utils'; -import { isType } from '@udecode/plate-utils'; + +import { isType } from './isType'; jsxt; diff --git a/packages/slate-react/src/types/TEditableProps.ts b/packages/slate-react/src/types/TEditableProps.ts index 188947b033..d3ce947e16 100644 --- a/packages/slate-react/src/types/TEditableProps.ts +++ b/packages/slate-react/src/types/TEditableProps.ts @@ -1,13 +1,31 @@ -import type { TNodeEntry } from '@udecode/slate'; +import type { TEditor, TNodeEntry } from '@udecode/slate'; import type { Range } from 'slate'; -import type { EditableProps } from 'slate-react/dist/components/editable'; +import type { DOMRange } from 'slate-dom'; import type { RenderElementFn } from './TRenderElementProps'; import type { RenderLeafFn } from './TRenderLeafProps'; /** `EditableProps` are passed to the component. */ export type TEditableProps = { + renderPlaceholder?: (props: { + attributes: { + contentEditable: boolean; + 'data-slate-placeholder': boolean; + ref: React.RefCallback; + style: React.CSSProperties; + dir?: 'rtl'; + }; + children: any; + }) => JSX.Element; + as?: React.ElementType; decorate?: (entry: TNodeEntry) => Range[]; + disableDefaultStyles?: boolean; + placeholder?: string; + readOnly?: boolean; renderElement?: RenderElementFn; renderLeaf?: RenderLeafFn; -} & Omit; + role?: string; + scrollSelectionIntoView?: (editor: TEditor, domRange: DOMRange) => void; + style?: React.CSSProperties; + onDOMBeforeInput?: (event: InputEvent) => void; +} & React.TextareaHTMLAttributes;