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: Added table cell actions menu for adding/removing rows and columns to Super note tables and merging cells #2508

Merged
merged 5 commits into from
Sep 16, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,23 @@ import { classNames } from '@standardnotes/utils'
import StyledTooltip from '../StyledTooltip/StyledTooltip'

type Props = {
onClick: () => void
onClick: MouseEventHandler
className?: string
icon: IconType
iconClassName?: string
iconProps?: Partial<Parameters<typeof Icon>[0]>
label: string
id?: string
} & ComponentPropsWithoutRef<'button'>

const RoundIconButton = forwardRef(
(
{ onClick, className, icon: iconType, iconClassName, id, label, ...props }: Props,
{ onClick, className, icon: iconType, iconClassName, iconProps, id, label, ...props }: Props,
ref: ForwardedRef<HTMLButtonElement>,
) => {
const click: MouseEventHandler = (e) => {
e.preventDefault()
onClick()
onClick(e)
}
return (
<StyledTooltip label={label}>
Expand All @@ -37,7 +38,7 @@ const RoundIconButton = forwardRef(
aria-label={label}
{...props}
>
<Icon type={iconType} className={iconClassName} />
<Icon {...iconProps} type={iconType} className={iconClassName} />
</button>
</StyledTooltip>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { SuperEditorContentId } from './Constants'
import { classNames } from '@standardnotes/utils'
import { MarkdownTransformers } from './MarkdownTransformers'
import { RemoveBrokenTablesPlugin } from './Plugins/TablePlugin'
import TableActionMenuPlugin from './Plugins/TableCellActionMenuPlugin'

type BlocksEditorProps = {
onChange?: (value: string, preview: string) => void
Expand Down Expand Up @@ -92,7 +93,7 @@ export const BlocksEditor: FunctionComponent<BlocksEditorProps> = ({
/>
<ListPlugin />
<MarkdownShortcutPlugin transformers={MarkdownTransformers} />
<TablePlugin />
<TablePlugin hasCellMerge />
<OnChangePlugin onChange={handleChange} ignoreSelectionChange={true} />
<HistoryPlugin />
<HorizontalRulePlugin />
Expand All @@ -111,6 +112,7 @@ export const BlocksEditor: FunctionComponent<BlocksEditorProps> = ({
<>
<FloatingTextFormatToolbarPlugin anchorElem={floatingAnchorElem} />
<DraggableBlockPlugin anchorElem={floatingAnchorElem} />
<TableActionMenuPlugin anchorElem={floatingAnchorElem} cellMerge />
</>
)}
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,9 @@ body {
z-index: 10;
display: block;
position: fixed;
box-shadow: 0 12px 28px 0 rgba(0, 0, 0, 0.2), 0 2px 4px 0 rgba(0, 0, 0, 0.1),
box-shadow:
0 12px 28px 0 rgba(0, 0, 0, 0.2),
0 2px 4px 0 rgba(0, 0, 0, 0.1),
inset 0 0 0 1px rgba(255, 255, 255, 0.5);
border-radius: 8px;
min-height: 40px;
Expand Down Expand Up @@ -657,15 +659,6 @@ body {
cursor: pointer;
}

i.chevron-down {
background-color: transparent;
background-size: contain;
display: inline-block;
height: 8px;
width: 8px;
background-image: url(#{$blocks-editor-icons-path}/chevron-down.svg);
}

.action-button {
background-color: #eee;
border: 0;
Expand Down Expand Up @@ -860,24 +853,6 @@ body {
background-size: contain;
}

.toolbar i.chevron-down {
margin-top: 3px;
width: 16px;
height: 16px;
display: flex;
user-select: none;
}

.toolbar i.chevron-down.inside {
width: 16px;
height: 16px;
display: flex;
margin-left: -25px;
margin-top: 11px;
margin-right: 10px;
pointer-events: none;
}

.toolbar .divider {
width: 1px;
background-color: #eee;
Expand Down