Skip to content

Instantly share code, notes, and snippets.

@zaydek-old
Created September 20, 2019 16:55
Show Gist options
  • Save zaydek-old/9b699b0c839c5166fad1b6a1b7128483 to your computer and use it in GitHub Desktop.
Save zaydek-old/9b699b0c839c5166fad1b6a1b7128483 to your computer and use it in GitHub Desktop.
// // Insert a tab character.
// tab() {
// let { data, pos1, pos2 } = editorState // Use `let`.
// if (data.slice(pos1, pos2).indexOf("\n") === -1) {
// data = data.slice(0, pos1) + "\t" + data.slice(pos2)
// pos1 += "\t".length
// this.setState({ data, pos1, pos2: pos1 })
// return
// }
// let x1 = pos1 // Use `let`.
// while (x1 - 1 >= 0) {
// if (data.charAt(x1 - 1) === "\n") {
// break
// }
// x1--
// }
// let x2 = pos2 // Use `let`.
// while (x2 < data.length) {
// if (data.charAt(x2) === "\n") {
// break
// }
// x2++
// }
// const { length } = data // Remember `data`’s length.
// data = data.slice(0, x1) + data.slice(x1, x2).replace(/^/gm, "\t") + data.slice(x2)
// pos1 += data.length - length // - "\t".length // ??
// pos2 += data.length - length
// this.setState({ data, pos1, pos2 })
// },
// // Remove a tab character.
// detab() {
// // TODO.
// },
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment