Sha256: 152ee5819dc302fe479eb6b74a1e83db7372c621b6cecfe6e39381cbf1006421
Contents?: true
Size: 1.11 KB
Versions: 4
Compression:
Stored size: 1.11 KB
Contents
#= require trix/views/text_view {makeElement, getBlockConfig} = Trix class Trix.BlockView extends Trix.ObjectView constructor: -> super @block = @object @attributes = @block.getAttributes() createNodes: -> comment = document.createComment("block") nodes = [comment] if @block.isEmpty() nodes.push(makeElement("br")) else textConfig = getBlockConfig(@block.getLastAttribute())?.text textView = @findOrCreateCachedChildView(Trix.TextView, @block.text, {textConfig}) nodes.push(textView.getNodes()...) nodes.push(makeElement("br")) if @shouldAddExtraNewlineElement() if @attributes.length nodes else element = makeElement(Trix.config.blockAttributes.default.tagName) element.appendChild(node) for node in nodes [element] createContainerElement: (depth) -> attribute = @attributes[depth] config = getBlockConfig(attribute) makeElement(config.tagName) # A single <br> at the end of a block element has no visual representation # so add an extra one. shouldAddExtraNewlineElement:-> /\n\n$/.test(@block.toString())
Version data entries
4 entries across 4 versions & 1 rubygems