-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the Froala WYSIWYG Editor #863
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
0e5978c
Add the froala editor to the inplace text area component
jrjohnson 86bfde6
Adjustments to the experimental froala editor
jrjohnson bdd537d
Add inplace-html to handle WYSIWYG editing
jrjohnson 0a50aa1
Revert inplace-textarea to its original state
jrjohnson 3ee7d3a
Remove the promptText concept from big-text component
jrjohnson 2642ece
Fix icon display for big-text component
jrjohnson d2c80f2
Add html editor where it works
jrjohnson e520ac3
Add html editor to new learning materials
jrjohnson f4ac828
Add HTML editor to the new objective title
jrjohnson 5a9bdee
Adjust tests for new HTML editor
jrjohnson a4370fd
Add HTML editor to Learning material notes
jrjohnson 47ee43d
Reset lists where we display user input
jrjohnson 6283f6c
Added spanish translation for newObjectiveSaved
jrjohnson 9e546ea
Add french translation for newObjectiveSaved
jrjohnson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
import Ember from 'ember'; | ||
|
||
const {computed, Handlebars} = Ember; | ||
const {SafeString} = Handlebars; | ||
const {collect, sum} = computed; | ||
|
||
export default Ember.Component.extend({ | ||
expanded: false, | ||
classNames: ['big-text'], | ||
|
@@ -8,28 +12,36 @@ export default Ember.Component.extend({ | |
expandIcon: 'info-circle', | ||
text: '', | ||
ellipsis: 'ellipsis-h', | ||
lengths: Ember.computed.collect('length', 'slippage'), | ||
totalLength: Ember.computed.sum('lengths'), | ||
promptText: '', | ||
showIcons: function(){ | ||
return this.get('displayText') !== this.get('cleanText'); | ||
}.property('displayText', 'text'), | ||
cleanText: function(){ | ||
var text = this.get('text'); | ||
if(text === undefined || text == null){ | ||
return this.get('promptText')?this.get('promptText').toString():''; | ||
lengths: collect('length', 'slippage'), | ||
totalLength: sum('lengths'), | ||
renderHtml: true, | ||
showIcons: computed('displayText', 'text', 'renderHtml', function(){ | ||
if(this.get('renderHtml')){ | ||
return this.get('displayText').toString() !== this.get('text'); | ||
} else { | ||
return this.get('displayText').toString() !== this.get('cleanText'); | ||
} | ||
}), | ||
cleanText: computed('text', function(){ | ||
//strip any possible HTML out of the text | ||
return text.replace(/(<([^>]+)>)/ig,""); | ||
}.property('text'), | ||
displayText: function(){ | ||
var text = this.get('cleanText'); | ||
if(this.get('expanded') || text.length < this.get('totalLength')){ | ||
return text; | ||
return this.get('text').replace(/(<([^>]+)>)/ig,""); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. likewise. |
||
}), | ||
displayText: computed('cleanText', 'totalLength', 'length', 'expanded', function(){ | ||
let cleanText = this.get('cleanText'); | ||
let text; | ||
if(this.get('expanded') || cleanText.length < this.get('totalLength')){ | ||
if(this.get('renderHtml')){ | ||
text = this.get('text'); | ||
} else { | ||
text = cleanText; | ||
} | ||
} else { | ||
text = cleanText.substring(0, this.get('length')); | ||
} | ||
|
||
return text.substring(0, this.get('length')); | ||
}.property('cleanText', 'totalLength', 'length', 'expanded'), | ||
|
||
return new SafeString(text); | ||
|
||
}), | ||
actions: { | ||
click: function(){ | ||
this.sendAction(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import Ember from 'ember'; | ||
import config from 'ilios/config/environment'; | ||
import InPlace from 'ilios/mixins/inplace'; | ||
|
||
export default Ember.Component.extend(InPlace, { | ||
classNames: ['editinplace', 'inplace-html'], | ||
editorParams: config.froalaEditorDefaults, | ||
willDestroyElement(){ | ||
this.$('.control .froala-box').editable('destroy'); | ||
}, | ||
actions: { | ||
grabChangedValue: function(event, editor){ | ||
if(editor){ | ||
this.send('changeValue', editor.getHTML()); | ||
} | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<span class='content'> | ||
{{#unless isEditing}} | ||
<span class='editable'> | ||
{{#if value.length}} | ||
{{big-text text=value action='edit' renderHtml=true}} | ||
{{else}} | ||
<span {{action 'edit'}}>{{clickPrompt}}</span> | ||
{{/if}} | ||
</span> | ||
{{else}} | ||
<span class='editor'> | ||
<span class='control list-reset'> | ||
{{froala-editor | ||
params=editorParams | ||
value=buffer | ||
contentChanged=(action "grabChangedValue") | ||
}} | ||
</span> | ||
<span class='actions'> | ||
<button class='done icon' title='{{t "general.save"}}' {{action 'save'}}>{{fa-icon 'check'}}</button> | ||
<button class='cancel icon' title='{{t "general.cancel"}}' {{action 'cancel'}}>{{fa-icon 'times'}}</button> | ||
</span> | ||
</span> | ||
{{/unless}} | ||
</span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems kinda hinky.
why not use jQuery here: http://api.jquery.com/text/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never occured to me actually. Good change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stopfstedt jquery.text() is for working with elements. We're working with a string passed from somewhere else like the DB. This would lead to something like:
return Ember.$("<div/>").html(text).text();
I'm not sure that isn't more confusing. This isn't a security step, its purely to easy in the display. Thoughts?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, forgot that you'll actually have to wrap your string in markup first.
that is more confusing.
let's go with your initial solution for now.