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

Allow editing existing footnote from RichText formats toolbar #52506

Merged
merged 1 commit into from
Jul 11, 2023
Merged
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
36 changes: 21 additions & 15 deletions packages/block-library/src/footnotes/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,30 @@ export const format = {
} = useSelect( blockEditorStore );
const { selectionChange, insertBlock } =
useDispatch( blockEditorStore );

function onClick() {
registry.batch( () => {
const id = createId();
const newValue = insertObject(
value,
{
type: formatName,
attributes: {
'data-fn': id,
let id;
if ( isObjectActive ) {
const object = value.replacements[ value.start ];
id = object?.attributes?.[ 'data-fn' ];
} else {
id = createId();
const newValue = insertObject(
value,
{
type: formatName,
attributes: {
'data-fn': id,
},
innerHTML: `<a href="#${ id }" id="${ id }-link">*</a>`,
},
innerHTML: `<a href="#${ id }" id="${ id }-link">*</a>`,
},
value.end,
value.end
);
newValue.start = newValue.end - 1;

onChange( newValue );
value.end,
value.end
);
newValue.start = newValue.end - 1;
onChange( newValue );
}

// BFS search to find the first footnote block.
let fnBlock = null;
Expand Down
Loading