Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
updateCaption(txt) {
// assumes no marks or anything
let textNode = this.getTextNode();
if (!textNode) {
console.log('could not find textNode');
return;
}
const slice = new Slice(Fragment.from(schema.text(txt)), 0, 0);
const transaction = this.view.state.tr.replaceRange(textNode.from, textNode.to, slice);
this.view.dispatch(transaction);
}
itemType: NodeType,
range: NodeRange
) {
const tr = state.tr,
end = range.end,
endOfList = range.$to.end(range.depth);
if (end < endOfList) {
// There are siblings after the lifted items, which must become
// children of the last item
tr.step(
new ReplaceAroundStep(
end - 1,
endOfList,
end,
endOfList,
new Slice(Fragment.from(itemType.create(undefined, range.parent.copy())), 1, 0),
1,
true
)
);
range = new NodeRange(
tr.doc.resolve(range.$from.pos),
tr.doc.resolve(endOfList),
range.depth
);
}
dispatch(tr.lift(range, liftTarget(range)!).scrollIntoView());
return true;
}
}
it("will call transformPastedHTML", () => {
let view = tempEditor({transformPastedHTML(_) { return "abc" }})
ist(parseFromClipboard(view, "", "def", false, view.state.doc.resolve(1)),
new Slice(p("abc").content, 0, 0), eq)
})
return () => {
let slice = content ? new Slice(content.content, openStart, openEnd) : Slice.empty
let tr = new Transform(doc).replace(from, to, slice)
ist(tr.doc, result, eq)
}
}
Transform.prototype.split = function(pos, depth = 1, typesAfter) {
let $pos = this.doc.resolve(pos), before = Fragment.empty, after = Fragment.empty
for (let d = $pos.depth, e = $pos.depth - depth, i = depth - 1; d > e; d--, i--) {
before = Fragment.from($pos.node(d).copy(before))
let typeAfter = typesAfter && typesAfter[i]
after = Fragment.from(typeAfter ? typeAfter.type.create(typeAfter.attrs, after) : $pos.node(d).copy(after))
}
return this.step(new ReplaceStep(pos, pos, new Slice(before.append(after), depth, depth), true))
}
function fitLeft($from, placed) {
let {content, openEnd} = fitLeftInner($from, 0, placed, false)
return new Slice(content, $from.depth, openEnd || 0)
}
openStart++
} else {
start--
}
let after = Fragment.empty, openEnd = 0
for (let d = depth, splitting = false; d > target; d--)
if (splitting || $to.after(d + 1) < $to.end(d)) {
splitting = true
after = Fragment.from($to.node(d).copy(after))
openEnd++
} else {
end++
}
return this.step(new ReplaceAroundStep(start, end, gapStart, gapEnd,
new Slice(before.append(after), openStart, openEnd),
before.size - openStart, true))
}
if (!wrappers) {
return tr;
}
let content = Fragment.empty;
for (let i = wrappers.length - 1; i >= 0; i--) {
content = Fragment.from(
wrappers[i].type.create(wrappers[i].attrs, content),
);
}
tr = tr.step(
new ReplaceAroundStep(range.start - (doJoin ? 2 : 0),
range.end,
range.start,
range.end,
new Slice(content, 0, 0), wrappers.length, true),
);
let found = 0
for (let i = 0; i < wrappers.length; i++) {
if (wrappers[i].type == nodeType) {
found = i + 1;
}
};
let splitDepth = wrappers.length - found;
let splitPos = range.start + wrappers.length - (doJoin ? 2 : 0);
let parent = range.parent;
for (
let i = range.startIndex, e = range.endIndex, first = true;
i < e; i++,
first = false
sel.forEachCell((cell, pos) => {
if (!cell.content.eq(baseContent))
tr.replace(tr.mapping.map(pos + 1), tr.mapping.map(pos + cell.nodeSize - 1),
new Slice(baseContent, 0, 0))
})
if (tr.docChanged) dispatch(tr)