Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ const DEFAULT_BLOCK_CONTEXT = {};

export const usesContextKey = Symbol( 'usesContext' );

function Edit( { onChange, onFocus, value, forwardedRef, settings } ) {
function Edit( {
onChange,
onFocus,
value,
forwardedRef,
settings,
isVisible,
} ) {
const {
name,
edit: EditFunction,
Expand Down Expand Up @@ -47,6 +54,7 @@ function Edit( { onChange, onFocus, value, forwardedRef, settings } ) {
<EditFunction
key={ name }
isActive={ isActive }
isVisible={ isVisible }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to confirm this is web only for now. Only mentioning since there's an index.native.js as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the native code still being maintained at all? There doesn't seem to be much recent movement on those files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good questions. I suppose it can't hurt to update the native code's format-edit.js file, too?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I might have been hallucinating. index.native.js doesn't even use format-edit' so probably not worth it.

Sorry for the red herring!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries, thanks for looking! I'll let this PR simmer for a bit to see what folks think.

activeAttributes={ isActive ? activeFormat.attributes || {} : {} }
isObjectActive={ isObjectActive }
activeObjectAttributes={
Expand Down
22 changes: 12 additions & 10 deletions packages/format-library/src/bold/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const bold = {
tagName: 'strong',
className: null,
[ essentialFormatKey ]: true,
edit( { isActive, value, onChange, onFocus } ) {
edit( { isActive, value, onChange, onFocus, isVisible = true } ) {
function onToggle() {
onChange( toggleFormat( value, { type: name, title } ) );
}
Expand All @@ -44,15 +44,17 @@ export const bold = {
character="b"
onUse={ onToggle }
/>
<RichTextToolbarButton
name="bold"
icon={ formatBold }
title={ title }
onClick={ onClick }
isActive={ isActive }
shortcutType="primary"
shortcutCharacter="b"
/>
{ isVisible && (
<RichTextToolbarButton
name="bold"
icon={ formatBold }
title={ title }
onClick={ onClick }
isActive={ isActive }
shortcutType="primary"
shortcutCharacter="b"
/>
) }
<__unstableRichTextInputEvent
inputType="formatBold"
onInput={ onToggle }
Expand Down
22 changes: 12 additions & 10 deletions packages/format-library/src/italic/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const italic = {
tagName: 'em',
className: null,
[ essentialFormatKey ]: true,
edit( { isActive, value, onChange, onFocus } ) {
edit( { isActive, value, onChange, onFocus, isVisible = true } ) {
function onToggle() {
onChange( toggleFormat( value, { type: name, title } ) );
}
Expand All @@ -44,15 +44,17 @@ export const italic = {
character="i"
onUse={ onToggle }
/>
<RichTextToolbarButton
name="italic"
icon={ formatItalic }
title={ title }
onClick={ onClick }
isActive={ isActive }
shortcutType="primary"
shortcutCharacter="i"
/>
{ isVisible && (
<RichTextToolbarButton
name="italic"
icon={ formatItalic }
title={ title }
onClick={ onClick }
isActive={ isActive }
shortcutType="primary"
shortcutCharacter="i"
/>
) }
<__unstableRichTextInputEvent
inputType="formatItalic"
onInput={ onToggle }
Expand Down
29 changes: 16 additions & 13 deletions packages/format-library/src/link/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function Edit( {
onChange,
onFocus,
contentRef,
isVisible = true,
} ) {
const [ addingLink, setAddingLink ] = useState( false );

Expand Down Expand Up @@ -190,19 +191,21 @@ function Edit( {
character="k"
onUse={ onRemoveFormat }
/>
<RichTextToolbarButton
name="link"
icon={ linkIcon }
title={ isActive ? __( 'Link' ) : title }
onClick={ ( event ) => {
addLink( event.currentTarget );
} }
isActive={ isActive || addingLink }
shortcutType="primary"
shortcutCharacter="k"
aria-haspopup="true"
aria-expanded={ addingLink }
/>
{ isVisible && (
<RichTextToolbarButton
name="link"
icon={ linkIcon }
title={ isActive ? __( 'Link' ) : title }
onClick={ ( event ) => {
addLink( event.currentTarget );
} }
isActive={ isActive || addingLink }
shortcutType="primary"
shortcutCharacter="k"
aria-haspopup="true"
aria-expanded={ addingLink }
/>
) }
{ addingLink && (
<InlineLinkUI
stopAddingLink={ stopAddingLink }
Expand Down
Loading