API de chemin
16 min
les tableaux path sont une liste d’index qui décrivent la position exacte d’un nœud dans un arbre de nœuds slate bien qu’ils soient généralement relatifs à l’objet racine éditeur , ils peuvent être relatifs à n’importe quel objet nœud type path = number\[] méthodes statiques docid\ ges8sdepfwcprgtfaq3hzméthodes de récupération docid\ ges8sdepfwcprgtfaq3hzméthodes de vérification docid\ ges8sdepfwcprgtfaq3hzméthode de transformation docid\ ges8sdepfwcprgtfaq3hz méthodes statiques méthodes de récupération path ancestors(path path, options { reverse? boolean } = {}) => path\[] obtenir une liste de chemins ancêtres pour un chemin donné les chemins sont triés du plus profond au moins profond toutefois, si l’option reverse true est passée, ils sont inversés path common(path path, another path) => path obtenir le chemin ancêtre commun de deux chemins path compare(path path, another path) => 1 | 0 | 1 comparer un chemin à un autre, en renvoyant un entier indiquant si le chemin était avant, à, ou après l’autre remarque deux chemins de longueurs différentes peuvent toujours recevoir un résultat 0 si l’un est directement au dessus ou en dessous de l’autre si vous souhaitez une correspondance exacte, utilisez plutôt \[\[path equals]] path levels(path path, options?) => path\[] obtenir une liste de chemins à chaque niveau jusqu’à un chemin remarque ceci est identique à path ancestors , mais inclut le chemin lui même les chemins sont triés du moins profond au plus profond toutefois, si l’option reverse true est passée, ils sont inversés options {reverse? boolean} path next(path path) => path étant donné un chemin, obtenir le chemin vers le nœud frère suivant la méthode ne garantit pas que le chemin retourné soit valide dans le document path parent(path path) => path étant donné un chemin, renvoyer un nouveau chemin faisant référence au nœud parent au dessus si l’argument chemin est égal à \[] , une erreur est levée path previous(path path) => path étant donné un chemin, obtenir le chemin vers le nœud frère précédent la méthode lèvera une erreur s’il n’existe aucun frère précédent (par ex si le path est actuellement \[1, 0] , le chemin précédent serait \[1, 1] , ce qui est illégal et lèvera une erreur) path relative(path path, ancestor path) => path étant donné deux chemins, dont l’un est un ancêtre de l’autre, renvoie le chemin relatif de l’argument ancêtre vers l’argument chemin si le chemin ancêtre n’est pas réellement un ancêtre ou égal à l’argument chemin , une erreur est levée méthodes de vérification vérifier un attribut d’un chemin renvoie toujours un booléen path endsafter(path path, another path) => boolean vérifier si un chemin se termine après l’un des index d’un autre path endsat(path path, another path) => boolean vérifier si un chemin se termine à l’un des index d’un autre path endsbefore(path path, another path) => boolean vérifier si un chemin se termine avant l’un des index d’un autre path equals(path path, another path) => boolean vérifier si un chemin est exactement égal à un autre path hasprevious(path path) => boolean vérifier si le chemin du nœud frère précédent existe path isafter(path path, another path) => boolean vérifiez si un path se trouve après un autre path isancestor(path path, another path) => boolean vérifiez si un path est un ancêtre d’un autre path isbefore(path path, another path) => boolean vérifiez si un path se trouve avant un autre path ischild(path path, another path) => boolean vérifiez si un path est un enfant d’un autre path iscommon(path path, another path) => boolean vérifiez si un path est égal à ou un ancêtre d’un autre path isdescendant(path path, another path) => boolean vérifiez si un path est un descendant d’un autre path isparent(path path, another path) => boolean vérifiez si un path est le parent d’un autre path ispath(value any) => value is path vérifiez si une valeur implémente l’ chemin interface path issibling(path path, another path) => boolean vérifiez si un path est un frère d’un autre méthode transform path transform(path path, operation operation, options?) => path | null transformez un path à l’aide d’une opération options { affinity? 'forward' | 'backward' | null }