Skip to content

Commit 8601f3d

Browse files
committed
fix #844
1 parent c18d3ce commit 8601f3d

28 files changed

+1695
-515
lines changed

src/blocks/box/block.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://schemas.wp.org/trunk/block.json",
33
"apiVersion": 3,
4-
"version": "22.3.1",
4+
"version": "23.0.1",
55
"textdomain": "snow-monkey-blocks",
66
"name": "snow-monkey-blocks/box",
77
"title": "Box",

src/blocks/box/view.js

+3-43
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,10 @@
1+
import { boxLink } from '../../js/helper/helper';
2+
13
document.addEventListener( 'DOMContentLoaded', () => {
24
const boxes = document.querySelectorAll( '.smb-box--has-link' );
35

46
[].slice.call( boxes ).forEach( ( box ) => {
5-
let down, up;
67
const link = box.querySelector( ':scope > .smb-box__link' );
7-
8-
if ( !! link ) {
9-
box.addEventListener( 'pointerdown', ( event ) => {
10-
event.stopPropagation();
11-
down = +new Date();
12-
} );
13-
14-
box.addEventListener( 'pointerup', ( event ) => {
15-
event.stopPropagation();
16-
17-
if ( 0 !== event.button ) {
18-
return false;
19-
}
20-
21-
if (
22-
[ 'A', 'BUTTON', 'INPUT', 'SELECT', 'TEXTAREA' ].includes(
23-
event.target?.tagName
24-
)
25-
) {
26-
return false;
27-
}
28-
29-
up = +new Date();
30-
if ( up - down < 200 ) {
31-
const pressedKeys =
32-
event.shiftKey || event.ctrlKey || event.metaKey;
33-
if ( pressedKeys ) {
34-
const originalTarget = link.getAttribute( 'target' );
35-
const originalRel = link.getAttribute( 'rel' );
36-
link.setAttribute( 'target', '_blank' );
37-
link.setAttribute( 'rel', 'noopener noreferrer' );
38-
39-
link.click();
40-
41-
link.setAttribute( 'target', originalTarget || '' );
42-
link.setAttribute( 'rel', originalRel || '' );
43-
} else {
44-
link.click();
45-
}
46-
}
47-
} );
48-
}
8+
boxLink( box, link );
499
} );
5010
} );

src/blocks/items/item/banner/block.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"$schema": "https://schemas.wp.org/trunk/block.json",
33
"apiVersion": 3,
4+
"version": "23.0.1",
45
"textdomain": "snow-monkey-blocks",
56
"name": "snow-monkey-blocks/items-banner",
67
"title": "Banner",

src/blocks/items/item/banner/edit.js

+2
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ export default function ( {
468468
} )
469469
}
470470
ref={ richTextRef }
471+
withoutInteractiveFormatting
471472
/>
472473
) }
473474

@@ -485,6 +486,7 @@ export default function ( {
485486
lede: value,
486487
} )
487488
}
489+
withoutInteractiveFormatting
488490
/>
489491
) }
490492
</div>

src/blocks/items/item/block-link/block.json

+15-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"$schema": "https://schemas.wp.org/trunk/block.json",
33
"apiVersion": 3,
4+
"version": "23.0.1",
45
"textdomain": "snow-monkey-blocks",
56
"name": "snow-monkey-blocks/items-item-block-link",
67
"title": "Item (Block Link)",
@@ -33,16 +34,20 @@
3334
"url": {
3435
"type": "string",
3536
"source": "attribute",
36-
"selector": ".smb-items__item--block-link",
37-
"attribute": "href",
38-
"default": ""
37+
"selector": ".smb-items__item__action > a",
38+
"attribute": "href"
39+
},
40+
"rel": {
41+
"type": "string",
42+
"source": "attribute",
43+
"selector": ".smb-items__item__action > a",
44+
"attribute": "rel"
3945
},
4046
"target": {
4147
"type": "string",
4248
"source": "attribute",
43-
"selector": ".smb-items__item--block-link",
44-
"attribute": "target",
45-
"default": "_self"
49+
"selector": ".smb-items__item__action > a",
50+
"attribute": "target"
4651
},
4752
"displayImage": {
4853
"type": "boolean",
@@ -91,8 +96,8 @@
9196
"btnLabel": {
9297
"type": "string",
9398
"source": "html",
94-
"selector": ".smb-items__item__btn > .smb-btn__label",
95-
"default": ""
99+
"selector": ".smb-items__item__action > a > span",
100+
"role": "content"
96101
},
97102
"btnBackgroundColor": {
98103
"type": "string"
@@ -124,5 +129,6 @@
124129
"link": true
125130
}
126131
},
127-
"editorScript": "file:./index.js"
132+
"editorScript": "file:./index.js",
133+
"viewScript": "file:./view.js"
128134
}

0 commit comments

Comments
 (0)