Browse Source
			
			
			logs-content: Replaced old post rendering with actual irc caret notation parsing.
			
			
				master
			
			
		
		logs-content: Replaced old post rendering with actual irc caret notation parsing.
	
		
	
			
			
				master
			
			
		
				 7 changed files with 84 additions and 40 deletions
			
			
		- 
					23marko/components/irc-caret-notation/component.js
 - 
					5marko/components/irc-caret-notation/index.marko
 - 
					34marko/page/logs-content/components/post/component.js
 - 
					8marko/page/logs-content/components/post/index.marko
 - 
					46marko/page/logs-content/components/post/style.less
 - 
					5package-lock.json
 - 
					1package.json
 
@ -0,0 +1,23 @@ | 
				
			|||
const {parse, BOLD} = require("irc-caret-notation") | 
				
			|||
 | 
				
			|||
module.exports = class { | 
				
			|||
  onCreate() { | 
				
			|||
    this.state = { | 
				
			|||
      paragraphs: [], | 
				
			|||
      prev: "", | 
				
			|||
    } | 
				
			|||
  } | 
				
			|||
 | 
				
			|||
  onInput(input) { | 
				
			|||
    if (this.state == null) { | 
				
			|||
      return | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    if (input.source != this.state.prev) { | 
				
			|||
      this.state.prev = input.source | 
				
			|||
      this.state.paragraphs = input.source.split("\n").filter(l => l.length > 0).map(l => parse(l, { | 
				
			|||
        "*": (!(input.source.startsWith("(")) ? BOLD : null), | 
				
			|||
      })) | 
				
			|||
    } | 
				
			|||
  } | 
				
			|||
} | 
				
			|||
@ -0,0 +1,5 @@ | 
				
			|||
<div class=["irc-caret-notation", input.class]> | 
				
			|||
  <p for(p in state.paragraphs)> | 
				
			|||
    <span for(chunk in p) class=chunk.cssClasses("icn-")>${chunk.text}</span> | 
				
			|||
  </p> | 
				
			|||
</div> | 
				
			|||
						Write
						Preview
					
					
					Loading…
					
					Cancel
						Save
					
		Reference in new issue