bitran
Version:
📜 Highly customizable text processor and transpiler.
70 lines (69 loc) • 2.07 kB
JavaScript
var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
import { G as GroupNode, B as BitranDomError } from "./_chunks/group-HQBJ3zxp.js";
import { N } from "./_chunks/group-HQBJ3zxp.js";
import { d, a, p, s } from "./_chunks/productMeta-DotuXXRl.js";
import { B, I, P, a as a2 } from "./_chunks/productNode-C0XZsQy2.js";
function assumeGroupItem(node) {
return new GroupItem(node);
}
class GroupItem {
constructor(node) {
__publicField(this, "node");
__publicField(this, "group");
if (!node.parent || !(node.parent instanceof GroupNode))
throw new BitranDomError(`Can't create GroupItem from given node! Given node is not a child of any GroupNode!`);
this.node = node;
this.group = node.parent;
}
//
// Operations
//
detach() {
this.group.detach(this.node);
}
before(...beforeNodes) {
this.group.before(this.node, ...beforeNodes);
}
after(...afterNodes) {
this.group.after(this.node, ...afterNodes);
}
replace(...withNodes) {
this.group.replace(this.node, ...withNodes);
}
move(toNode, before = false) {
this.group.move(this.node, toNode, before);
}
//
// Group traversal
//
previous() {
return this.group.children[this.group.__locate(this.node) - 1];
}
next() {
return this.group.children[this.group.__locate(this.node) + 1];
}
walkBackward(step) {
this.node.__walk((current) => assumeGroupItem(current).previous(), step);
}
walkForward(step) {
this.node.__walk((current) => assumeGroupItem(current).next(), step);
}
}
export {
BitranDomError,
B as BlockNode,
GroupItem,
GroupNode,
I as InlinerNode,
N as Node,
P as ProductLayout,
a2 as ProductNode,
assumeGroupItem,
d as detachMeta,
a as parseLineMeta,
p as parseMeta,
s as stringifyMeta
};
//# sourceMappingURL=dom.js.map