git ssb

2+

mixmix / ticktack



Commit 909b4b2756a7aaa99f6114938b240b53beb129c8

attach medium editor to page it belongs to

mix irving committed on 4/10/2018, 10:06:11 PM
Parent: 8e1f9e4430c79fef119b27ecdf1f7ce8d0869fba

Files changed

app/page/blogNew.jschanged
app/page/blogNew.mcsschanged
app/page/blogNew.jsView
@@ -4,8 +4,9 @@
44 const pull = require('pull-stream')
55 const marksum = require('markdown-summary')
66 const MediumEditor = require('medium-editor').MediumEditor
77 const MediumToMD = require('medium-editor-markdown')
8 +const CustomHtml = require('medium-editor-custom-async')
89
910 exports.gives = nest('app.page.blogNew')
1011
1112 exports.needs = nest({
@@ -33,9 +34,12 @@
3334 summary: Value(),
3435 text: Value('')
3536 })
3637
37- const mediumComposer = h('div.editor')
38 + const mediumComposer = h('div.editor', {
39 + 'ev-input': e => {
40 + }
41 + })
3842 const composer = api.message.html.compose(
3943 {
4044 meta,
4145 placeholder: strings.blogNew.actions.writeBlog,
@@ -86,15 +90,24 @@
8690 placeholder: strings.blogNew.field.summary
8791 })
8892 ]),
8993 mediumComposer,
94 + h('Button', {
95 + 'ev-click': () => {
96 + var img = h('img', { src: 'http://localhost:8989/blobs/get/%264TKyoyZmjjtpPvwiSR%2BGQIgrJs8o6XmzfUDZ5p1PP30%3D.sha256' })
97 + // var e = MediumEditor.getEditorFromElement(mediumComposer)
98 + // e.serialize()['element-0'].value
99 + mediumComposer.appendChild(img)
100 + }
101 + }, 'Add Image'),
90102 composer
91103 ])
92104 ])
93105 ])
94106
95107 function initialiseMedium () {
96108 new MediumEditor(mediumComposer, {
109 + elementsContainer: page,
97110 toolbar: {
98111 allowMultiParagraphSelection: true,
99112 buttons: ['bold', 'italic', 'underline', 'anchor', 'h2', 'h3', 'quote'],
100113 diffLeft: 0,
@@ -109,9 +122,23 @@
109122 sticky: false,
110123 updateOnEmptySelection: false
111124 },
112125 extensions: {
113- markdown: new MediumToMD (md => meta.text.set(md))
126 + markdown: new MediumToMD (
127 + {
128 + toMarkdownOptions: {
129 + converters: [{
130 + filter: 'img',
131 + replacement: (content, node) => {
132 + var blob = decodeURIComponent(node.src.replace('http://localhost:8989/blobs/get/', ''))
133 + return `![](${blob})`
134 + }
135 + }]
136 + },
137 + events: ['input', 'change', 'DOMNodeInserted']
138 + },
139 + md => meta.text.set(md)
140 + )
114141 }
115142 })
116143 }
117144 initialiseMedium()
app/page/blogNew.mcssView
@@ -12,9 +12,9 @@
1212
1313 div.field {
1414 margin-bottom: .5rem
1515 $maxWidth
16-
16 +
1717 display: flex
1818 align-items: center
1919
2020 div.label {
@@ -32,25 +32,25 @@
3232 $borderSubtle
3333 outline: none
3434 }
3535
36-
36 +
3737 -channel {}
3838 -title {}
3939 }
4040
4141 div.editor{
4242 background-color: #fff
4343 padding: 1rem
4444 margin-top: 2rem
45- min-height: 30rem
45 + min-height: 30rem
4646 outline: none
4747 }
4848
4949 div.Compose {
5050 textarea {
5151 margin-top: 2rem
52- min-height: 30rem
52 + min-height: 30rem
5353 }
5454 }
5555 }
5656 }

Built with git-ssb-web