mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
Add plugin to extend links popup with predefined links (unfinished)
This commit is contained in:
parent
997b7cb188
commit
dbe5141189
@ -60,6 +60,18 @@ class RichEditor extends FormWidgetBase
|
||||
$this->vars['value'] = $this->getLoadValue();
|
||||
}
|
||||
|
||||
public function onGetPageLinks()
|
||||
{
|
||||
$links = [
|
||||
['name' => 'Select a page...', 'url' => false],
|
||||
['name' => 'Some url', 'url' => 'some/url'],
|
||||
['name' => 'Other thing', 'url' => 'else/thing'],
|
||||
['name' => 'More', 'url' => 'more/thing']
|
||||
];
|
||||
|
||||
return ['links' => $links];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
File diff suppressed because one or more lines are too long
@ -11,6 +11,7 @@
|
||||
=require plugin.fullscreen.js
|
||||
=require plugin.figure.js
|
||||
=require plugin.table.js
|
||||
=require plugin.pagelinks.js
|
||||
=require richeditor.js
|
||||
|
||||
*/
|
||||
|
@ -0,0 +1,52 @@
|
||||
if (!RedactorPlugins) var RedactorPlugins = {};
|
||||
|
||||
(function($)
|
||||
{
|
||||
RedactorPlugins.pagelinks = function()
|
||||
{
|
||||
return {
|
||||
init: function()
|
||||
{
|
||||
if (!this.opts.pageLinksHandler) return
|
||||
|
||||
this.modal.addCallback('link', $.proxy(this.pagelinks.load, this))
|
||||
},
|
||||
load: function()
|
||||
{
|
||||
return; // Disabled for now
|
||||
|
||||
var $select = $('<select id="redactor-page-links" />')
|
||||
$('#redactor-modal-link-insert').prepend($select)
|
||||
|
||||
this.pagelinks.storage = {};
|
||||
|
||||
this.$editor.request(this.opts.pageLinksHandler, {
|
||||
success: $.proxy(function(data) {
|
||||
|
||||
$.each(data.links, $.proxy(function(key, val) {
|
||||
this.pagelinks.storage[key] = val
|
||||
$select.append($('<option>').val(key).html(val.name))
|
||||
}, this))
|
||||
|
||||
$select.on('change', $.proxy(this.pagelinks.select, this))
|
||||
|
||||
}, this)
|
||||
})
|
||||
},
|
||||
select: function(e)
|
||||
{
|
||||
var key = $(e.target).val()
|
||||
var name = '', url = ''
|
||||
if (key !== 0) {
|
||||
name = this.pagelinks.storage[key].name
|
||||
url = this.pagelinks.storage[key].url
|
||||
}
|
||||
|
||||
$('#redactor-link-url').val(url)
|
||||
|
||||
var $el = $('#redactor-link-url-text')
|
||||
if ($el.val() === '') $el.val(name)
|
||||
}
|
||||
};
|
||||
};
|
||||
})(jQuery);
|
@ -37,6 +37,8 @@
|
||||
RichEditor.prototype.constructor = RichEditor
|
||||
|
||||
RichEditor.DEFAULTS = {
|
||||
dataLocker: null,
|
||||
linksHandler: null,
|
||||
stylesheet: null,
|
||||
fullpage: false
|
||||
}
|
||||
@ -76,6 +78,7 @@
|
||||
keydownCallback: this.proxy(this.onKeydown),
|
||||
enterCallback: this.proxy(this.onEnter),
|
||||
changeCallback: this.proxy(this.onChange),
|
||||
pageLinksHandler: this.options.linksHandler,
|
||||
initCallback: function() { self.build(this) }
|
||||
}
|
||||
|
||||
@ -83,7 +86,7 @@
|
||||
redactorOptions.fullpage = true
|
||||
}
|
||||
|
||||
redactorOptions.plugins = ['fullscreen', 'figure', 'table', 'mediamanager']
|
||||
redactorOptions.plugins = ['fullscreen', 'figure', 'table', 'pagelinks', 'mediamanager']
|
||||
redactorOptions.buttons = ['html', 'formatting', 'bold', 'italic', 'unorderedlist', 'orderedlist', 'link', 'horizontalrule'],
|
||||
|
||||
this.$textarea.redactor(redactorOptions)
|
||||
@ -241,7 +244,8 @@
|
||||
// If the paragraph is empty, remove it.
|
||||
if ($.trim($paragraph.text()).length == 0)
|
||||
$paragraph.remove()
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// If block is inserted into another UI block, insert it after the existing block.
|
||||
var $closestBlock = $(current).closest('[data-ui-block]')
|
||||
if ($closestBlock.length > 0) {
|
||||
@ -361,11 +365,11 @@
|
||||
}
|
||||
|
||||
RichEditor.prototype.onFocus = function() {
|
||||
this.$el.addClass('editor-focus')
|
||||
this.$el.addClass('editor-focus')
|
||||
}
|
||||
|
||||
RichEditor.prototype.onBlur = function() {
|
||||
this.$el.removeClass('editor-focus')
|
||||
this.$el.removeClass('editor-focus')
|
||||
}
|
||||
|
||||
RichEditor.prototype.onKeydown = function(ev) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user