kopia lustrzana https://github.com/wagtail/wagtail
Add mechanism for apps to register their own hallo.js plugins
rodzic
4785a41c38
commit
1ecc215759
|
@ -1,3 +1,15 @@
|
|||
var halloPlugins = {
|
||||
'halloformat': {},
|
||||
'halloheadings': {formatBlocks: ["p", "h2", "h3", "h4", "h5"]},
|
||||
'hallolists': {},
|
||||
'hallohr': {},
|
||||
'halloreundo': {},
|
||||
'hallowagtaillink': {},
|
||||
};
|
||||
function registerHalloPlugin(name, opts) {
|
||||
halloPlugins[name] = (opts || {});
|
||||
}
|
||||
|
||||
function makeRichTextEditable(id) {
|
||||
var input = $('#' + id);
|
||||
var richText = $('<div class="richtext"></div>').html(input.val());
|
||||
|
@ -19,17 +31,7 @@ function makeRichTextEditable(id) {
|
|||
richText.hallo({
|
||||
toolbar: 'halloToolbarFixed',
|
||||
toolbarcssClass: 'testy',
|
||||
plugins: {
|
||||
'halloformat': {},
|
||||
'halloheadings': {formatBlocks: ["p", "h2", "h3", "h4", "h5"]},
|
||||
'hallolists': {},
|
||||
'hallohr': {},
|
||||
'halloreundo': {},
|
||||
'hallowagtailimage': {},
|
||||
'hallowagtailembeds': {},
|
||||
'hallowagtaillink': {},
|
||||
'hallowagtaildoclink': {}
|
||||
}
|
||||
plugins: halloPlugins
|
||||
}).bind('hallomodified', function(event, data) {
|
||||
input.val(data.content);
|
||||
if (!removeStylingPending) {
|
||||
|
|
|
@ -34,7 +34,12 @@ def editor_js():
|
|||
((settings.STATIC_URL, filename) for filename in js_files)
|
||||
)
|
||||
return js_includes + format_html(
|
||||
"<script>window.chooserUrls.documentChooser = '{0}';</script>",
|
||||
"""
|
||||
<script>
|
||||
window.chooserUrls.documentChooser = '{0}';
|
||||
registerHalloPlugin('hallowagtaildoclink');
|
||||
</script>
|
||||
""",
|
||||
urlresolvers.reverse('wagtaildocs_chooser')
|
||||
)
|
||||
hooks.register('insert_editor_js', editor_js)
|
||||
|
|
|
@ -17,7 +17,10 @@ hooks.register('register_admin_urls', register_admin_urls)
|
|||
def editor_js():
|
||||
return format_html("""
|
||||
<script src="{0}{1}"></script>
|
||||
<script>window.chooserUrls.embedsChooser = '{2}';</script>
|
||||
<script>
|
||||
window.chooserUrls.embedsChooser = '{2}';
|
||||
registerHalloPlugin('hallowagtailembeds');
|
||||
</script>
|
||||
""",
|
||||
settings.STATIC_URL,
|
||||
'wagtailembeds/js/hallo-plugins/hallo-wagtailembeds.js',
|
||||
|
|
|
@ -34,7 +34,12 @@ def editor_js():
|
|||
((settings.STATIC_URL, filename) for filename in js_files)
|
||||
)
|
||||
return js_includes + format_html(
|
||||
"<script>window.chooserUrls.imageChooser = '{0}';</script>",
|
||||
"""
|
||||
<script>
|
||||
window.chooserUrls.imageChooser = '{0}';
|
||||
registerHalloPlugin('hallowagtailimage');
|
||||
</script>
|
||||
""",
|
||||
urlresolvers.reverse('wagtailimages_chooser')
|
||||
)
|
||||
hooks.register('insert_editor_js', editor_js)
|
||||
|
|
Ładowanie…
Reference in New Issue