mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-11 09:43:58 +02:00
Merge pull request #494 from ianstormtaylor/text-around-inline
Fix to always have text nodes around inline nodes
This commit is contained in:
@@ -10,7 +10,6 @@ import Transfer from '../utils/transfer'
|
||||
import TYPES from '../constants/types'
|
||||
import getWindow from 'get-window'
|
||||
import keycode from 'keycode'
|
||||
import noop from '../utils/noop'
|
||||
import { IS_FIREFOX, IS_MAC } from '../constants/environment'
|
||||
|
||||
/**
|
||||
@@ -656,7 +655,7 @@ class Content extends React.Component {
|
||||
const anchorInline = document.getClosestInline(anchor.key)
|
||||
const focusInline = document.getClosestInline(focus.key)
|
||||
|
||||
if (anchorInline && anchor.offset == anchorText.length) {
|
||||
if (anchorInline && !anchorInline.isVoid && anchor.offset == anchorText.length) {
|
||||
const block = document.getClosestBlock(anchor.key)
|
||||
const next = block.getNextText(anchor.key)
|
||||
if (next) {
|
||||
@@ -665,7 +664,7 @@ class Content extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
if (focusInline && focus.offset == focusText.length) {
|
||||
if (focusInline && !focusInline.isVoid && focus.offset == focusText.length) {
|
||||
const block = document.getClosestBlock(focus.key)
|
||||
const next = block.getNextText(focus.key)
|
||||
if (next) {
|
||||
|
@@ -4,6 +4,7 @@ import CorePlugin from '../plugins/core'
|
||||
import Debug from 'debug'
|
||||
import React from 'react'
|
||||
import Schema from '../models/schema'
|
||||
import State from '../models/state'
|
||||
import noop from '../utils/noop'
|
||||
|
||||
/**
|
||||
@@ -58,7 +59,7 @@ class Editor extends React.Component {
|
||||
readOnly: React.PropTypes.bool,
|
||||
schema: React.PropTypes.object,
|
||||
spellCheck: React.PropTypes.bool,
|
||||
state: React.PropTypes.object.isRequired,
|
||||
state: React.PropTypes.instanceOf(State).isRequired,
|
||||
style: React.PropTypes.object
|
||||
};
|
||||
|
||||
|
@@ -1003,13 +1003,7 @@ const Node = {
|
||||
return this
|
||||
.getTexts()
|
||||
.find((text, i, texts) => {
|
||||
const next = texts.get(i + 1)
|
||||
length += text.length
|
||||
|
||||
// If the next text is an empty string, return false, because we want
|
||||
// the furthest text node at the offset, and it will also match.
|
||||
if (next && next.length == 0) return false
|
||||
|
||||
return length > offset
|
||||
})
|
||||
},
|
||||
|
@@ -4,7 +4,6 @@ import Character from '../models/character'
|
||||
import Debug from 'debug'
|
||||
import Placeholder from '../components/placeholder'
|
||||
import React from 'react'
|
||||
import String from '../utils/string'
|
||||
import getWindow from 'get-window'
|
||||
import { IS_MAC } from '../constants/environment'
|
||||
|
||||
@@ -455,7 +454,10 @@ function Plugin(options = {}) {
|
||||
/**
|
||||
* On `left` key down, move backward.
|
||||
*
|
||||
* COMPAT: This is required to solve for the case where an inline void node is
|
||||
* COMPAT: This is required to make navigating with the left arrow work when
|
||||
* a void node is selected.
|
||||
*
|
||||
* COMPAT: This is also required to solve for the case where an inline node is
|
||||
* surrounded by empty text nodes with zero-width spaces in them. Without this
|
||||
* the zero-width spaces will cause two arrow keys to jump to the next text.
|
||||
*
|
||||
@@ -467,23 +469,39 @@ function Plugin(options = {}) {
|
||||
|
||||
function onKeyDownLeft(e, data, state) {
|
||||
if (data.isCtrl) return
|
||||
if (data.isOpt) return
|
||||
if (data.isAlt) return
|
||||
if (state.isExpanded) return
|
||||
|
||||
const { document, startKey, startText } = state
|
||||
const hasVoidParent = document.hasVoidParent(startKey)
|
||||
|
||||
if (
|
||||
startText.text == '' ||
|
||||
hasVoidParent
|
||||
) {
|
||||
const previousText = document.getPreviousText(startKey)
|
||||
if (!previousText) return
|
||||
|
||||
// If the current text node is empty, or we're inside a void parent, we're
|
||||
// going to need to handle the selection behavior.
|
||||
if (startText.text == '' || hasVoidParent) {
|
||||
e.preventDefault()
|
||||
const previous = document.getPreviousText(startKey)
|
||||
|
||||
// If there's no previous text node in the document, abort.
|
||||
if (!previous) return
|
||||
|
||||
// If the previous text is in the current block, and inside a non-void
|
||||
// inline node, move one character into the inline node.
|
||||
const { startBlock } = state
|
||||
const previousBlock = document.getClosestBlock(previous.key)
|
||||
const previousInline = document.getClosestInline(previous.key)
|
||||
|
||||
if (previousBlock == startBlock && previousInline && !previousInline.isVoid) {
|
||||
return state
|
||||
.transform()
|
||||
.collapseToEndOf(previous)
|
||||
.moveBackward(1)
|
||||
.apply()
|
||||
}
|
||||
|
||||
// Otherwise, move to the end of the previous node.
|
||||
return state
|
||||
.transform()
|
||||
.collapseToEndOf(previousText)
|
||||
.collapseToEndOf(previous)
|
||||
.apply()
|
||||
}
|
||||
}
|
||||
@@ -491,10 +509,18 @@ function Plugin(options = {}) {
|
||||
/**
|
||||
* On `right` key down, move forward.
|
||||
*
|
||||
* COMPAT: This is required to solve for the case where an inline void node is
|
||||
* COMPAT: This is required to make navigating with the right arrow work when
|
||||
* a void node is selected.
|
||||
*
|
||||
* COMPAT: This is also required to solve for the case where an inline node is
|
||||
* surrounded by empty text nodes with zero-width spaces in them. Without this
|
||||
* the zero-width spaces will cause two arrow keys to jump to the next text.
|
||||
*
|
||||
* COMPAT: In Chrome & Safari, selections that are at the zero offset of
|
||||
* an inline node will be automatically replaced to be at the last offset
|
||||
* of a previous inline node, which screws us up, so we never want to set the
|
||||
* selection to the very start of an inline node here. (2016/11/29)
|
||||
*
|
||||
* @param {Event} e
|
||||
* @param {Object} data
|
||||
* @param {State} state
|
||||
@@ -503,30 +529,49 @@ function Plugin(options = {}) {
|
||||
|
||||
function onKeyDownRight(e, data, state) {
|
||||
if (data.isCtrl) return
|
||||
if (data.isOpt) return
|
||||
if (data.isAlt) return
|
||||
if (state.isExpanded) return
|
||||
|
||||
const { document, startKey, startText } = state
|
||||
const hasVoidParent = document.hasVoidParent(startKey)
|
||||
|
||||
if (
|
||||
startText.text == '' ||
|
||||
hasVoidParent
|
||||
) {
|
||||
const nextText = document.getNextText(startKey)
|
||||
if (!nextText) return state
|
||||
|
||||
// COMPAT: In Chrome & Safari, selections that are at the zero offset of
|
||||
// an inline node will be automatically replaced to be at the last offset
|
||||
// of a previous inline node, which screws us up, so we always want to set
|
||||
// it to the end of the node. (2016/11/29)
|
||||
const hasNextVoidParent = document.hasVoidParent(nextText.key)
|
||||
const method = hasNextVoidParent ? 'collapseToEndOf' : 'collapseToStartOf'
|
||||
|
||||
// If the current text node is empty, or we're inside a void parent, we're
|
||||
// going to need to handle the selection behavior.
|
||||
if (startText.text == '' || hasVoidParent) {
|
||||
e.preventDefault()
|
||||
const next = document.getNextText(startKey)
|
||||
|
||||
// If there's no next text node in the document, abort.
|
||||
if (!next) return state
|
||||
|
||||
// If the next text is inside a void node, move to the end of it.
|
||||
const isInVoid = document.hasVoidParent(next.key)
|
||||
|
||||
if (isInVoid) {
|
||||
return state
|
||||
.transform()
|
||||
.collapseToEndOf(next)
|
||||
.apply()
|
||||
}
|
||||
|
||||
// If the next text is in the current block, and inside an inline node,
|
||||
// move one character into the inline node.
|
||||
const { startBlock } = state
|
||||
const nextBlock = document.getClosestBlock(next.key)
|
||||
const nextInline = document.getClosestInline(next.key)
|
||||
|
||||
if (nextBlock == startBlock && nextInline) {
|
||||
return state
|
||||
.transform()
|
||||
.collapseToStartOf(next)
|
||||
.moveForward(1)
|
||||
.apply()
|
||||
}
|
||||
|
||||
// Otherwise, move to the start of the next text node.
|
||||
return state
|
||||
.transform()
|
||||
[method](nextText)
|
||||
.collapseToStartOf(next)
|
||||
.apply()
|
||||
}
|
||||
}
|
||||
|
@@ -178,13 +178,13 @@ const rules = [
|
||||
},
|
||||
validate: (node) => {
|
||||
const invalids = node.nodes.reduce((list, child, index) => {
|
||||
if (child.kind == 'block') return list
|
||||
if (!child.isVoid) return list
|
||||
if (child.kind !== 'inline') return list
|
||||
|
||||
const prev = index > 0 ? node.nodes.get(index - 1) : null
|
||||
const next = node.nodes.get(index + 1)
|
||||
// We don't test if "prev" is inline, since it has already been processed in the loop
|
||||
const insertBefore = !prev
|
||||
const insertAfter = !next || isInlineVoid(next)
|
||||
const insertAfter = !next || (next.kind == 'inline')
|
||||
|
||||
if (insertAfter || insertBefore) {
|
||||
list = list.push({ insertAfter, insertBefore, index })
|
||||
@@ -267,13 +267,13 @@ const rules = [
|
||||
const next = nodes.get(i + 1)
|
||||
|
||||
// If it's the first node, and the next is a void, preserve it.
|
||||
if (!prev && isInlineVoid(next)) return
|
||||
if (!prev && next.kind == 'inline') return
|
||||
|
||||
// It it's the last node, and the previous is a void, preserve it.
|
||||
if (!next && isInlineVoid(prev)) return
|
||||
// It it's the last node, and the previous is an inline, preserve it.
|
||||
if (!next && prev.kind == 'inline') return
|
||||
|
||||
// If it's surrounded by voids, preserve it.
|
||||
if (next && prev && isInlineVoid(next) && isInlineVoid(prev)) return
|
||||
// If it's surrounded by inlines, preserve it.
|
||||
if (next && prev && next.kind == 'inline' && prev.kind == 'inline') return
|
||||
|
||||
// Otherwise, remove it.
|
||||
return true
|
||||
@@ -290,17 +290,6 @@ const rules = [
|
||||
|
||||
]
|
||||
|
||||
/**
|
||||
* Test if a `node` is an inline void node.
|
||||
*
|
||||
* @param {Node} node
|
||||
* @return {Boolean}
|
||||
*/
|
||||
|
||||
function isInlineVoid(node) {
|
||||
return (node.kind == 'inline' && node.isVoid)
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the core schema.
|
||||
*
|
||||
|
@@ -185,52 +185,64 @@ export function deleteBackwardAtRange(transform, range, n = 1, options = {}) {
|
||||
const { document } = state
|
||||
const { startKey, focusOffset } = range
|
||||
|
||||
// If the range is expanded, perform a regular delete instead.
|
||||
if (range.isExpanded) {
|
||||
transform.deleteAtRange(range, { normalize })
|
||||
return
|
||||
}
|
||||
|
||||
// If the closest block is void, delete it.
|
||||
const block = document.getClosestBlock(startKey)
|
||||
if (block && block.isVoid) {
|
||||
transform.removeNodeByKey(block.key, { normalize })
|
||||
return
|
||||
}
|
||||
|
||||
// If the closest inline is void, delete it.
|
||||
const inline = document.getClosestInline(startKey)
|
||||
if (inline && inline.isVoid) {
|
||||
transform.removeNodeByKey(inline.key, { normalize })
|
||||
return
|
||||
}
|
||||
|
||||
// If the range is at the start of the document, abort.
|
||||
if (range.isAtStartOf(document)) {
|
||||
return
|
||||
}
|
||||
|
||||
// If the range is at the start of the text node, we need to figure out what
|
||||
// is behind it to know how to delete...
|
||||
const text = document.getDescendant(startKey)
|
||||
if (range.isAtStartOf(text)) {
|
||||
const prev = document.getPreviousText(text.key)
|
||||
const prevBlock = document.getClosestBlock(prev.key)
|
||||
const prevInline = document.getClosestInline(prev.key)
|
||||
|
||||
// If the previous block is void, remove it.
|
||||
if (prevBlock && prevBlock.isVoid) {
|
||||
transform.removeNodeByKey(prevBlock.key, { normalize })
|
||||
return
|
||||
}
|
||||
|
||||
// If the previous inline is void, remove it.
|
||||
if (prevInline && prevInline.isVoid) {
|
||||
transform.removeNodeByKey(prevInline.key, { normalize })
|
||||
return
|
||||
}
|
||||
|
||||
// If the previous text's block is inside the current block, then we need
|
||||
// to remove a character when deleteing. Otherwise, we just want to join
|
||||
// the two blocks together.
|
||||
range = range.merge({
|
||||
anchorKey: prev.key,
|
||||
anchorOffset: prev.length,
|
||||
anchorOffset: prevBlock == block ? prev.length - 1 : prev.length,
|
||||
})
|
||||
|
||||
transform.deleteAtRange(range, { normalize })
|
||||
return
|
||||
}
|
||||
|
||||
// Otherwise, just remove a character backwards.
|
||||
range = range.merge({
|
||||
focusOffset: focusOffset - n,
|
||||
isBackward: true,
|
||||
@@ -341,9 +353,12 @@ export function deleteForwardAtRange(transform, range, n = 1, options = {}) {
|
||||
return
|
||||
}
|
||||
|
||||
// If the next text's block is inside the current block, then we need
|
||||
// to remove a character when deleteing. Otherwise, we just want to join
|
||||
// the two blocks together.
|
||||
range = range.merge({
|
||||
focusKey: next.key,
|
||||
focusOffset: 0
|
||||
focusOffset: nextBlock == block ? 1 : 0
|
||||
})
|
||||
|
||||
transform.deleteAtRange(range, { normalize })
|
||||
|
@@ -3,6 +3,8 @@ nodes:
|
||||
- kind: block
|
||||
type: default
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
data:
|
||||
@@ -11,3 +13,5 @@ nodes:
|
||||
- kind: text
|
||||
ranges:
|
||||
- text: word
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -1,10 +1,20 @@
|
||||
|
||||
<div contenteditable="true">
|
||||
<div style="position:relative;">
|
||||
<span>
|
||||
<span>
|
||||
<span class="slate-zero-width-space">​</span>
|
||||
</span>
|
||||
</span>
|
||||
<a href="https://google.com">
|
||||
<span>
|
||||
<span>word</span>
|
||||
</span>
|
||||
</a>
|
||||
<span>
|
||||
<span>
|
||||
<span class="slate-zero-width-space">​</span>
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -3,9 +3,13 @@ nodes:
|
||||
- kind: block
|
||||
type: default
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: default
|
||||
nodes:
|
||||
- kind: text
|
||||
ranges:
|
||||
- text: word
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -1,10 +1,20 @@
|
||||
|
||||
<div contenteditable="true">
|
||||
<div style="position:relative;">
|
||||
<span>
|
||||
<span>
|
||||
<span class="slate-zero-width-space">​</span>
|
||||
</span>
|
||||
</span>
|
||||
<span style="position:relative;">
|
||||
<span>
|
||||
<span>word</span>
|
||||
</span>
|
||||
</span>
|
||||
<span>
|
||||
<span>
|
||||
<span class="slate-zero-width-space">​</span>
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -3,6 +3,8 @@ nodes:
|
||||
- kind: block
|
||||
type: default
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
data:
|
||||
@@ -11,6 +13,8 @@ nodes:
|
||||
- kind: text
|
||||
ranges:
|
||||
- text: another
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
data:
|
||||
@@ -19,3 +23,5 @@ nodes:
|
||||
- kind: text
|
||||
ranges:
|
||||
- text: word
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -1,15 +1,30 @@
|
||||
|
||||
<div contenteditable="true">
|
||||
<div style="position:relative;">
|
||||
<span>
|
||||
<span>
|
||||
<span class="slate-zero-width-space">​</span>
|
||||
</span>
|
||||
</span>
|
||||
<a href="https://google.com">
|
||||
<span>
|
||||
<span>another</span>
|
||||
</span>
|
||||
</a>
|
||||
<span>
|
||||
<span>
|
||||
<span class="slate-zero-width-space">​</span>
|
||||
</span>
|
||||
</span>
|
||||
<a href="https://google.com">
|
||||
<span>
|
||||
<span>word</span>
|
||||
</span>
|
||||
</a>
|
||||
<span>
|
||||
<span>
|
||||
<span class="slate-zero-width-space">​</span>
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -3,8 +3,12 @@ nodes:
|
||||
- kind: block
|
||||
type: default
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: default
|
||||
nodes:
|
||||
- kind: text
|
||||
text: one
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -3,6 +3,8 @@ nodes:
|
||||
- kind: block
|
||||
type: default
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
@@ -13,3 +15,5 @@ nodes:
|
||||
isVoid: true
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: text
|
||||
text: ""
|
@@ -0,0 +1,10 @@
|
||||
|
||||
nodes:
|
||||
- kind: block
|
||||
type: default
|
||||
nodes:
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
- kind: text
|
||||
text: "Hello"
|
@@ -0,0 +1,15 @@
|
||||
|
||||
|
||||
nodes:
|
||||
- kind: block
|
||||
type: default
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
- kind: text
|
||||
text: "Hello"
|
||||
- kind: text
|
||||
text: ""
|
@@ -0,0 +1,2 @@
|
||||
|
||||
export default {}
|
@@ -4,11 +4,15 @@ nodes:
|
||||
- kind: block
|
||||
type: default
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
- kind: text
|
||||
text: "Hello "
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
isVoid: true
|
||||
type: image
|
@@ -4,10 +4,12 @@ nodes:
|
||||
isVoid: false
|
||||
data: {}
|
||||
nodes:
|
||||
- characters: []
|
||||
- type: link
|
||||
isVoid: false
|
||||
data: {}
|
||||
nodes:
|
||||
- characters: []
|
||||
- type: hashtag
|
||||
isVoid: false
|
||||
data: {}
|
||||
@@ -19,3 +21,5 @@ nodes:
|
||||
marks: []
|
||||
- text: e
|
||||
marks: []
|
||||
- characters: []
|
||||
- characters: []
|
||||
|
@@ -4,6 +4,7 @@ nodes:
|
||||
isVoid: false
|
||||
data: {}
|
||||
nodes:
|
||||
- characters: []
|
||||
- type: link
|
||||
isVoid: false
|
||||
data:
|
||||
@@ -16,3 +17,4 @@ nodes:
|
||||
marks: []
|
||||
- text: e
|
||||
marks: []
|
||||
- characters: []
|
||||
|
@@ -4,14 +4,16 @@ nodes:
|
||||
isVoid: false
|
||||
data: {}
|
||||
nodes:
|
||||
- type: link
|
||||
isVoid: false
|
||||
data: {}
|
||||
nodes:
|
||||
- characters:
|
||||
- text: o
|
||||
marks: []
|
||||
- text: n
|
||||
marks: []
|
||||
- text: e
|
||||
marks: []
|
||||
- characters: []
|
||||
- type: link
|
||||
isVoid: false
|
||||
data: {}
|
||||
nodes:
|
||||
- characters:
|
||||
- text: o
|
||||
marks: []
|
||||
- text: n
|
||||
marks: []
|
||||
- text: e
|
||||
marks: []
|
||||
- characters: []
|
||||
|
@@ -4,10 +4,12 @@ nodes:
|
||||
isVoid: false
|
||||
data: {}
|
||||
nodes:
|
||||
- characters: []
|
||||
- type: link
|
||||
isVoid: false
|
||||
data: {}
|
||||
nodes:
|
||||
- characters: []
|
||||
- type: hashtag
|
||||
isVoid: false
|
||||
data: {}
|
||||
@@ -19,3 +21,5 @@ nodes:
|
||||
marks: []
|
||||
- text: e
|
||||
marks: []
|
||||
- characters: []
|
||||
- characters: []
|
||||
|
@@ -4,6 +4,7 @@ nodes:
|
||||
isVoid: false
|
||||
data: {}
|
||||
nodes:
|
||||
- characters: []
|
||||
- type: link
|
||||
isVoid: false
|
||||
data:
|
||||
@@ -16,3 +17,4 @@ nodes:
|
||||
marks: []
|
||||
- text: e
|
||||
marks: []
|
||||
- characters: []
|
||||
|
@@ -4,6 +4,7 @@ nodes:
|
||||
isVoid: false
|
||||
data: {}
|
||||
nodes:
|
||||
- characters: []
|
||||
- type: link
|
||||
isVoid: false
|
||||
data: {}
|
||||
@@ -15,3 +16,4 @@ nodes:
|
||||
marks: []
|
||||
- text: e
|
||||
marks: []
|
||||
- characters: []
|
||||
|
@@ -4,10 +4,12 @@ nodes:
|
||||
isVoid: false
|
||||
data: {}
|
||||
nodes:
|
||||
- characters: []
|
||||
- type: link
|
||||
isVoid: false
|
||||
data: {}
|
||||
nodes:
|
||||
- characters: []
|
||||
- type: hashtag
|
||||
isVoid: false
|
||||
data: {}
|
||||
@@ -19,3 +21,5 @@ nodes:
|
||||
marks: []
|
||||
- text: e
|
||||
marks: []
|
||||
- characters: []
|
||||
- characters: []
|
||||
|
@@ -4,6 +4,7 @@ nodes:
|
||||
isVoid: false
|
||||
data: {}
|
||||
nodes:
|
||||
- characters: []
|
||||
- type: link
|
||||
isVoid: false
|
||||
data:
|
||||
@@ -16,3 +17,4 @@ nodes:
|
||||
marks: []
|
||||
- text: e
|
||||
marks: []
|
||||
- characters: []
|
||||
|
@@ -4,6 +4,7 @@ nodes:
|
||||
isVoid: false
|
||||
data: {}
|
||||
nodes:
|
||||
- characters: []
|
||||
- type: link
|
||||
isVoid: false
|
||||
data: {}
|
||||
@@ -15,3 +16,4 @@ nodes:
|
||||
marks: []
|
||||
- text: e
|
||||
marks: []
|
||||
- characters: []
|
||||
|
@@ -3,11 +3,19 @@ nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: hashtag
|
||||
nodes:
|
||||
- kind: text
|
||||
text: one
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -3,6 +3,8 @@ nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
data:
|
||||
@@ -10,3 +12,5 @@ nodes:
|
||||
nodes:
|
||||
- kind: text
|
||||
text: one
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -3,8 +3,12 @@ nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
- kind: text
|
||||
text: one
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -8,11 +8,21 @@ document:
|
||||
data: {}
|
||||
isVoid: false
|
||||
nodes:
|
||||
- kind: text
|
||||
ranges:
|
||||
- kind: range
|
||||
text: ""
|
||||
marks: []
|
||||
- kind: inline
|
||||
type: link
|
||||
data: {}
|
||||
isVoid: false
|
||||
nodes:
|
||||
- kind: text
|
||||
ranges:
|
||||
- kind: range
|
||||
text: ""
|
||||
marks: []
|
||||
- kind: inline
|
||||
type: hashtag
|
||||
data: {}
|
||||
@@ -23,3 +33,13 @@ document:
|
||||
- kind: range
|
||||
text: one
|
||||
marks: []
|
||||
- kind: text
|
||||
ranges:
|
||||
- kind: range
|
||||
text: ""
|
||||
marks: []
|
||||
- kind: text
|
||||
ranges:
|
||||
- kind: range
|
||||
text: ""
|
||||
marks: []
|
||||
|
@@ -8,6 +8,11 @@ document:
|
||||
data: {}
|
||||
isVoid: false
|
||||
nodes:
|
||||
- kind: text
|
||||
ranges:
|
||||
- kind: range
|
||||
text: ""
|
||||
marks: []
|
||||
- kind: inline
|
||||
type: link
|
||||
isVoid: false
|
||||
@@ -19,3 +24,8 @@ document:
|
||||
- kind: range
|
||||
text: one
|
||||
marks: []
|
||||
- kind: text
|
||||
ranges:
|
||||
- kind: range
|
||||
text: ""
|
||||
marks: []
|
||||
|
@@ -8,6 +8,11 @@ document:
|
||||
data: {}
|
||||
isVoid: false
|
||||
nodes:
|
||||
- kind: text
|
||||
ranges:
|
||||
- kind: range
|
||||
text: ""
|
||||
marks: []
|
||||
- kind: inline
|
||||
type: link
|
||||
data: {}
|
||||
@@ -18,3 +23,8 @@ document:
|
||||
- kind: range
|
||||
text: one
|
||||
marks: []
|
||||
- kind: text
|
||||
ranges:
|
||||
- kind: range
|
||||
text: ""
|
||||
marks: []
|
||||
|
@@ -4,12 +4,12 @@ import assert from 'assert'
|
||||
export default function (state) {
|
||||
const { document, selection } = state
|
||||
const texts = document.getTexts()
|
||||
const first = texts.first()
|
||||
const second = texts.last()
|
||||
const second = texts.get(1)
|
||||
const fifth = texts.get(4)
|
||||
const range = selection.merge({
|
||||
anchorKey: first.key,
|
||||
anchorKey: second.key,
|
||||
anchorOffset: 2,
|
||||
focusKey: second.key,
|
||||
focusKey: fifth.key,
|
||||
focusOffset: 2
|
||||
})
|
||||
|
||||
|
@@ -3,16 +3,24 @@ nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
- kind: text
|
||||
text: another
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -3,6 +3,8 @@ nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
@@ -12,9 +14,13 @@ nodes:
|
||||
- text: rd
|
||||
marks:
|
||||
- type: bold
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
@@ -24,3 +30,5 @@ nodes:
|
||||
marks:
|
||||
- type: bold
|
||||
- text: other
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -10,3 +10,5 @@ nodes:
|
||||
nodes:
|
||||
- kind: text
|
||||
text: two
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -10,3 +10,5 @@ nodes:
|
||||
nodes:
|
||||
- kind: text
|
||||
text: two
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -4,12 +4,12 @@ import assert from 'assert'
|
||||
export default function (state) {
|
||||
const { document, selection } = state
|
||||
const texts = document.getTexts()
|
||||
const first = texts.first()
|
||||
const last = texts.last()
|
||||
const first = texts.get(0)
|
||||
const second = texts.get(1)
|
||||
const range = selection.merge({
|
||||
anchorKey: first.key,
|
||||
anchorOffset: 0,
|
||||
focusKey: last.key,
|
||||
focusKey: second.key,
|
||||
focusOffset: 1
|
||||
})
|
||||
|
||||
@@ -19,6 +19,7 @@ export default function (state) {
|
||||
.deleteForward()
|
||||
.apply()
|
||||
|
||||
// TODO: fix this behavior.
|
||||
/* const updated = next.document.getTexts().last()
|
||||
|
||||
assert.deepEqual(
|
||||
|
@@ -10,3 +10,5 @@ nodes:
|
||||
nodes:
|
||||
- kind: text
|
||||
text: two
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -3,8 +3,12 @@ nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
- kind: text
|
||||
text: wo
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -4,12 +4,12 @@ import assert from 'assert'
|
||||
export default function (state) {
|
||||
const { document, selection } = state
|
||||
const texts = document.getTexts()
|
||||
const first = texts.first()
|
||||
const last = texts.last()
|
||||
const second = texts.get(1)
|
||||
const fifth = texts.get(4)
|
||||
const range = selection.merge({
|
||||
anchorKey: first.key,
|
||||
anchorKey: second.key,
|
||||
anchorOffset: 2,
|
||||
focusKey: last.key,
|
||||
focusKey: fifth.key,
|
||||
focusOffset: 2
|
||||
})
|
||||
|
||||
|
@@ -3,16 +3,24 @@ nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
- kind: text
|
||||
text: another
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -3,13 +3,19 @@ nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
- kind: text
|
||||
text: wo
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
- kind: text
|
||||
text: other
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -10,3 +10,5 @@ nodes:
|
||||
nodes:
|
||||
- kind: text
|
||||
text: two
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -11,12 +11,12 @@ export default function (state) {
|
||||
|
||||
const { document, selection } = state
|
||||
const texts = document.getTexts()
|
||||
const first = texts.first()
|
||||
const second = texts.get(1)
|
||||
const range = selection.merge({
|
||||
anchorKey: first.key,
|
||||
anchorOffset: first.length,
|
||||
focusKey: first.key,
|
||||
focusOffset: first.length
|
||||
anchorKey: second.key,
|
||||
anchorOffset: second.length,
|
||||
focusKey: second.key,
|
||||
focusOffset: second.length
|
||||
})
|
||||
|
||||
const next = state
|
||||
|
@@ -3,8 +3,12 @@ nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -3,6 +3,8 @@ nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
|
@@ -3,8 +3,12 @@ nodes:
|
||||
- kind: block
|
||||
type: list-item
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: hashtag
|
||||
nodes:
|
||||
- kind: text
|
||||
text: fragment
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -11,12 +11,11 @@ export default function (state) {
|
||||
|
||||
const { document, selection } = state
|
||||
const texts = document.getTexts()
|
||||
const first = texts.first()
|
||||
const last = fragment.getTexts().last()
|
||||
const second = texts.get(1)
|
||||
const range = selection.merge({
|
||||
anchorKey: first.key,
|
||||
anchorKey: second.key,
|
||||
anchorOffset: 2,
|
||||
focusKey: first.key,
|
||||
focusKey: second.key,
|
||||
focusOffset: 2
|
||||
})
|
||||
|
||||
@@ -26,15 +25,16 @@ export default function (state) {
|
||||
.insertFragment(fragment)
|
||||
.apply()
|
||||
|
||||
const updated = next.document.getTexts().get(1)
|
||||
const updated = next.document.getTexts().get(4)
|
||||
|
||||
// TODO: this seems wrong.
|
||||
assert.deepEqual(
|
||||
next.selection.toJS(),
|
||||
range.merge({
|
||||
anchorKey: updated.key,
|
||||
anchorOffset: last.length,
|
||||
anchorOffset: 0,
|
||||
focusKey: updated.key,
|
||||
focusOffset: last.length
|
||||
focusOffset: 0
|
||||
}).toJS()
|
||||
)
|
||||
|
||||
|
@@ -3,8 +3,12 @@ nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -3,18 +3,26 @@ nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
- kind: text
|
||||
text: wo
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: hashtag
|
||||
nodes:
|
||||
- kind: text
|
||||
text: fragment
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
- kind: text
|
||||
text: rd
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -11,12 +11,12 @@ export default function (state) {
|
||||
|
||||
const { document, selection } = state
|
||||
const texts = document.getTexts()
|
||||
const first = texts.first()
|
||||
const second = texts.get(1)
|
||||
const last = fragment.getTexts().last()
|
||||
const range = selection.merge({
|
||||
anchorKey: first.key,
|
||||
anchorKey: second.key,
|
||||
anchorOffset: 2,
|
||||
focusKey: first.key,
|
||||
focusKey: second.key,
|
||||
focusOffset: 2
|
||||
})
|
||||
|
||||
@@ -26,7 +26,7 @@ export default function (state) {
|
||||
.insertFragment(fragment)
|
||||
.apply()
|
||||
|
||||
const updated = next.document.getTexts().get(1)
|
||||
const updated = next.document.getTexts().get(2)
|
||||
|
||||
assert.deepEqual(
|
||||
next.selection.toJS(),
|
||||
|
@@ -3,8 +3,12 @@ nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -3,6 +3,8 @@ nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
@@ -15,3 +17,5 @@ nodes:
|
||||
nodes:
|
||||
- kind: text
|
||||
text: rd
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -11,12 +11,12 @@ export default function (state) {
|
||||
|
||||
const { document, selection } = state
|
||||
const texts = document.getTexts()
|
||||
const first = texts.first()
|
||||
const second = texts.get(1)
|
||||
const last = fragment.getTexts().last()
|
||||
const range = selection.merge({
|
||||
anchorKey: first.key,
|
||||
anchorKey: second.key,
|
||||
anchorOffset: 0,
|
||||
focusKey: first.key,
|
||||
focusKey: second.key,
|
||||
focusOffset: 0
|
||||
})
|
||||
|
||||
@@ -26,7 +26,7 @@ export default function (state) {
|
||||
.insertFragment(fragment)
|
||||
.apply()
|
||||
|
||||
const updated = next.document.getTexts().first()
|
||||
const updated = next.document.getTexts().get(1)
|
||||
|
||||
assert.deepEqual(
|
||||
next.selection.toJS(),
|
||||
|
@@ -3,8 +3,12 @@ nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -10,3 +10,5 @@ nodes:
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -4,11 +4,11 @@ import assert from 'assert'
|
||||
export default function (state) {
|
||||
const { document, selection } = state
|
||||
const texts = document.getTexts()
|
||||
const first = texts.first()
|
||||
const second = texts.get(1)
|
||||
const range = selection.merge({
|
||||
anchorKey: first.key,
|
||||
anchorKey: second.key,
|
||||
anchorOffset: 2,
|
||||
focusKey: first.key,
|
||||
focusKey: second.key,
|
||||
focusOffset: 2
|
||||
})
|
||||
|
||||
@@ -21,7 +21,7 @@ export default function (state) {
|
||||
})
|
||||
.apply()
|
||||
|
||||
const updated = next.document.getTexts().get(1)
|
||||
const updated = next.document.getTexts().get(2)
|
||||
|
||||
assert.deepEqual(
|
||||
next.selection.toJS(),
|
||||
|
@@ -3,8 +3,12 @@ nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -3,6 +3,8 @@ nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
@@ -13,3 +15,5 @@ nodes:
|
||||
isVoid: true
|
||||
- kind: text
|
||||
text: rd
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -4,12 +4,12 @@ import assert from 'assert'
|
||||
export default function (state) {
|
||||
const { document, selection } = state
|
||||
const texts = document.getTexts()
|
||||
const first = texts.first()
|
||||
const second = texts.last()
|
||||
const second = texts.get(1)
|
||||
const fifth = texts.get(4)
|
||||
const range = selection.merge({
|
||||
anchorKey: first.key,
|
||||
anchorKey: second.key,
|
||||
anchorOffset: 2,
|
||||
focusKey: second.key,
|
||||
focusKey: fifth.key,
|
||||
focusOffset: 2
|
||||
})
|
||||
|
||||
|
@@ -3,6 +3,8 @@ nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
@@ -12,9 +14,13 @@ nodes:
|
||||
- text: rd
|
||||
marks:
|
||||
- type: bold
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
@@ -24,3 +30,5 @@ nodes:
|
||||
marks:
|
||||
- type: bold
|
||||
- text: other
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -3,16 +3,24 @@ nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
- kind: text
|
||||
text: another
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -4,12 +4,12 @@ import assert from 'assert'
|
||||
export default function (state) {
|
||||
const { document, selection } = state
|
||||
const texts = document.getTexts()
|
||||
const first = texts.first()
|
||||
const second = texts.last()
|
||||
const second = texts.get(1)
|
||||
const fifth = texts.get(4)
|
||||
const range = selection.merge({
|
||||
anchorKey: first.key,
|
||||
anchorKey: second.key,
|
||||
anchorOffset: 2,
|
||||
focusKey: second.key,
|
||||
focusKey: fifth.key,
|
||||
focusOffset: 2
|
||||
})
|
||||
|
||||
|
@@ -3,16 +3,24 @@ nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
- kind: text
|
||||
text: another
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -3,16 +3,24 @@ nodes:
|
||||
- kind: block
|
||||
type: code
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: block
|
||||
type: code
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
- kind: text
|
||||
text: another
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -4,12 +4,12 @@ import assert from 'assert'
|
||||
export default function (state) {
|
||||
const { document, selection } = state
|
||||
const texts = document.getTexts()
|
||||
const first = texts.first()
|
||||
const second = texts.last()
|
||||
const second = texts.get(1)
|
||||
const fifth = texts.get(4)
|
||||
const range = selection.merge({
|
||||
anchorKey: first.key,
|
||||
anchorKey: second.key,
|
||||
anchorOffset: 2,
|
||||
focusKey: second.key,
|
||||
focusKey: fifth.key,
|
||||
focusOffset: 2
|
||||
})
|
||||
|
||||
|
@@ -3,16 +3,24 @@ nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
- kind: text
|
||||
text: another
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -3,16 +3,24 @@ nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: code
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: code
|
||||
nodes:
|
||||
- kind: text
|
||||
text: another
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -5,11 +5,11 @@ import assert from 'assert'
|
||||
export default function (state) {
|
||||
const { document, selection } = state
|
||||
const texts = document.getTexts()
|
||||
const first = texts.first()
|
||||
const second = texts.get(1)
|
||||
const range = selection.merge({
|
||||
anchorKey: first.key,
|
||||
anchorKey: second.key,
|
||||
anchorOffset: 0,
|
||||
focusKey: first.key,
|
||||
focusKey: second.key,
|
||||
focusOffset: 0
|
||||
})
|
||||
|
||||
|
@@ -3,8 +3,12 @@ nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -3,6 +3,8 @@ nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
data:
|
||||
@@ -10,3 +12,5 @@ nodes:
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -4,11 +4,11 @@ import assert from 'assert'
|
||||
export default function (state) {
|
||||
const { document, selection } = state
|
||||
const texts = document.getTexts()
|
||||
const first = texts.first()
|
||||
const third = texts.get(2)
|
||||
const range = selection.merge({
|
||||
anchorKey: first.key,
|
||||
anchorKey: third.key,
|
||||
anchorOffset: 0,
|
||||
focusKey: first.key,
|
||||
focusKey: third.key,
|
||||
focusOffset: 0
|
||||
})
|
||||
|
||||
|
@@ -3,11 +3,19 @@ nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: hashtag
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -3,11 +3,19 @@ nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: hashtag
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: code
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -4,11 +4,11 @@ import assert from 'assert'
|
||||
export default function (state) {
|
||||
const { document, selection } = state
|
||||
const texts = document.getTexts()
|
||||
const first = texts.first()
|
||||
const second = texts.get(1)
|
||||
const range = selection.merge({
|
||||
anchorKey: first.key,
|
||||
anchorKey: second.key,
|
||||
anchorOffset: 0,
|
||||
focusKey: first.key,
|
||||
focusKey: second.key,
|
||||
focusOffset: 0
|
||||
})
|
||||
|
||||
|
@@ -3,8 +3,12 @@ nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -3,8 +3,12 @@ nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: code
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -4,11 +4,11 @@ import assert from 'assert'
|
||||
export default function (state) {
|
||||
const { document, selection } = state
|
||||
const texts = document.getTexts()
|
||||
const first = texts.first()
|
||||
const second = texts.get(1)
|
||||
const range = selection.merge({
|
||||
anchorKey: first.key,
|
||||
anchorKey: second.key,
|
||||
anchorOffset: 0,
|
||||
focusKey: first.key,
|
||||
focusKey: second.key,
|
||||
focusOffset: 0
|
||||
})
|
||||
|
||||
|
@@ -3,8 +3,12 @@ nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -3,8 +3,12 @@ nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: code
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
- kind: text
|
||||
text: ""
|
||||
|
@@ -4,11 +4,11 @@ import assert from 'assert'
|
||||
export default function (state) {
|
||||
const { document, selection } = state
|
||||
const texts = document.getTexts()
|
||||
const first = texts.first()
|
||||
const second = texts.get(1)
|
||||
const range = selection.merge({
|
||||
anchorKey: first.key,
|
||||
anchorKey: second.key,
|
||||
anchorOffset: 0,
|
||||
focusKey: first.key,
|
||||
focusKey: second.key,
|
||||
focusOffset: 0
|
||||
})
|
||||
|
||||
|
@@ -3,8 +3,12 @@ nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: inline
|
||||
type: link
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
- kind: text
|
||||
text: ""
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user