1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-18 05:01:17 +02:00

fix: make void node selectable for edge case, close: #1639 (#1734)

This commit is contained in:
Benjy Cui
2018-04-28 04:42:53 +08:00
committed by Ian Storm Taylor
parent 42ff90e9cd
commit fb172dec6f
3 changed files with 16 additions and 18 deletions

View File

@@ -66,26 +66,24 @@ class Void extends React.Component {
}
const spacer = (
<Tag
contentEditable
data-slate-spacer
suppressContentEditableWarning
style={style}
>
<Tag data-slate-spacer style={style}>
{this.renderText()}
</Tag>
)
const content = <Tag draggable={readOnly ? null : true}>{children}</Tag>
const content = (
<Tag
contentEditable={readOnly ? null : false}
draggable={readOnly ? null : true}
>
{children}
</Tag>
)
this.debug('render', { props })
return (
<Tag
data-slate-void
data-key={node.key}
contentEditable={readOnly ? null : false}
>
<Tag data-slate-void data-key={node.key}>
{readOnly ? null : spacer}
{content}
</Tag>

View File

@@ -31,15 +31,15 @@ export const value = (
export const output = `
<div data-slate-editor="true" contenteditable="true" role="textbox">
<div data-slate-void="true" contenteditable="false">
<div contenteditable="true" data-slate-spacer="true" style="height:0;color:transparent;outline:none">
<div data-slate-void="true">
<div data-slate-spacer="true" style="height:0;color:transparent;outline:none">
<span>
<span>
<span data-slate-zero-width="z">&#x200B;</span>
</span>
</span>
</div>
<div draggable="true">
<div contenteditable="false" draggable="true">
<img src="https://example.com/image.png">
</div>
</div>

View File

@@ -36,15 +36,15 @@ export const output = `
<span data-slate-zero-width="z">&#x200B;</span>
</span>
</span>
<span data-slate-void="true" contenteditable="false">
<span contenteditable="true" data-slate-spacer="true" style="height:0;color:transparent;outline:none">
<span data-slate-void="true">
<span data-slate-spacer="true" style="height:0;color:transparent;outline:none">
<span>
<span>
<span data-slate-zero-width="z">&#x200B;</span>
</span>
</span>
</span>
<span draggable="true">
<span contenteditable="false" draggable="true">
<img>
</span>
</span>