mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 01:36:22 +00:00
If there is no TOC in the current document, it's created at current cursor position. Subsequent generation calls update TOC at existing position. Add additional tests with CodeMirror editor mock.
28 lines
496 B
JavaScript
28 lines
496 B
JavaScript
import browserEnv from 'browser-env'
|
|
browserEnv(['window', 'document', 'navigator'])
|
|
|
|
// for CodeMirror mockup
|
|
document.body.createTextRange = function () {
|
|
return {
|
|
setEnd: function () {},
|
|
setStart: function () {},
|
|
getBoundingClientRect: function () {
|
|
return {right: 0}
|
|
},
|
|
getClientRects: function () {
|
|
return {
|
|
length: 0,
|
|
left: 0,
|
|
right: 0
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
window.localStorage = {
|
|
// polyfill
|
|
getItem () {
|
|
return '{}'
|
|
}
|
|
}
|