dante-editor 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  require "dante-editor/version"
2
2
 
3
3
  module DanteEditor
4
- VERSION = "0.1.6"
4
+ VERSION = "0.1.7"
5
5
  end
@@ -0,0 +1,45 @@
1
+ ---
2
+ title: Dante Editor example
3
+ ---
4
+
5
+
6
+ <article class="postArticle">
7
+ <div class="postContent">
8
+
9
+ <div class="notesSource">
10
+
11
+ <div class="debug postField postField--body smart-media-plugin">
12
+
13
+ <section class="section--first section--last">
14
+
15
+ <div class="section-divider layoutSingleColumn">
16
+ <hr class="section-divider">
17
+ </div>
18
+
19
+ <div class="section-content">
20
+ <div class="section-inner layoutSingleColumn">
21
+
22
+ <%= partial "partials/existing_content" %>
23
+
24
+ </div>
25
+
26
+ </div>
27
+
28
+ </div>
29
+
30
+ </div>
31
+
32
+ </div>
33
+
34
+ </div>
35
+
36
+ </article>
37
+
38
+
39
+
40
+ <script type="text/javascript">
41
+ article = new Dante.Article({ el: ".postField--body" })
42
+ article.start()
43
+ </script>
44
+
45
+
@@ -0,0 +1,35 @@
1
+
2
+ <h3 class="graf graf--h3 graf--first" name="mmvdzpc52t4479fi529">Dante Editor</h3>
3
+
4
+ <h4 class="graf graf--h4" name="osd5p3nu17etutyb9">Just another Medium editor clone.</h4>
5
+
6
+ <p class="graf graf--p" name="a1ffkj6snfqkwzjv2t9"><strong>Motivation:</strong><br></p>
7
+
8
+ <blockquote class="graf graf--blockquote" name="vb1qp19ubnbx1qcnxw29">
9
+ <p>So far we have tried all the Medium.com wysiwyg clones out there, those are really great, and each have their pros and cons. <a href="http://howtox.com/medium-editor-clones-in-js/" class="markup--anchor markup--p-anchor" data-href="http://howtox.com/medium-editor-clones-in-js/">But none of them has all the features that the real medium editor provides.</a> So we wondered, How complicated could be write our own version of Medium's wysiwyg?</p>
10
+ </blockquote>
11
+
12
+ <h3 class="graf graf--h3" name="x99z80r16pibtjoflxr">This is a live demo:</h3>
13
+ <p class="graf graf--p" name="ng6qy18yt8no76hfflxr">Please click the image or type everywere. Use it as you were using Medium. Have fun!<br></p>
14
+
15
+ <figure contenteditable="false" class="graf graf--figure is-selected" name="mg4tfk9ud8e0cnmi" tabindex="0"> <div style="max-width: 245px; max-height: 184px;" class="aspectRatioPlaceholder is-locked"> <div style="padding-bottom: 75.102%;" class="aspect-ratio-fill"></div> <img src="http://i.imgur.com/0erQFLu.gif" data-height="184" data-width="245" data-image-id="" class="graf-image" data-delayed-src=""> </div> <figcaption contenteditable="true" data-default-value="Type caption for image (optional)" class="imageCaption">this is a text</figcaption> </figure><p class="graf graf--p" name="xyif2a1piq5ffb9be29">
16
+ This Library will <em>work</em> fine on modern browsers, such as Chrome, Safari, FF and IE.
17
+ We don't have any intentions to target all browsers versions. Really… If you like this library and you need backward compatibility for an specific version, you can submit a patch to help with the development or just upgrade your shitty browser :D<br></p>
18
+
19
+ <pre class="graf graf--pre" name="l44ayschy478wa5rk9">Dante is being at active development, so the internal api could change a lot but is good to use.
20
+ </pre>
21
+
22
+ <p class="graf graf--p" name="v1qyjusgoj13y8sq0k9">(This library is free and will stay free, but needs your support to sustain its development. There are lots of desirable new features and maintenance to do. If you work for a company using Dante or have the means to do so, please consider financial support)<br></p>
23
+
24
+ <p class="graf graf--p" name="uuajflrkzboaxyxh6w29"><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=QVH5DXB326YQG" class="markup--anchor markup--p-anchor" data-href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=QVH5DXB326YQG">Donate at paypal.</a><br></p>
25
+
26
+ <h4 class="graf graf--h4" name="kseec8atv22n4b1emi">MAINTAINERS:</h4>
27
+
28
+ <ul class="postList" name="r9iluzwo1lb2617nwmi">
29
+ <li class="graf graf--li"><a data-id="1" data-type="user" data-href="api/miguel.json" class="markup--user markup--p-user"> Miguel Michelson </a></li>
30
+ <li class="graf graf--li"><a data-id="1" data-type="user" data-href="api/cristian.json" class="markup--user markup--p-user"> Cristian Ferrari </a></li>
31
+ </ul>
32
+
33
+ <p class="graf graf--p graf--last" name="saehi6q7u2jc2ph0vn29"><a class="markup--anchor markup--p-anchor">Licensed under MIT.</a> 2014<br></p>
34
+
35
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dante-editor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Michelson
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-06-18 00:00:00.000000000 Z
12
+ date: 2016-06-19 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: dante-editor yet another Medium editor clone.
15
15
  email:
@@ -38,6 +38,7 @@ files:
38
38
  - app/assets/fonts/dante/fontello.woff
39
39
  - app/assets/images/dante/media-loading-placeholder.png
40
40
  - app/assets/javascripts/dante.js
41
+ - app/assets/javascripts/dante/article.js.coffee
41
42
  - app/assets/javascripts/dante/behavior.js.coffee
42
43
  - app/assets/javascripts/dante/behaviors/image.js.coffee
43
44
  - app/assets/javascripts/dante/behaviors/list.js.coffee
@@ -47,7 +48,10 @@ files:
47
48
  - app/assets/javascripts/dante/dante.js.coffee.erb
48
49
  - app/assets/javascripts/dante/editor.js.coffee
49
50
  - app/assets/javascripts/dante/menu.js.coffee
50
- - app/assets/javascripts/dante/popover.js.coffee
51
+ - app/assets/javascripts/dante/popovers/anchor.js.coffee
52
+ - app/assets/javascripts/dante/popovers/card.js.coffee
53
+ - app/assets/javascripts/dante/popovers/image.js.coffee
54
+ - app/assets/javascripts/dante/popovers/typeahead.js.coffee
51
55
  - app/assets/javascripts/dante/tooltip.js.coffee
52
56
  - app/assets/javascripts/dante/tooltip_widget.js.coffee
53
57
  - app/assets/javascripts/dante/tooltip_widgets/embed.js.coffee
@@ -129,10 +133,12 @@ files:
129
133
  - source/layouts/layout.erb
130
134
  - source/layouts/spec.html.erb
131
135
  - source/lists.html.erb
136
+ - source/non_editable.erb
132
137
  - source/partials/_content.erb
133
138
  - source/partials/_example_1.erb
134
139
  - source/partials/_example_2.erb
135
140
  - source/partials/_example_3.erb
141
+ - source/partials/_existing_content.erb
136
142
  - source/partials/_lists.erb
137
143
  - source/partials/_readme.markdown
138
144
  - source/partials/test/_example_1.erb
@@ -1,424 +0,0 @@
1
- utils = Dante.utils
2
-
3
- class Dante.Editor.PopOver extends Dante.View
4
- el: "body"
5
-
6
- events:
7
- "mouseover .popover--tooltip": "cancelHide"
8
- "mouseout .popover--tooltip": "hide"
9
-
10
- initialize: (opts = {})->
11
- utils.log("initialized popover")
12
- @pop_over_element = ".popover--tooltip"
13
- @editor = opts.editor
14
- @hideTimeout
15
- @settings = {timeout: 300}
16
-
17
- template: ()->
18
- "<div class='dante-popover popover--tooltip popover--Linktooltip popover--bottom is-active'>
19
- <div class='popover-inner'>
20
- <a href='#' target='_blank'> Link </a>
21
- </div>
22
- <div class='popover-arrow'>
23
- </div>
24
- </div>"
25
-
26
- #display & copy original link
27
- positionAt: (ev)->
28
- target = $(ev.currentTarget)
29
- wrapperOffset = target.closest('article.postArticle').offset()
30
- target_positions = @resolveTargetPosition(target)
31
- target_offset = target.offset()
32
- target_width = target.outerWidth()
33
- target_height = target.outerHeight()
34
- popover_width = @findElement().outerWidth()
35
- top_value = target_positions.top + target_height
36
- left_value = target_offset.left + (target_width/2) - (popover_width/2) - wrapperOffset.left
37
-
38
- @findElement()
39
- .css("top", top_value)
40
- .css("left", left_value )
41
- .show()
42
-
43
- @handleDirection(target)
44
-
45
- displayAt: (ev)->
46
- @cancelHide()
47
- target = $(ev.currentTarget)
48
- @findElement()
49
- .find(".popover-inner a")
50
- .text( target.attr('href') )
51
- .attr('href', target.attr("href") )
52
- @positionAt(ev)
53
- @findElement().css("pointer-events", "auto")
54
- $(@el).show()
55
-
56
- cancelHide: ()->
57
- utils.log "Cancel Hide"
58
- clearTimeout @hideTimeout
59
-
60
- hide: (ev)->
61
- @cancelHide()
62
- @hideTimeout = setTimeout ()=>
63
- @findElement().hide()
64
- , @settings.timeout
65
-
66
- resolveTargetPosition: (target)->
67
- if target.parents(".graf--mixtapeEmbed").exists()
68
- target.parents(".graf--mixtapeEmbed").position()
69
- else
70
- target.position()
71
-
72
- handleDirection: (target)->
73
- if target.parents(".graf--mixtapeEmbed").exists()
74
- @findElement().removeClass("popover--bottom").addClass("popover--top")
75
- else
76
- @findElement().removeClass("popover--top").addClass("popover--bottom")
77
-
78
- findElement: ()->
79
- $(@el).find(@pop_over_element)
80
-
81
- render: ()->
82
- $(@template()).insertAfter(@editor.$el)
83
-
84
- class Dante.Editor.PopOverTypeAhead extends Dante.Editor.PopOver
85
- el: "body"
86
-
87
- events:
88
- "mouseover .popover--typeahead": "cancelHide"
89
- "mouseout .popover--typeahead": "hide"
90
-
91
- "click .typeahead-item": "handleOptionSelection"
92
-
93
- initialize: (opts = {})->
94
- @pop_over_element = "popover--typeahead"
95
- utils.log("initialized popover")
96
- @editor = opts.editor
97
- @hideTimeout
98
- @settings = {timeout: 300}
99
- @typeaheadStyles()
100
-
101
- template: ()->
102
- "<div class='dante-popover popover--typeahead js-popover typeahead typeahead--mention popover--maxWidth360 popover--bottom is-active'>
103
- <div class='popover-inner js-popover-inner'>
104
- <ul></ul>
105
- </div>
106
- <div class='popover-arrow' style='left: 297px;'></div>
107
- </div>"
108
-
109
- popoverItem: (item)->
110
- "<li class='typeahead-item'
111
- data-action-value='#{item.text}'
112
- data-action='typeahead-populate' data-id='#{item.id}'
113
- data-type='#{item.type}'
114
- data-href='#{item.href}'>
115
-
116
- <div class='dante-avatar'>
117
- <img src='#{item.avatar}'
118
- class='avatar-image avatar-image--icon'
119
- alt='#{item.text}'>
120
-
121
- <span class='avatar-text'>#{item.text}</span>
122
- <em class='avatar-description'>#{item.description}</em>
123
-
124
- </div>
125
-
126
- </li>"
127
-
128
- typeaheadStyles: ->
129
- @classesForCurrent = "typeahead typeahead--mention popover--maxWidth360"
130
-
131
- handleOptionSelection: (ev)->
132
- ev.preventDefault
133
- console.log "Select option here!"
134
- data = $(ev.currentTarget).data()
135
- $(".markup--query").replaceWith(@linkTemplate(data))
136
- @hide(0)
137
- #@setRangeAt(new_paragraph[0])
138
-
139
- linkTemplate: (data)->
140
- "<a href='#'
141
- data-type='#{data.type}'
142
- data-href='#{data.href}'
143
- data-id='#{data.id}'
144
- class='markup--user markup--p-user'>
145
- #{data.actionValue}
146
- </a>"
147
-
148
- #display & copy original link
149
- positionAt: (target)->
150
- target = $(target)
151
- wrapperOffset = target.closest('article.postArticle').offset()
152
- target_positions = @resolveTargetPosition(target)
153
- target_offset = target.offset()
154
- target_width = target.outerWidth()
155
- target_height = target.outerHeight()
156
- popover_width = @findElement().outerWidth()
157
- top_value = target_positions.top + target_height
158
- left_value = target_offset.left + (target_width/2) - (popover_width/2) - wrapperOffset.left
159
-
160
- @findElement()
161
- .css("top", top_value)
162
- .css("left", left_value )
163
- .show()
164
-
165
- @handleDirection(target)
166
-
167
- displayAt: (ev)->
168
- @cancelHide()
169
- #target = $(ev.currentTarget)
170
- #$(@el).find(".popover-inner a").text( target.attr('href') ).attr('href', target.attr("href") )
171
- @positionAt(ev)
172
- #$(@el).find(".popover--tooltip").css("pointer-events", "auto")
173
- #$(@el).show()
174
-
175
- cancelHide: ()->
176
- utils.log "Cancel Hide"
177
- clearTimeout @hideTimeout
178
-
179
- findElement: ->
180
- $(@el).find(".#{@pop_over_element}")
181
-
182
- hide: (ev, timeout = @settings.timeout)->
183
- @cancelHide()
184
- @hideTimeout = setTimeout ()=>
185
- @findElement().hide()
186
- , timeout
187
-
188
- appendData: (data)->
189
- @findElement().find(".popover-inner ul").html("")
190
- _.each data, (item)=>
191
- @findElement().find(".popover-inner ul").append(@popoverItem(item))
192
-
193
- resolveTargetPosition: (target)->
194
- if target.parents(".graf--mixtapeEmbed").exists()
195
- target.parents(".graf--mixtapeEmbed").position()
196
- else
197
- target.position()
198
-
199
- handleDirection: (target)->
200
- if target.parents(".graf--mixtapeEmbed").exists()
201
- @findElement().removeClass("popover--bottom").addClass("popover--top")
202
- else
203
- @findElement().removeClass("popover--top").addClass("popover--bottom")
204
-
205
- render: ()->
206
- $(@template()).insertAfter(@editor.$el)
207
-
208
- class Dante.Editor.PopOverCard extends Dante.Editor.PopOver
209
-
210
- el: "body"
211
-
212
- events:
213
- "mouseover .popover--card": "cancelHide"
214
- "mouseout .popover--card": "hide"
215
- "mouseover .markup--user" : "displayPopOver"
216
- "mouseout .markup--user" : "hidePopOver"
217
- #"click .typeahead-item": "handleOptionSelection"
218
-
219
- initialize: (opts = {})->
220
- @pop_over_element = ".popover--card"
221
- utils.log("initialized popover")
222
- @editor = opts.editor
223
- @hideTimeout
224
- @settings = {timeout: 300}
225
- @card_data = {}
226
-
227
- template: ()->
228
- "<div class='dante-popover popover--card js-popover popover--animated popover--flexible popover--top is-active'>
229
- <div class='popover-inner js-popover-inner'>
230
- </div>
231
- </div>"
232
-
233
- cardTemplate: ->
234
- "<div class='popoverCard'>
235
- <div class='u-clearfix'>
236
-
237
- <div class='u-floatLeft popoverCard-meta'>
238
- <h4 class='popoverCard-title'>
239
- <a class='link u-baseColor--link'
240
- href='#{@card_data.href}'
241
- title='#{@card_data.text}'
242
- aria-label='#{@card_data.text}'
243
- data-user-id='#{@card_data.id}'
244
- dir='auto'>
245
- #{@card_data.text}
246
- </a>
247
- </h4>
248
- <div class='popoverCard-description'>
249
- #{@card_data.description}
250
- </div>
251
- </div>
252
-
253
- <div class='u-floatRight popoverCard-avatar'>
254
- <a class='link dante-avatar u-baseColor--link'
255
- href='#{@card_data.href}'
256
- title='#{@card_data.text}'
257
- aria-label='#{@card_data.text}'
258
- data-user-id='#{@card_data.id}'
259
- dir='auto'>
260
- <img src='#{@card_data.avatar}'
261
- class='avatar-image avatar-image--small'
262
- alt='#{@card_data.text}'>
263
- </a>
264
- </div>
265
- </div>
266
- #{ @footerTemplate() }
267
- <div class='popover-arrow'></div>
268
-
269
- </div>"
270
-
271
- # TODO: implement footer
272
- footerTemplate: ->
273
- ""
274
- ###
275
- "<div class='popoverCard-actions u-clearfix'>
276
- <div class='u-floatLeft popoverCard-stats'>
277
- <span class='popoverCard-stat'>
278
- Following
279
- <span class='popoverCard-count js-userFollowingCount'>124</span>
280
- </span>
281
- <span class='popoverCard-stat'>
282
- Followers
283
- <span class='popoverCard-count js-userFollowersCount'>79</span>
284
- </span>
285
- </div>
286
- </div>"
287
- ###
288
-
289
- displayPopOver: (ev)->
290
- @.displayAt(ev)
291
-
292
- displayAt: (ev)->
293
- @cancelHide()
294
-
295
- $.getJSON($(ev.currentTarget).data().href)
296
- .success (data)=>
297
- if @editor.suggest_resource_handler
298
- @card_data = @editor.suggest_resource_handler(data)
299
- else
300
- @card_data = data
301
-
302
- @refreshTemplate()
303
- @positionAt(ev)
304
-
305
- hidePopOver: (ev)->
306
- @.hide(ev)
307
-
308
- refreshTemplate: ->
309
- $(".popover--card .popover-inner").html(@cardTemplate())
310
-
311
- class Dante.Editor.ImageTooltip extends Dante.Editor.PopOver
312
-
313
- el: "body"
314
-
315
- events:
316
- "click .graf" : "handleHide"
317
- "click .dante-menu-button.align-left": "alignLeft"
318
- "click .dante-menu-button.align-center": "alignCenter"
319
-
320
- # #"click": ""
321
- # #"mouseover .popover--tooltip": "cancelHide"
322
- # #"mouseout .popover--tooltip": "hide"
323
-
324
- initialize: (opts = {})->
325
- utils.log("initialized popover")
326
- @pop_over_element = ".popover--Aligntooltip"
327
- @editor = opts.editor
328
- @hideTimeout
329
- @settings = {timeout: 100}
330
-
331
- alignLeft: (ev)->
332
- @activateLink $(ev.currentTarget)
333
- @findSelectedImage().addClass("graf--layoutOutsetLeft")
334
-
335
- handleHide: (ev)->
336
- target = $(ev.currentTarget)
337
- @hide(ev) unless target.hasClass("graf--figure") and target.hasClass("is-mediaFocused")
338
-
339
- alignCenter: (ev)->
340
- @activateLink $(ev.currentTarget)
341
- @findSelectedImage().removeClass("graf--layoutOutsetLeft")
342
- @repositionWithActiveImage()
343
-
344
- handleActiveClass: ->
345
- @findElement().find(".dante-menu-button").removeClass("active")
346
- if @findSelectedImage().hasClass("graf--layoutOutsetLeft")
347
- @findElement().find(".icon-image-left").parent().addClass("active")
348
- else
349
- @findElement().find(".icon-image-center").parent().addClass("active")
350
-
351
- activateLink: (element)->
352
- setTimeout =>
353
- @repositionWithActiveImage()
354
- , 20
355
-
356
- repositionWithActiveImage: ->
357
- # pass the same element that is passed from click event
358
- @positionPopOver(@findSelectedImage().find("div") )
359
-
360
- template: ()->
361
- "<div class='dante-popover popover--Aligntooltip popover--top'>
362
-
363
- <div class='popover-inner'>
364
-
365
- <ul class='dante-menu-buttons'>
366
-
367
- <li class='dante-menu-button align-left'>
368
- <span class='tooltip-icon icon-image-left'></span>
369
- </li>
370
-
371
- <li class='dante-menu-button align-wide hidden'>
372
- <span class='tooltip-icon icon-image-wide'></span>
373
- </li>
374
-
375
- <li class='dante-menu-button align-fill hidden'>
376
- <span class='tooltip-icon icon-image-fill'></span>
377
- </li>
378
-
379
- <li class='dante-menu-button align-center'>
380
- <span class='tooltip-icon icon-image-center'></span>
381
- </li>
382
-
383
- </ul>
384
-
385
- </div>
386
-
387
- <div class='popover-arrow'>
388
- </div>
389
- </div>"
390
-
391
- positionPopOver: (target)->
392
- target_offset = target.offset()
393
- target_position = target.parent().position()
394
- target_width = target.outerWidth()
395
- target_height = target.outerHeight()
396
- popover_width = @findElement().outerWidth()
397
-
398
- # hacky hack
399
- pad_top = if @findSelectedImage().hasClass("graf--layoutOutsetLeft") then 72 else 74
400
-
401
- top_value = target_position.top - pad_top # target_positions.top + target_height
402
- left_value = target_offset.left + (target_width/2) - (popover_width/2)
403
-
404
- @findElement()
405
- .css("top", top_value)
406
- .css("left", left_value )
407
- .show()
408
- .addClass("is-active")
409
-
410
- @handleActiveClass()
411
-
412
- hide: (ev)->
413
- @cancelHide()
414
- @hideTimeout = setTimeout ()=>
415
- @findElement()
416
- .hide()
417
- .removeClass("is-active")
418
- , @settings.timeout
419
-
420
- findSelectedImage: ->
421
- $(".graf--figure.is-mediaFocused")
422
-
423
- render: ()->
424
- $(@template()).insertAfter(@editor.$el)