Skip to content

Commit

Permalink
Simplify UI
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Mar 30, 2023
1 parent 8828a3b commit 070e182
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 35 deletions.
10 changes: 7 additions & 3 deletions packages/block-editor/src/components/rich-text/content.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Should be in theme compatibility file.
.editor-styles-wrapper { counter-reset:footnotes }
.editor-styles-wrapper {
counter-reset: footnotes;
}

.rich-text {
[data-rich-text-placeholder] {
Expand All @@ -23,9 +25,11 @@
}

// Should be in theme compatibility file.
.note-link { counter-increment:footnotes }
.note-link {
counter-increment: footnotes;
}
.note-link::after {
content: "[" counter( footnotes ) "]";
content: "[" counter(footnotes) "]";
vertical-align: super;
font-size: smaller;
}
Expand Down
42 changes: 10 additions & 32 deletions packages/format-library/src/footnote/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,8 @@
import { __ } from '@wordpress/i18n';
import { insertObject, useAnchor } from '@wordpress/rich-text';
import { RichTextToolbarButton } from '@wordpress/block-editor';
import { formatListNumbered, keyboardReturn } from '@wordpress/icons';
import {
Popover,
Button,
TextControl,
__experimentalHStack as HStack,
} from '@wordpress/components';
import { useState } from '@wordpress/element';
import { formatListNumbered } from '@wordpress/icons';
import { Popover, TextControl } from '@wordpress/components';

const name = 'core/footnote';
const title = __( 'Footnote' );
Expand Down Expand Up @@ -67,7 +61,6 @@ export const footnote = {
function InlineUI( { value, onChange, activeObjectAttributes, contentRef } ) {
const { 'data-shortcode-content': shortcodeContent } =
activeObjectAttributes;
const [ note, setNote ] = useState( shortcodeContent );
const popoverAnchor = useAnchor( {
editableContentElement: contentRef.current,
settings: footnote,
Expand All @@ -76,46 +69,31 @@ function InlineUI( { value, onChange, activeObjectAttributes, contentRef } ) {
return (
<Popover
placement="bottom"
focusOnMount={ false }
focusOnMount={ true }
anchor={ popoverAnchor }
className="block-editor-format-toolbar__image-popover"
>
<form
className="block-editor-format-toolbar__image-container-content"
onSubmit={ ( event ) => {
<TextControl
className="block-editor-format-toolbar__image-container-value"
label={ __( 'Note' ) }
value={ shortcodeContent }
onChange={ ( newNote ) => {
const newReplacements = value.replacements.slice();

newReplacements[ value.start ] = {
type: name,
attributes: {
...activeObjectAttributes,
'data-shortcode-content': note,
'data-shortcode-content': newNote,
},
};

onChange( {
...value,
replacements: newReplacements,
} );

event.preventDefault();
} }
>
<HStack alignment="bottom" spacing="0">
<TextControl
className="block-editor-format-toolbar__image-container-value"
label={ __( 'Note' ) }
value={ note }
onChange={ ( newNote ) => setNote( newNote ) }
/>
<Button
className="block-editor-format-toolbar__image-container-button"
icon={ keyboardReturn }
label={ __( 'Apply' ) }
type="submit"
/>
</HStack>
</form>
/>
</Popover>
);
}

0 comments on commit 070e182

Please sign in to comment.