-
Notifications
You must be signed in to change notification settings - Fork 40
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
Feature/link-block #728
Feature/link-block #728
Changes from all commits
0325907
fee00c7
b3cddb2
e80189b
71fa14b
6c1e3d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,13 +12,6 @@ | |
populateToolbar: function(toolbar) { | ||
var button, widget; | ||
|
||
var getEnclosing = function(tag) { | ||
var node; | ||
|
||
node = widget.options.editable.getSelection().commonAncestorContainer; | ||
return $(node).parents(tag).get(0); | ||
}; | ||
|
||
widget = this; | ||
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. Just noting that this is removed because it wasn't actually being used. |
||
|
||
button = $('<span></span>'); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
(function() { | ||
(function($) { | ||
return $.widget('IKS.sansSerifButton', { | ||
options: { | ||
uuid: '', | ||
editable: null | ||
}, | ||
populateToolbar: function(toolbar) { | ||
var button, | ||
widget = this; | ||
|
||
var checkClass = function() { | ||
var node = widget.options.editable.getSelection().commonAncestorContainer; | ||
var parent = $(node).parents('span').get(0); | ||
if (parent) { | ||
return parent.classList.contains('t-sans'); | ||
} else { | ||
return false; | ||
} | ||
}; | ||
|
||
button = $('<span></span>'); | ||
button.hallobutton({ | ||
uuid: this.options.uuid, | ||
editable: this.options.editable, | ||
label: 'Sans-serif link', | ||
icon: 'icon-edit', | ||
command: null, | ||
queryState: function(e) { | ||
// Show the active state if it has the t-sans class already | ||
return button.hallobutton('checked', checkClass()); | ||
} | ||
}); | ||
|
||
toolbar.append(button); | ||
|
||
button.on('click', function() { | ||
// Get the selected node, find it's parent element and wrap it in a t-sans span | ||
var node = widget.options.editable.getSelection().commonAncestorContainer; | ||
var parent = $(node).parents('a').get(0); | ||
$(parent).wrap('<span class="t-sans"></span>'); | ||
widget.options.editable.setModified(); | ||
}); | ||
} | ||
}); | ||
})(jQuery); | ||
}).call(this); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,29 +5,7 @@ | |
@hooks.register('construct_whitelister_element_rules') | ||
def whitelister_element_rules(): | ||
return { | ||
# Commenting out disallowed tags so its easier to remember & revert | ||
'a': attribute_rule({'href': check_url}), | ||
'b': allow_without_attributes, | ||
# 'br': allow_without_attributes, | ||
# 'div': allow_without_attributes, | ||
'em': allow_without_attributes, | ||
'h1': allow_without_attributes, | ||
'h2': allow_without_attributes, | ||
'h3': allow_without_attributes, | ||
'h4': allow_without_attributes, | ||
'h5': allow_without_attributes, | ||
'h6': allow_without_attributes, | ||
'hr': allow_without_attributes, | ||
'i': allow_without_attributes, | ||
'img': attribute_rule({'src': check_url, 'width': True, 'height': True, | ||
'alt': True}), | ||
'li': allow_without_attributes, | ||
'ol': allow_without_attributes, | ||
'p': allow_without_attributes, | ||
'strong': allow_without_attributes, | ||
'sub': allow_without_attributes, | ||
'sup': allow_without_attributes, | ||
'ul': allow_without_attributes, | ||
'span': attribute_rule({'class': True}), | ||
} | ||
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. I learned that these rules are the default ones, so we don't need to include them... just the ones that we want to add. |
||
|
||
@hooks.register('insert_editor_js') | ||
|
@@ -37,13 +15,15 @@ def editor_js(): | |
<script src="/static/js/vendor/rangy-core.js"></script> | ||
<script src="/static/js/vendor/rangy-selectionsaverestore.js"></script> | ||
<script src="/static/js/hallo-edit-html.js"></script> | ||
<script src="/static/js/hallo-sans-serif.js"></script> | ||
<script src="/static/js/customize-editor.js"></script> | ||
<script src="/static/js-beautify/js/lib/beautify-html.js"></script> | ||
<script src="/static/ace-builds/src-noconflict/ace.js"></script> | ||
<script src="/static/ace-builds/src-noconflict/mode-html.js"></script> | ||
<script> | ||
registerHalloPlugin('editHtmlButton'); | ||
registerHalloPlugin('hallocleanhtml'); | ||
registerHalloPlugin('sansSerifButton'); | ||
</script> | ||
''') | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{% load wagtailcore_tags %} | ||
|
||
<p class="usa-width-one-half"> | ||
<a class="t-sans" href="{{ self.url }}">{{ self }} »</a> | ||
</p> |
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.
Does it not get this class from fec-style?
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.
This stylesheet is loaded by the admin interface, which doesn't load fec-style. I added this as a one-off style so that you can know that the button works.
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.
Gotcha!