Skip to content

Commit

Permalink
unacms#3203 quill + embed
Browse files Browse the repository at this point in the history
  • Loading branch information
romanlesnikov committed Nov 16, 2021
1 parent 74898b7 commit 03d5372
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 14 deletions.
4 changes: 2 additions & 2 deletions embed.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
bx_import('BxDolEmbed');

if (bx_get('a') == 'get_link'){
$sLink = bx_get('l');
$sLink = trim(bx_get('l'));

$oEmbed = BxDolEmbed::getObjectInstance();
if ($oEmbed)
echoJson(['code' => $oEmbed->getLinkHTML($sLink), 'js' => strip_tags($oEmbed->addProcessLinkMethod())]);
echoJson(['code' => $oEmbed->getLinkHTML($sLink), 'js' => strip_tags($oEmbed->addProcessLinkMethod()), 'link' => $sLink]);
}
19 changes: 13 additions & 6 deletions inc/js/classes/BxDolPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,22 @@ BxDolPage.prototype.init = function() {
});
}
// process embeds
$(".bx-embed-link").each(function( index ) {
$obj = $(this);
$.getJSON(sUrlRoot + '/embed.php?', {a: 'get_link', l: $(this).attr('source')}, function(aData){
$obj.html(aData.code);
bx_embed_link();
});
$(".bx-embed-link").each(function() {
$(this).html($(this).attr('source'));
$.getJSON(sUrlRoot + '/embed.php?', {a: 'get_link', l: $(this).attr('source')}, $this.embededCallback($(this)));
});
};

BxDolPage.prototype.embededCallback = function(item)
{
return function(oData) {
item.html(oData.code)
if (item.find('a').length > 0){
bx_embed_link(item.find('a')[0]);
}
};
}

BxDolPage.prototype.showHelp = function(oLink, iBlockId)
{
var oData = this._getDefaultParams();
Expand Down
8 changes: 4 additions & 4 deletions inc/js/editor.quill.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ function bx_editor_init(oEditor, oParams){
sLink = $(oPopup).find("input[type = 'text']").val()
$.getJSON(oParams.root_url + 'embed.php?', {a: 'get_link', l: sLink}, function(aData){
oEditor.insertEmbed(100, 'embed-link', {source: sLink, inlinecode : aData.code});
bx_embed_link();
if ($(oParams.selector).next().next().find('.bx-embed-link a[href="' + aData.link + '"]').length > 0)
bx_embed_link($(oParams.selector).next().next().find('.bx-embed-link a[href="' + aData.link + '"]')[0]);
else
bx_embed_link();
});
});
},
Expand Down Expand Up @@ -55,7 +58,6 @@ function bx_editor_init(oEditor, oParams){
}

format(name, value) {
console.log('format'+name+"!"+value)
if (name === 'href' || name === 'title') {
if (value) {
this.domNode.setAttribute(name, value);
Expand All @@ -72,7 +74,6 @@ function bx_editor_init(oEditor, oParams){
};

static formats(node) {
console.log(node+"x");
let format = {};
if (node.hasAttribute('href')) {
format.href = node.getAttribute('href');
Expand Down Expand Up @@ -184,7 +185,6 @@ function bx_editor_init(oEditor, oParams){
})
.catch(error => {
reject("Upload failed");
console.error("Error:", error);
});
});
}
Expand Down
4 changes: 2 additions & 2 deletions inc/utils.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ function clear_xss($val)
{
// HTML Purifier plugin
global $oHtmlPurifier;
if (!isset($oHtmlPurifier) /*&& !$GLOBALS['logged']['admin']*/) {
if (!isset($oHtmlPurifier) && !$GLOBALS['logged']['admin']) {
HTMLPurifier_Bootstrap::registerAutoload();

$oConfig = HTMLPurifier_Config::createDefault();
Expand Down Expand Up @@ -628,7 +628,7 @@ function clear_xss($val)
$oHtmlPurifier = new HTMLPurifier($oConfig);
}

//if (!$GLOBALS['logged']['admin'])
if (!$GLOBALS['logged']['admin'])
$val = $oHtmlPurifier->purify($val);

bx_alert('system', 'clear_xss', 0, 0, array('oHtmlPurifier' => $oHtmlPurifier, 'return_data' => &$val));
Expand Down
1 change: 1 addition & 0 deletions modules/boonex/english/data/langs/system/en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@
<string name="_adm_dbd_txt_c_clear_css"><![CDATA[Clear CSS cache]]></string>
<string name="_adm_dbd_txt_c_less"><![CDATA[LESS]]></string>
<string name="_adm_dbd_txt_c_clear_less"><![CDATA[Clear LESS cache]]></string>
<string name="_adm_dbd_txt_c_clear_purifier"><![CDATA[Clear all Purifier cache]]></string>
<string name="_adm_dbd_txt_c_js"><![CDATA[JavaScript]]></string>
<string name="_adm_dbd_txt_c_clear_js"><![CDATA[Clear JavaScript cache]]></string>
<string name="_adm_dbd_txt_c_clear_custom"><![CDATA[Clear Custom cache]]></string>
Expand Down

0 comments on commit 03d5372

Please sign in to comment.