一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
23 行
695 B
TypeScript
23 行
695 B
TypeScript
import { Command, TextSelection } from 'prosemirror-state';
|
|
|
|
const selectDocumentEnd: Command = (state, dispatch) => {
|
|
// nodeSize is defined to be the length of the node content plus two (one for the start
|
|
// and one for the end token). However, the main document has no start/end tokens, so subtract two.
|
|
const position = state.doc.nodeSize - 2;
|
|
|
|
const endAlreadySelected = position === state.selection.from && state.selection.to === state.selection.from;
|
|
if (endAlreadySelected) {
|
|
return false;
|
|
}
|
|
|
|
const transaction = state.tr.setSelection(TextSelection.create(state.doc, position));
|
|
|
|
if (dispatch) {
|
|
dispatch(transaction);
|
|
}
|
|
|
|
return true;
|
|
};
|
|
|
|
export default selectDocumentEnd;
|