File tree Expand file tree Collapse file tree 1 file changed +114
-0
lines changed
utils/editors/markdown-editor/html/output-md Expand file tree Collapse file tree 1 file changed +114
-0
lines changed Original file line number Diff line number Diff line change 1+
2+
3+ < output-md v2.0 >
4+
5+ < template shadowrootmode =open >
6+
7+ < link rel =stylesheet href ='css/github-markdown-light.css '>
8+ < style >
9+
10+ # output {height : 100% ;border : 2px solid lightgray;box-sizing : border-box;padding : 10px }
11+
12+ </ style >
13+
14+ < div id =output class =markdown-body >
15+ </ div >
16+
17+ </ template >
18+
19+ < script >
20+
21+ ( function output_md ( { mod, dom, host} ) {
22+ console . log ( 'output' ) ;
23+ var obj = {
24+ version : 'v2.0' ,
25+ } ;
26+
27+ var $
28+ ;
29+
30+ obj . initmod = function ( params ) {
31+
32+ $ = params . $ ;
33+
34+ } //initmod
35+
36+
37+ //vars:-
38+
39+ var md ;
40+
41+ var shadow ;
42+
43+ var output ;
44+
45+
46+ //:
47+
48+
49+ obj . init = async function ( ) {
50+
51+ await libs ( ) ;
52+
53+ } //init
54+
55+
56+
57+ function libs ( ) {
58+
59+ var resolve , promise = new Promise ( res => resolve = res ) ;
60+
61+ var script = document . createElement ( 'script' ) ;
62+ script . src = 'https://cdn.jsdelivr.net/npm/markdown-it/dist/markdown-it.min.js' ;
63+ script . onload = onload ;
64+ document . head . append ( script ) ;
65+
66+ return promise ;
67+
68+
69+ function onload ( ) {
70+
71+ md = markdownit ( ) ;
72+ resolve ( ) ;
73+
74+ } //onload
75+
76+ } //libs
77+
78+
79+ //:
80+
81+
82+ obj . initdom = function ( rootnode ) {
83+
84+ shadow = host . shadowRoot ;
85+
86+ output = $ ( shadow , '#output' ) ;
87+
88+
89+ } //initdom
90+
91+
92+ //:
93+
94+
95+
96+ obj . display = async function ( txt ) {
97+
98+ await libs ;
99+
100+ var html = md . render ( txt ) ;
101+ output . innerHTML = html ;
102+
103+ } //show
104+
105+
106+
107+ return obj ;
108+
109+ } ) //output_md
110+
111+ </ script >
112+
113+ </ output-md >
114+
You can’t perform that action at this time.
0 commit comments