comments.ts 372 B

1234567891011121314
  1. import { EditorState } from '@codemirror/state'
  2. export const canAddComment = (state: EditorState) => {
  3. // TODO: permissions.comment
  4. // allow an empty selection if there's content on the line
  5. const range = state.selection.main
  6. if (range.empty) {
  7. return state.doc.lineAt(range.head).text.length > 0
  8. }
  9. // always allow a non-empty selection
  10. return true
  11. }