Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add DecoratedRange/TDecoratedRange types #3837

Merged
merged 4 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/twenty-mayflies-fry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@udecode/slate': minor
'@udecode/plate-core': minor
---

feat: Change Decorate's return type to DecoratedRange/TDecoratedRange
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
"react-test-renderer": "18.3.1",
"rimraf": "^6.0.1",
"shadcx": "workspace:^",
"slate": "0.110.2",
"slate": "0.112.0",
"slate-dom": "0.111.0",
"slate-history": "0.110.3",
"slate-hyperscript": "0.100.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"peerDependencies": {
"react": ">=16.8.0",
"react-dom": ">=16.8.0",
"slate": ">=0.103.0",
"slate": ">=0.112.0",
yf-yang marked this conversation as resolved.
Show resolved Hide resolved
"slate-dom": ">=0.111.0",
"slate-history": ">=0.93.0",
"slate-hyperscript": ">=0.66.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/lib/plugin/SlatePlugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { TDescendant, TNodeEntry, Value } from '@udecode/slate';
import type { AnyObject } from '@udecode/utils';
import type { Range } from 'slate';
import type { DecoratedRange } from 'slate';

import type { SlateEditor } from '../editor';
import type { Nullable } from '../types/misc';
Expand Down Expand Up @@ -393,7 +393,7 @@ export type HtmlSerializer<C extends AnyPluginConfig = PluginConfig> =
*/
export type Decorate<C extends AnyPluginConfig = PluginConfig> = (
ctx: SlatePluginContext<C> & { entry: TNodeEntry }
) => Range[] | undefined;
) => DecoratedRange[] | undefined;

export type InjectNodeProps<C extends AnyPluginConfig = PluginConfig> =
BaseInjectProps & {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/react/plugin/PlatePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import type {
Keys,
} from '@udecode/react-hotkeys';
import type {
TDecoratedRange,
TDescendant,
TElement,
TNodeEntry,
TRange,
TText,
Value,
} from '@udecode/slate';
Expand Down Expand Up @@ -657,7 +657,7 @@ export type HtmlReactSerializer<C extends AnyPluginConfig = PluginConfig> = {
*/
export type Decorate<C extends AnyPluginConfig = PluginConfig> = (
ctx: PlatePluginContext<C> & { entry: TNodeEntry }
) => TRange[] | undefined;
) => TDecoratedRange[] | undefined;

/** Properties used by Plate to inject props into any {@link NodeComponent}. */
export type InjectNodeProps<C extends AnyPluginConfig = PluginConfig> =
Expand Down
11 changes: 10 additions & 1 deletion packages/slate/src/types/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import type { Location, Path, Range, Selection, Span } from 'slate';
import type {
DecoratedRange,
Location,
Path,
Range,
Selection,
Span,
} from 'slate';

export type TLocation = Location;

Expand All @@ -9,3 +16,5 @@ export type TRange = Range;
export type TSelection = Selection;

export type TSpan = Span;

export type TDecoratedRange = DecoratedRange;
15 changes: 13 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6677,7 +6677,7 @@ __metadata:
peerDependencies:
react: ">=16.8.0"
react-dom: ">=16.8.0"
slate: ">=0.103.0"
slate: ">=0.112.0"
slate-dom: ">=0.111.0"
slate-history: ">=0.93.0"
slate-hyperscript: ">=0.66.0"
Expand Down Expand Up @@ -17444,7 +17444,7 @@ __metadata:
react-test-renderer: "npm:18.3.1"
rimraf: "npm:^6.0.1"
shadcx: "workspace:^"
slate: "npm:0.110.2"
slate: "npm:0.112.0"
slate-dom: "npm:0.111.0"
slate-history: "npm:0.110.3"
slate-hyperscript: "npm:0.100.0"
Expand Down Expand Up @@ -19824,6 +19824,17 @@ __metadata:
languageName: node
linkType: hard

"slate@npm:0.112.0":
version: 0.112.0
resolution: "slate@npm:0.112.0"
dependencies:
immer: "npm:^10.0.3"
is-plain-object: "npm:^5.0.0"
tiny-warning: "npm:^1.0.3"
checksum: 10c0/e31dc1eb13c20505d243398bb91efeb8a8ef602eef6c8d4b55f616a39dd80ba4405916a4e40f30b0aa4ba8fbfd52a83508ecb947ad4b4cbc68d8e1f6b518eb96
languageName: node
linkType: hard

"slick@npm:^1.12.2":
version: 1.12.2
resolution: "slick@npm:1.12.2"
Expand Down
Loading