1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-30 18:39:51 +02:00

rename Node.text to Node.string (#3341)

This commit is contained in:
Ian Storm Taylor
2019-12-17 22:17:21 -05:00
committed by GitHub
parent 4ee9f8b4e6
commit 235a578967
19 changed files with 26 additions and 26 deletions

View File

@@ -393,7 +393,7 @@ export const Editable = (props: EditableProps) => {
placeholder &&
editor.children.length === 1 &&
Array.from(Node.texts(editor)).length === 1 &&
Node.text(editor) === ''
Node.string(editor) === ''
) {
const start = Editor.start(editor, [])
decorations.push({

View File

@@ -74,7 +74,7 @@ const Element = (props: {
// If it's a block node with inline children, add the proper `dir` attribute
// for text direction.
if (!isInline && Editor.hasInlines(editor, element)) {
const text = Node.text(element)
const text = Node.string(element)
const dir = getDirection(text)
if (dir === 'rtl') {

View File

@@ -21,7 +21,7 @@ const String = (props: {
// COMPAT: Render text inside void nodes with a zero-width space.
// So the node can contain selection but the text is not visible.
if (editor.isVoid(parent)) {
return <ZeroWidthString length={Node.text(parent).length} />
return <ZeroWidthString length={Node.string(parent).length} />
}
// COMPAT: If this is the last text node in an empty block, render a zero-
@@ -31,7 +31,7 @@ const String = (props: {
leaf.text === '' &&
parent.children[parent.children.length - 1] === text &&
!editor.isInline(parent) &&
Editor.text(editor, parentPath) === ''
Editor.string(editor, parentPath) === ''
) {
return <ZeroWidthString isLineBreak />
}

View File

@@ -620,7 +620,7 @@ export const LocationQueries = {
? start
: Editor.start(editor, path)
const text = Editor.text(editor, { anchor: s, focus: e })
const text = Editor.string(editor, { anchor: s, focus: e })
string = reverse ? reverseText(text) : text
isNewBlock = true
}
@@ -733,13 +733,13 @@ export const LocationQueries = {
},
/**
* Get the text content of a location.
* Get the text string content of a location.
*
* Note: the text of void nodes is presumed to be an empty string, regardless
* of what their actual content is.
*/
text(editor: Editor, at: Location): string {
string(editor: Editor, at: Location): string {
const range = Editor.range(editor, at)
const [start, end] = Range.edges(range)
let text = ''

View File

@@ -464,11 +464,11 @@ export const Node = {
* computations for a node.
*/
text(node: Node): string {
string(node: Node): string {
if (Text.isText(node)) {
return node.text
} else {
return node.children.map(Node.text).join('')
return node.children.map(Node.string).join('')
}
},

View File

@@ -17,7 +17,7 @@ export const input = (
)
export const test = value => {
return Node.text(value)
return Node.string(value)
}
export const output = `onetwothreefour`

View File

@@ -11,7 +11,7 @@ export const input = (
)
export const test = value => {
return Node.text(value, [1])
return Node.string(value, [1])
}
export const output = `onetwo`

View File

@@ -6,7 +6,7 @@ import { jsx } from 'slate-hyperscript'
export const input = <text>one</text>
export const test = value => {
return Node.text(value)
return Node.string(value)
}
export const output = `one`

View File

@@ -17,7 +17,7 @@ export const input = (
)
export const run = editor => {
return Editor.text(editor, [])
return Editor.string(editor, [])
}
export const output = `onetwothreefour`

View File

@@ -13,7 +13,7 @@ export const input = (
)
export const run = editor => {
return Editor.text(editor, [0])
return Editor.string(editor, [0])
}
export const output = ``

View File

@@ -17,7 +17,7 @@ export const input = (
)
export const run = editor => {
return Editor.text(editor, [0])
return Editor.string(editor, [0])
}
export const output = `onetwo`

View File

@@ -12,7 +12,7 @@ export const input = (
)
export const run = editor => {
return Editor.text(editor, [0, 1])
return Editor.string(editor, [0, 1])
}
export const output = `two`

View File

@@ -13,7 +13,7 @@ export const input = (
)
export const run = editor => {
return Editor.text(editor, [0, 0])
return Editor.string(editor, [0, 0])
}
export const output = `one`