简体   繁体   中英

Summernote allow only plain text in table

I want to allow only plain text inside table cells, no nested tables, paragraphs, lists and so on. What is the best way to approach here, maybe disable toolbar once caret is positioned inside table? Is there any event that can handle this?

I have tried disabling buttons by checking $(".note-table-popover").is(":visible") but this doesn't solve my problem completely since popover is can be hidden and caret may stay inside table.

I have figured out how to disable toolbar when caret is inside Table, hope it helps someone (this is written in coffeescript)

textarea = "#div"
@$(textarea).next(".note-editor").find(".note-editable").on 'keydown keyup mousedown mouseup', (e) =>
  node = document.getSelection().anchorNode
  node = if node.nodeType == 3 then node.parentElement else node
  btns = @$(textarea).next(".note-editor").find(".note-btn")
  if ["TD", "TH"].indexOf(node.tagName) != -1
    btns.attr("disabled", true)
  else
    btns.attr("disabled", false)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM