1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-23 15:32:59 +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 = ( const spacer = (
<Tag <Tag data-slate-spacer style={style}>
contentEditable
data-slate-spacer
suppressContentEditableWarning
style={style}
>
{this.renderText()} {this.renderText()}
</Tag> </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 }) this.debug('render', { props })
return ( return (
<Tag <Tag data-slate-void data-key={node.key}>
data-slate-void
data-key={node.key}
contentEditable={readOnly ? null : false}
>
{readOnly ? null : spacer} {readOnly ? null : spacer}
{content} {content}
</Tag> </Tag>

View File

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

View File

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