(cm, doc)
| 88 | |
| 89 | // Attach a document to an editor. |
| 90 | export function attachDoc(cm, doc) { |
| 91 | if (doc.cm) throw new Error("This document is already in use.") |
| 92 | cm.doc = doc |
| 93 | doc.cm = cm |
| 94 | estimateLineHeights(cm) |
| 95 | loadMode(cm) |
| 96 | setDirectionClass(cm) |
| 97 | if (!cm.options.lineWrapping) findMaxLine(cm) |
| 98 | cm.options.mode = doc.modeOption |
| 99 | regChange(cm) |
| 100 | } |
| 101 | |
| 102 | function setDirectionClass(cm) { |
| 103 | ;(cm.doc.direction == "rtl" ? addClass : rmClass)(cm.display.lineDiv, "CodeMirror-rtl") |
no test coverage detected