mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
Add findDescendant method typedef and remove findDescendants typedef (#39364)
This commit is contained in:
committed by
Wesley Wigham
parent
7b0b4a2464
commit
afaf7cf382
Vendored
+2
-1
@@ -13,6 +13,7 @@
|
||||
// Han Jeon <https://github.com/hanstar17>
|
||||
// Kay Delaney <https://github.com/kaydelaney>
|
||||
// Yuichiro Tsuchiya <https://github.com/tuttieee>
|
||||
// Kamil Kamiński <https://github.com/0ctothorp>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
import * as Immutable from "immutable";
|
||||
@@ -491,7 +492,7 @@ declare class BaseNode extends Immutable.Record({}) {
|
||||
createSelection(properties: SelectionProperties | SelectionJSON | Selection | Range): Selection;
|
||||
descendants(options?: IterableOptions): Iterable<[Node, Immutable.List<number>]>;
|
||||
filterDescendants(predicate?: (node: Node, path: Immutable.List<number>) => boolean): Immutable.List<Node>;
|
||||
findDescendants(predicate?: (node: Node, path: Immutable.List<number>) => boolean): Node | null;
|
||||
findDescendant(predicate?: (node: Node, path: Immutable.List<number>) => boolean): Node | null;
|
||||
forEachDescendant(predicate?: (node: Node, path: Immutable.List<number>) => boolean): void;
|
||||
getActiveMarksAtRange(range: RangeTypeProperties | RangeTypeJSON | RangeType): Immutable.Set<Mark>;
|
||||
getAncestors(path: Path): Immutable.List<Node> | null;
|
||||
|
||||
+28
-18
@@ -31,12 +31,12 @@ data['foo'];
|
||||
|
||||
const value = Value.create({ data });
|
||||
|
||||
const node: BlockJSON = {
|
||||
object: "block",
|
||||
type: "paragraph",
|
||||
nodes: [
|
||||
{
|
||||
object: "text",
|
||||
const nodeJSON: BlockJSON = {
|
||||
object: "block",
|
||||
type: "paragraph",
|
||||
nodes: [
|
||||
{
|
||||
object: "text",
|
||||
key: "a",
|
||||
text: "example",
|
||||
marks: [{
|
||||
@@ -44,16 +44,26 @@ const node: BlockJSON = {
|
||||
type: "mark",
|
||||
object: "mark"
|
||||
}]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
const doc = Document.fromJSON({
|
||||
object: "document",
|
||||
data: {},
|
||||
nodes: [node]
|
||||
object: "document",
|
||||
data: {},
|
||||
nodes: [nodeJSON]
|
||||
});
|
||||
|
||||
const node = new Block(nodeJSON);
|
||||
|
||||
doc.findDescendant();
|
||||
doc.findDescendant(node => node.object === 'block' && node.type === 'paragraph');
|
||||
doc.findDescendant((node, path) => true);
|
||||
|
||||
node.findDescendant();
|
||||
node.findDescendant(node => node.object === 'block');
|
||||
node.findDescendant((node, path) => false);
|
||||
|
||||
const schema: SchemaProperties = {
|
||||
document: {
|
||||
nodes: [
|
||||
@@ -168,13 +178,13 @@ editor
|
||||
.flush()
|
||||
.focus()
|
||||
.insertBlock({
|
||||
type: "image",
|
||||
key: "b",
|
||||
data: {
|
||||
src: "http://placekitten.com/200/300",
|
||||
alt: "Kittens",
|
||||
className: "img-responsive"
|
||||
}
|
||||
type: "image",
|
||||
key: "b",
|
||||
data: {
|
||||
src: "http://placekitten.com/200/300",
|
||||
alt: "Kittens",
|
||||
className: "img-responsive"
|
||||
}
|
||||
})
|
||||
.insertBlockAtRange(range, "text")
|
||||
.insertFragment(doc)
|
||||
|
||||
Reference in New Issue
Block a user