chore: revert indented line wrap due to issues with mobile (fixes hoppscotch/internal-issues#9)

This commit is contained in:
Andrew Bastin
2022-06-13 23:05:23 +05:30
parent 6b1ca1dce1
commit a6b5295df5
2 changed files with 2 additions and 30 deletions

View File

@@ -1,27 +0,0 @@
import { EditorView } from "@codemirror/view"
const WrappedLineIndenter = EditorView.updateListener.of((update) => {
const view = update.view
const charWidth = view.defaultCharacterWidth
const lineHeight = view.defaultLineHeight
const basePadding = 10
view.viewportLines((line) => {
const domAtPos = view.domAtPos(line.from)
const lineCount = (line.bottom - line.top) / lineHeight
if (lineCount <= 1) return
const belowPadding = basePadding * charWidth
const node = domAtPos.node as HTMLElement
node.style.textIndent = `-${belowPadding - charWidth + 1}px`
node.style.paddingLeft = `${belowPadding}px`
})
})
export const IndentedLineWrapPlugin = [
EditorView.lineWrapping,
WrappedLineIndenter,
]