You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The spacebar is used on a <summary> element to toggle its parent <details> open/closed. Because of this, we do this horribly hacky thing to prevent the default behavior in the editor, but still insert a space:
* Insert a space at the current position of the cursor and then adjust
* the cursor position, accounting for any selection it has made.
*
* @param {Node} node
*/
constinsertSpace=(node)=>{
const{ ownerDocument }=node;
const{ defaultView }=ownerDocument;
constsel=defaultView.getSelection();
constrange=sel.getRangeAt(0);
consttextNode=document.createTextNode(' ');
range.deleteContents();
range.insertNode(textNode);
range.setStartAfter(textNode);
};
This works, though it can be annoying because there's a slight lag before the space is inserted. If you're typing at any kind of pace at all, you may need to go back and correct the spaces.
The answer may be to use different markup in the editor, though it's nice to present the component as it will be presented on the front-end.
Maybe we could consider presenting different markup when the block is focused in the editor?
The text was updated successfully, but these errors were encountered:
The spacebar is used on a
<summary>
element to toggle its parent<details>
open/closed. Because of this, we do this horribly hacky thing to prevent the default behavior in the editor, but still insert a space:show-hide-section-block/blocks/show-hide-section/index.js
Lines 14 to 31 in 3603b3b
This works, though it can be annoying because there's a slight lag before the space is inserted. If you're typing at any kind of pace at all, you may need to go back and correct the spaces.
The answer may be to use different markup in the editor, though it's nice to present the component as it will be presented on the front-end.
Maybe we could consider presenting different markup when the block is focused in the editor?
The text was updated successfully, but these errors were encountered: