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

fix: corrected toggle calls for Superscript and Subscript #3402

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 9 additions & 0 deletions .changeset/dull-dryers-sip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@udecode/plate-normalizers': patch
'@udecode/plate-utils': patch
'@udecode/plate-selection': patch
'@udecode/plate-combobox': patch
'@udecode/plate-table': patch
---

fix: corrected toggle calls for Superscript and Subscript
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function PlaygroundMoreDropdownMenu(props: DropdownMenuProps) {
<DropdownMenuItem
onSelect={() => {
toggleMark(editor, {
clear: MARK_SUBSCRIPT,
clear: [MARK_SUBSCRIPT, MARK_SUPERSCRIPT],
key: MARK_SUPERSCRIPT,
});
focusEditor(editor);
Expand All @@ -80,7 +80,7 @@ export function PlaygroundMoreDropdownMenu(props: DropdownMenuProps) {
<DropdownMenuItem
onSelect={() => {
toggleMark(editor, {
clear: MARK_SUPERSCRIPT,
clear: [MARK_SUPERSCRIPT, MARK_SUBSCRIPT],
key: MARK_SUBSCRIPT,
});
focusEditor(editor);
Expand Down
8 changes: 4 additions & 4 deletions apps/www/src/registry/default/plate-ui/more-dropdown-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export function MoreDropdownMenu(props: DropdownMenuProps) {
<DropdownMenuItem
onSelect={() => {
toggleMark(editor, {
clear: MARK_SUPERSCRIPT,
key: MARK_SUBSCRIPT,
clear: [MARK_SUBSCRIPT, MARK_SUPERSCRIPT],
key: MARK_SUPERSCRIPT,
});
focusEditor(editor);
}}
Expand All @@ -48,8 +48,8 @@ export function MoreDropdownMenu(props: DropdownMenuProps) {
<DropdownMenuItem
onSelect={() => {
toggleMark(editor, {
clear: MARK_SUBSCRIPT,
key: MARK_SUPERSCRIPT,
clear: [MARK_SUPERSCRIPT, MARK_SUBSCRIPT],
key: MARK_SUBSCRIPT,
});
focusEditor(editor);
}}
Expand Down
20 changes: 15 additions & 5 deletions packages/combobox/src/hooks/useHTMLInputCursorState.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { type RefObject, useCallback, useEffect, useState, useMemo } from 'react';
import {
type RefObject,
useCallback,
useEffect,
useMemo,
useState,
} from 'react';

import type { ComboboxInputCursorState } from '../types';

Expand All @@ -12,6 +18,7 @@ export const useHTMLInputCursorState = (
// Wait for events to finish processing
setTimeout(() => {
if (!ref.current) return;

const { selectionEnd, selectionStart, value } = ref.current;
setAtStart(selectionStart === 0);
setAtEnd(selectionEnd === value.length);
Expand Down Expand Up @@ -45,8 +52,11 @@ export const useHTMLInputCursorState = (
};
}, [recomputeCursorState, ref]);

return useMemo(() => ({
atStart,
atEnd,
}), [atStart, atEnd]);
return useMemo(
() => ({
atEnd,
atStart,
}),
[atStart, atEnd]
);
};
2 changes: 1 addition & 1 deletion packages/normalizers/src/createRemoveEmptyNodesPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface RemoveEmptyNodesPlugin {
types?: string | string[];
}

export const KEY_REMOVE_EMPTY_NODES = 'removeEmptyNodes'
export const KEY_REMOVE_EMPTY_NODES = 'removeEmptyNodes';

/** @see {@link withRemoveEmptyNodes} */
export const createRemoveEmptyNodesPlugin =
Expand Down
13 changes: 7 additions & 6 deletions packages/plate-utils/src/useFormInputProps.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
interface InputProps {
/**
* Should we activate the onKeyDownCapture handler to preventDefault when
* the user presses enter?
* Should we activate the onKeyDownCapture handler to preventDefault when the
* user presses enter?
*/
preventDefaultOnEnterKeydown?: boolean;
}
Expand All @@ -10,8 +10,9 @@ interface InputProps {
* Hook to allow the user to spread a set of predefined props to the Div wrapper
* of an Input element
*
* @param param0 an options object which can be expanded to add further functionality
* @returns a props object which can be spread onto the element
* @param param0 An options object which can be expanded to add further
* functionality
* @returns A props object which can be spread onto the element
*/
export const useFormInputProps = (options?: InputProps) => {
// Nothing provided to just return an empty object which can still be spread.
Expand All @@ -33,8 +34,8 @@ export const useFormInputProps = (options?: InputProps) => {
* By calling preventDefault we short circuit the form's submission thus
* allowing the user to continue filling in the other fields
*
* @param e The original event which was provided by the VDOM
* implement their own behaviour on this event
* @param e The original event which was provided by the VDOM implement their
* own behaviour on this event
*/
const handleEnterKeydownCapture = (
e: React.KeyboardEvent<HTMLDivElement>
Expand Down
2 changes: 1 addition & 1 deletion packages/selection/src/queries/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
*/

export * from './getSelectedBlocks';
export * from "./isNodeBlockSelected";
export * from './isNodeBlockSelected';
4 changes: 2 additions & 2 deletions packages/table/src/queries/getTableColumnCount.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { TElement } from '@udecode/slate';

import { getTableColumnCount } from './getTableColumnCount';
import { TElement } from '@udecode/slate';

describe('getTableColumnCount', () => {
it('should return 0 if tableNode has no children', () => {
Expand Down Expand Up @@ -54,4 +54,4 @@ describe('getTableColumnCount', () => {
const result = getTableColumnCount(tableNode);
expect(result).toBe(3);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export function MoreDropdownMenu(props: DropdownMenuProps) {
<DropdownMenuItem
onSelect={() => {
toggleMark(editor, {
key: MARK_SUBSCRIPT,
clear: MARK_SUPERSCRIPT,
clear: [MARK_SUBSCRIPT, MARK_SUPERSCRIPT],
key: MARK_SUPERSCRIPT,
});
focusEditor(editor);
}}
Expand All @@ -46,8 +46,8 @@ export function MoreDropdownMenu(props: DropdownMenuProps) {
<DropdownMenuItem
onSelect={() => {
toggleMark(editor, {
key: MARK_SUPERSCRIPT,
clear: MARK_SUBSCRIPT,
clear: [MARK_SUPERSCRIPT, MARK_SUBSCRIPT],
key: MARK_SUBSCRIPT,
});
focusEditor(editor);
}}
Expand Down