Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function joinUp(tr: Transform): Transform {
const sel = tr.selection;
const nodeSel = sel instanceof NodeSelection;
let point;
if (nodeSel) {
if (sel.node.isTextblock || !canJoin(tr.doc, sel.from)) {
return tr;
}
point = sel.from;
} else {
point = joinPoint(tr.doc, sel.from, -1);
if (point === null || point === undefined) {
return tr;
}
}
tr = tr.join(point);
if (nodeSel) {
tr = tr.setSelection(
NodeSelection.create(
tr.doc,
point - tr.doc.resolve(point).nodeBefore.nodeSize
)
);
}
return tr;
export function joinUp(state, dispatch) {
let sel = state.selection, nodeSel = sel instanceof NodeSelection, point
if (nodeSel) {
if (sel.node.isTextblock || !canJoin(state.doc, sel.from)) return false
point = sel.from
} else {
point = joinPoint(state.doc, sel.from, -1)
if (point == null) return false
}
if (dispatch) {
let tr = state.tr.join(point)
if (nodeSel) tr.setSelection(NodeSelection.create(tr.doc, point - state.doc.resolve(point).nodeBefore.nodeSize))
dispatch(tr.scrollIntoView())
}
return true
}
export function joinDown(state, dispatch) {
let sel = state.selection, point
if (sel instanceof NodeSelection) {
if (sel.node.isTextblock || !canJoin(state.doc, sel.to)) return false
point = sel.to
} else {
point = joinPoint(state.doc, sel.to, 1)
if (point == null) return false
}
if (dispatch)
dispatch(state.tr.join(point).scrollIntoView())
return true
}
export default function joinDown(tr: Transform): Transform {
const sel = tr.selection;
let point;
if (sel instanceof NodeSelection) {
if (sel.node.isTextblock || !canJoin(tr.doc, sel.to)) {
return tr;
}
point = sel.to;
} else {
point = joinPoint(tr.doc, sel.to, 1);
if (point === null || point === undefined) {
return tr;
}
}
tr = tr.join(point);
return tr;
}