mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-18 13:11:17 +02:00
Merge branch 'master' of github.com:ianstormtaylor/slate
This commit is contained in:
@@ -178,6 +178,7 @@ class Images extends React.Component {
|
||||
onDropNode = (e, data, state) => {
|
||||
return state
|
||||
.transform()
|
||||
.unsetSelection()
|
||||
.removeNodeByKey(data.node.key)
|
||||
.moveTo(data.target)
|
||||
.insertBlock(data.node)
|
||||
|
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "slate",
|
||||
"description": "A completely customizable framework for building rich text editors.",
|
||||
"version": "0.14.3",
|
||||
"version": "0.14.4",
|
||||
"license": "MIT",
|
||||
"repository": "git://github.com/ianstormtaylor/slate.git",
|
||||
"main": "./lib/index.js",
|
||||
|
@@ -287,14 +287,14 @@ class Text extends new Record(DEFAULTS) {
|
||||
*/
|
||||
|
||||
updateMark(index, length, mark, properties) {
|
||||
const m = mark.merge(properties)
|
||||
const characters = this.characters.map((char, i) => {
|
||||
if (i < index) return char
|
||||
if (i >= index + length) return char
|
||||
let { marks } = char
|
||||
const j = marks.indexOf(mark)
|
||||
let m = marks.get(j)
|
||||
m = m.merge(properties)
|
||||
marks = marks.set(j, m)
|
||||
if (!marks.has(mark)) return char
|
||||
marks = marks.remove(mark)
|
||||
marks = marks.add(m)
|
||||
char = char.merge({ marks })
|
||||
return char
|
||||
})
|
||||
|
@@ -0,0 +1,21 @@
|
||||
|
||||
export default function (state) {
|
||||
const { document, selection } = state
|
||||
const first = document.getTexts().first()
|
||||
|
||||
return state
|
||||
.transform()
|
||||
.setMarkByKey(
|
||||
first.key,
|
||||
0,
|
||||
first.length,
|
||||
{
|
||||
type: 'bold',
|
||||
data: { key: true }
|
||||
},
|
||||
{
|
||||
data: { key: false }
|
||||
}
|
||||
)
|
||||
.apply()
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
|
||||
nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
ranges:
|
||||
- text: word
|
||||
marks:
|
||||
- type: bold
|
||||
data:
|
||||
key: true
|
@@ -0,0 +1,12 @@
|
||||
|
||||
nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
ranges:
|
||||
- text: word
|
||||
marks:
|
||||
- type: bold
|
||||
data:
|
||||
key: false
|
Reference in New Issue
Block a user