Skip to content
Open
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
25 changes: 4 additions & 21 deletions packages/plugin-seo/src/fields/Preview/PreviewComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,34 +118,17 @@ export const PreviewComponent: React.FC<PreviewProps> = (props) => {
boxShadow: '0px 0px 10px rgba(0, 0, 0, 0.1)',
maxWidth: '600px',
padding: '20px',
pointerEvents: 'none',
width: '100%',
}}
>
<div>
<a
href={href}
style={{
textDecoration: 'none',
}}
>
{href || 'https://...'}
</a>
</div>
<h4
<div>{href || 'https://...'}</div>
<div
style={{
margin: 0,
}}
>
<a
href="/"
style={{
textDecoration: 'none',
}}
>
{metaTitle as string}
</a>
</h4>
{metaTitle as string}
</div>
<p
style={{
margin: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const toolbarGroups = ({ disabledNodes }: IndentFeatureProps): ToolbarGroup[] =>
toolbarIndentGroupWithItems([
{
ChildComponent: IndentDecreaseIcon,
isActive: () => false,
isEnabled: ({ selection }) => {
const nodes = selection?.getNodes() ?? []

Expand All @@ -41,7 +40,6 @@ const toolbarGroups = ({ disabledNodes }: IndentFeatureProps): ToolbarGroup[] =>
},
{
ChildComponent: IndentIncreaseIcon,
isActive: () => false,
isEnabled: ({ selection }) => {
const nodes = selection?.getNodes() ?? []

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import type { LexicalEditor } from 'lexical'

import { Tooltip, useTranslation } from '@payloadcms/ui'
import { $addUpdateTag } from 'lexical'
import { $addUpdateTag, $getRoot, $getSelection, SKIP_SELECTION_FOCUS_TAG } from 'lexical'
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'

import type { ToolbarGroupItem } from '../../types.js'
Expand Down Expand Up @@ -59,22 +59,52 @@ export const ToolbarButton = ({
.join(' ')
}, [active, enabled, item.key])

const handleClick = useCallback(() => {
if (!enabled) {
return
}
const handleClick = useCallback(
(event: React.MouseEvent<HTMLButtonElement>) => {
if (!enabled) {
return
}

editor.focus(() => {
editor.update(() => {
$addUpdateTag('toolbar')
})
// We need to wrap the onSelect in the callback, so the editor is properly focused before the onSelect is called.
item.onSelect?.({
editor,
isActive: active,
if (event.detail === 0 && item.isActive) {
const button = event.currentTarget

editor.update(
() => {
$addUpdateTag('toolbar')
$addUpdateTag(SKIP_SELECTION_FOCUS_TAG)
if (!$getSelection()) {
$getRoot().selectEnd()
}
item.onSelect?.({ editor, isActive: active })
},
{
onUpdate: () => {
// Native selection repair can focus contenteditable in Chromium despite the tag.
if (
button.isConnected &&
button.ownerDocument.activeElement === editor.getRootElement()
) {
button.focus({ preventScroll: true })
}
},
},
)
return
}

editor.focus(() => {
editor.update(() => {
$addUpdateTag('toolbar')
})
// We need to wrap the onSelect in the callback, so the editor is properly focused before the onSelect is called.
item.onSelect?.({
editor,
isActive: active,
})
})
})
}, [editor, item, active, enabled])
},
[editor, item, active, enabled],
)

const handleMouseDown = useCallback((e: React.MouseEvent) => {
// This fixes a bug where you are unable to click the button if you are in a NESTED editor (editor in blocks field in editor).
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/elements/NoListResults/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
}

.no-results__title {
margin: 0;
color: var(--color-text);
font-size: var(--text-body-large-bold-font-size);
font-weight: var(--font-weight-strong);
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/elements/NoListResults/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type NoResultsProps = {
export function NoListResults({ Actions, description, title, withMargin }: NoResultsProps) {
return (
<div className={`${baseClass}${withMargin ? ` ${baseClass}--with-margin` : ''}`}>
{title ? <span className={`${baseClass}__title`}>{title}</span> : null}
{title ? <h2 className={`${baseClass}__title`}>{title}</h2> : null}
{description ? <p className={`${baseClass}__description`}>{description}</p> : null}
{Actions && Actions.length > 0 && (
<div className={`${baseClass}__actions`}>
Expand Down
Loading
Loading