MCPcopy Create free account
hub / github.com/breck7/scroll / pasteText

Method pasteText

external/.scrollLibs.js:17488–17506  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

17486 return newParticle
17487 }
17488 pasteText(text) {
17489 const parent = this.parent
17490 const index = this.index
17491 const newParticles = new Particle(text)
17492 const firstParticle = newParticles.particleAt(0)
17493 if (firstParticle) {
17494 this.setLine(firstParticle.getLine())
17495 if (firstParticle.length) this.setSubparticles(firstParticle.subparticlesToString())
17496 } else {
17497 this.setLine("")
17498 }
17499 newParticles.forEach((subparticle, subparticleIndex) => {
17500 if (!subparticleIndex)
17501 // skip first
17502 return true
17503 parent.insertLineAndSubparticles(subparticle.getLine(), subparticle.subparticlesToString(), index + subparticleIndex)
17504 })
17505 return this
17506 }
17507 templateToString(obj) {
17508 // todo: compile/cache for perf?
17509 const particle = this.clone()

Callers 1

templateToStringMethod · 0.80

Calls 7

particleAtMethod · 0.95
setLineMethod · 0.95
setSubparticlesMethod · 0.95
forEachMethod · 0.95
subparticlesToStringMethod · 0.80
getLineMethod · 0.45

Tested by

no test coverage detected