fondant-rails 0.2.4 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -6,7 +6,7 @@ Use [fondant](https://github.com/ovenbits-ingredients/fondant) in Rails' asset p
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
- gem 'fondant-rails', '~> 0.2.4'
9
+ gem 'fondant-rails', '~> 0.4.0'
10
10
 
11
11
  ## Contributing
12
12
 
@@ -1,5 +1,5 @@
1
1
  module Fondant
2
2
  module Rails
3
- VERSION = '0.2.4'
3
+ VERSION = '0.4.0'
4
4
  end
5
5
  end
@@ -1,4 +1,4 @@
1
- # ## Fondant v0.2.4
1
+ # ## Fondant v0.4.0
2
2
  #
3
3
  # The icing on the cake for user input. A simple jQuery HTML5 WYSIWYG editor
4
4
  # using `contenteditable`.
@@ -112,8 +112,10 @@ $ ->
112
112
  #
113
113
  bindToolbar: ->
114
114
  for action in @actions
115
- $("[data-action='#{ @type }-#{ action }']").on 'click.fondant',
116
- $.proxy(@[action], this)
115
+ $button = $("[data-action='#{ @type }-#{ action }']")
116
+ $button.on 'click.fondant', { action: action, editor: this }, (event) ->
117
+ event.preventDefault()
118
+ event.data.editor[event.data.action]()
117
119
 
118
120
  # ### unbindToolbar()
119
121
  #
@@ -148,6 +150,18 @@ $ ->
148
150
  options, # options passed in to the constructor
149
151
  @$element.data() # options set in the element's `data` attribute
150
152
 
153
+ # ### getSelection()
154
+ #
155
+ # Grab the currently selected HTML content
156
+ #
157
+ getSelection: ->
158
+ content = window
159
+ .getSelection()
160
+ .getRangeAt(0)
161
+ .cloneContents()
162
+
163
+ $('<span>').html(content).html()
164
+
151
165
  # ### value( html )
152
166
  #
153
167
  # Get the html from the editor, or if a value is passed in, set the html for the editor
@@ -288,7 +302,8 @@ $ ->
288
302
  #
289
303
  custom: (html) ->
290
304
  if navigator.appName == "Microsoft Internet Explorer"
291
- console.log "Custom HTML not yet implemented"
305
+ range = document.selection.createRange()
306
+ range.pasteHTML(html)
292
307
  else
293
308
  @applyFormat 'insertHTML', html
294
309
 
@@ -415,7 +430,7 @@ $ ->
415
430
 
416
431
  if (typeof option == 'string' && args.length < 1)
417
432
 
418
- if option in ['getElement', 'value']
433
+ if option in ['getElement', 'getSelection', 'value']
419
434
  instance = $(this).data('fondant')
420
435
  if instance
421
436
  return instance[option].apply(instance, args)
@@ -1,4 +1,4 @@
1
- // Fondant v0.2.4
1
+ // Fondant v0.4.0
2
2
  // see http://github.com/ovenbits-ingredients/fondant for more information
3
3
  //
4
4
  .fondant-toolbar {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fondant-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: