Skip to content

Commit f29bcd8

Browse files
committed
chore: better code
1 parent 06fd01e commit f29bcd8

File tree

6 files changed

+6
-12
lines changed

6 files changed

+6
-12
lines changed

src/components/editor/components/toolbar/selection-toolbar/SelectionToolbar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function SelectionToolbar() {
4646
<div
4747
ref={ref}
4848
className={
49-
'selection-toolbar pointer-events-none transform transition-opacity duration-200 absolute z-[100] flex min-h-[32px] w-fit flex-grow items-center rounded-lg bg-[var(--surface-primary)] px-2 py-[var(--spacing-spacing-xs)] opacity-0 shadow-toolbar'
49+
'selection-toolbar pointer-events-none transform transition-opacity duration-200 absolute z-[100] flex min-h-[32px] w-fit flex-grow items-center rounded-[var(--border-radius-border-radius-l)] bg-[var(--surface-primary)] px-2 py-[var(--spacing-spacing-xs)] opacity-0 shadow-toolbar'
5050
}
5151
onMouseDown={(e) => {
5252
// prevent toolbar from taking focus away from editor

src/components/editor/components/toolbar/selection-toolbar/actions/Align.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import Button from '@mui/material/Button';
22
import { PopoverProps } from '@mui/material/Popover';
3-
import { useCallback, useEffect, useRef, useState } from 'react';
3+
import { cloneElement, useCallback, useEffect, useRef, useState } from 'react';
44
import { useTranslation } from 'react-i18next';
55
import { Element } from 'slate';
66
import { useSlateStatic } from 'slate-react';
7-
import React from 'react';
87

98
import { YjsEditor } from '@/application/slate-yjs';
109
import { CustomEditor } from '@/application/slate-yjs/command';
@@ -76,6 +75,7 @@ export function Align({ blockId, enabled = true }: { blockId?: string; enabled?:
7675
const getAlign = useCallback(() => {
7776
try {
7877
const node = getNode();
78+
7979
return (node.data as BlockData).align;
8080
} catch (e) {
8181
return;
@@ -93,7 +93,8 @@ export function Align({ blockId, enabled = true }: { blockId?: string; enabled?:
9393
const activeIcon = useCallback(() => {
9494
const align = getAlign();
9595
const option = alignOptions.find(opt => opt.type === align) || alignOptions[0];
96-
return React.cloneElement(option.icon, {
96+
97+
return cloneElement(option.icon, {
9798
className: `h-5 w-5 ${align ? 'text-fill-default' : ''}`
9899
});
99100
}, [getAlign]);
@@ -103,6 +104,7 @@ export function Align({ blockId, enabled = true }: { blockId?: string; enabled?:
103104
return () => {
104105
try {
105106
const node = getNode();
107+
106108
CustomEditor.setBlockData(editor, node.blockId as string, { align });
107109
handleClose();
108110
rePosition();

src/components/editor/components/toolbar/selection-toolbar/actions/BulletedList.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import { ReactComponent as BulletedListSvg } from '@/assets/icons/bulleted_list.
1010

1111
import ActionButton from './ActionButton';
1212

13-
14-
1513
export function BulletedList() {
1614
const { t } = useTranslation();
1715
const editor = useSlateStatic() as YjsEditor;

src/components/editor/components/toolbar/selection-toolbar/actions/Color.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import { renderColor } from '@/utils/color';
1414

1515
import ActionButton from './ActionButton';
1616

17-
18-
1917
function Color() {
2018
const { t } = useTranslation();
2119
const { visible: toolbarVisible } = useSelectionToolbarContext();

src/components/editor/components/toolbar/selection-toolbar/actions/NumberedList.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import { ReactComponent as NumberedListSvg } from '@/assets/icons/numbered_list.
1010

1111
import ActionButton from './ActionButton';
1212

13-
14-
1513
export function NumberedList() {
1614
const { t } = useTranslation();
1715
const editor = useSlateStatic() as YjsEditor;

src/components/editor/components/toolbar/selection-toolbar/actions/Quote.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import { ReactComponent as QuoteSvg } from '@/assets/icons/quote.svg';
1010

1111
import ActionButton from './ActionButton';
1212

13-
14-
1513
export function Quote() {
1614
const { t } = useTranslation();
1715
const editor = useSlateStatic() as YjsEditor;

0 commit comments

Comments
 (0)