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

Merge branch 'master' of github.com:ianstormtaylor/slate

This commit is contained in:
Ian Storm Taylor
2018-04-27 15:28:18 -07:00
27 changed files with 263 additions and 85 deletions

View File

@@ -13,7 +13,7 @@
"lib/"
],
"dependencies": {
"debug": "^2.3.2",
"debug": "^3.1.0",
"get-window": "^1.1.1",
"is-window": "^1.0.2",
"keycode": "^2.1.2",

View File

@@ -99,9 +99,21 @@ class Leaf extends React.Component {
const { marks, node, offset, text, editor } = this.props
const { stack } = editor
const leaf = this.renderText()
const attributes = {
'data-slate-leaf': true,
}
return marks.reduce((children, mark) => {
const props = { editor, mark, marks, node, offset, text, children }
const props = {
editor,
mark,
marks,
node,
offset,
text,
children,
attributes,
}
const element = stack.find('renderMark', props)
return element || children
}, leaf)

View File

@@ -305,8 +305,8 @@ function AfterPlugin() {
// Get the selection point.
const native = window.getSelection()
const { anchorNode, anchorOffset } = native
const point = findPoint(anchorNode, anchorOffset, value)
const { anchorNode } = native
const point = findPoint(anchorNode, 0, value)
if (!point) return
// Get the text node and leaf in question.
@@ -323,7 +323,7 @@ function AfterPlugin() {
leaves.find(r => {
start = end
end += r.text.length
if (end >= point.offset) return true
if (end > point.offset) return true
}) || lastLeaf
// Get the text information.

View File

@@ -17,7 +17,7 @@ function decorateNode(block) {
}
function Bold(props) {
return React.createElement('strong', null, props.children)
return React.createElement('strong', { ...props.attributes }, props.children)
}
function renderMark(props) {
@@ -45,7 +45,7 @@ export const output = `
<div style="position:relative">
<span>
<span>o</span>
<span><strong>n</strong></span>
<span><strong data-slate-leaf="true">n</strong></span>
<span>e</span>
</span>
</div>

View File

@@ -4,7 +4,7 @@ import React from 'react'
import h from '../../helpers/h'
function Bold(props) {
return React.createElement('strong', null, props.children)
return React.createElement('strong', { ...props.attributes }, props.children)
}
function renderMark(props) {
@@ -33,7 +33,7 @@ export const output = `
<div style="position:relative">
<span>
<span>one</span>
<span><strong>two</strong></span>
<span><strong data-slate-leaf="true">two</strong></span>
<span>three</span>
</span>
</div>