Skip to content

Commit

Permalink
PLANET-7635 Move remaining code from plugin
Browse files Browse the repository at this point in the history
This is in preparation to finally retire it
  • Loading branch information
mleray committed Dec 18, 2024
1 parent 7fe3e28 commit 6bb6fea
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
18 changes: 18 additions & 0 deletions assets/src/block-editor/addButtonLinkPasteWarning.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export const addButtonLinkPasteWarning = () => document.addEventListener('DOMContentLoaded', () => {
document.onpaste = event => {
const {target} = event;
if (!target.matches('.wp-block-button__link, .wp-block-button__link *')) {
return;
}

const aTags = target.querySelectorAll('a');
if (aTags.length) {
const {__} = wp.i18n;
// eslint-disable-next-line no-alert
alert(__(
'You are pasting a link into the button text. Please ensure your clipboard only has text in it. Alternatively you can press control/command + SHIFT + V to paste only the text in your clipboard.',
'planet4-blocks-backend'
));
}
};
});
12 changes: 6 additions & 6 deletions assets/src/editorIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {registerColumnsBlock} from './blocks/Columns/ColumnsBlock';
import {registerBlockStyles} from './block-styles';
import {registerBlockVariations} from './block-variations';
import {registerActionButtonTextBlock} from './blocks/ActionCustomButtonText';
import {addButtonLinkPasteWarning} from './block-editor/addButtonLinkPasteWarning';

wp.domReady(() => {
// Blocks
Expand All @@ -37,10 +38,9 @@ wp.domReady(() => {

// Block variations
registerBlockVariations();
});

setupCustomSidebar();
setupQueryLoopBlockExtension();

// Setup new attributes to the core/query.
// It should be executed after the DOM is ready
setupQueryLoopBlockExtension();
// Editor behaviour.
setupCustomSidebar();
addButtonLinkPasteWarning();
});
1 change: 1 addition & 0 deletions assets/src/scss/blocks.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
@import "blocks/core-overrides/Columns";
@import "blocks/core-overrides/Heading";
@import "blocks/core-overrides/Embed";
@import "blocks/core-overrides/File";

// Other
@import "blocks/WideBlocks";
Expand Down
6 changes: 6 additions & 0 deletions assets/src/scss/blocks/core-overrides/File.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.wp-block-file .wp-block-file__button {
overflow: unset;
padding: 0 1em;
margin-inline-start: 1em;
font-size: .8em;
}

0 comments on commit 6bb6fea

Please sign in to comment.