Skip to content

Commit

Permalink
Use admin URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
franck-paul committed Jun 19, 2023
1 parent afb5cfc commit 4262772
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 58 deletions.
2 changes: 1 addition & 1 deletion _define.php
Expand Up @@ -15,7 +15,7 @@
'YASH',
'Yet Another Syntax Highlighter',
'Pep and contributors',
'3.1',
'3.2',
[
'requires' => [['core', '2.26']],
'permissions' => dcCore::app()->auth->makePermissions([
Expand Down
114 changes: 59 additions & 55 deletions js/post.js
@@ -1,61 +1,65 @@
/*global jsToolBar, dotclear */
/*global $, jQuery, jsToolBar, dotclear */
'use strict';

jsToolBar.prototype.elements.yashSpace = {
type: 'space',
format: {
wysiwyg: true,
wiki: true,
xhtml: true,
markdown: true,
},
};
$(() => {
const data = dotclear.getData('dc_editor_yash');

jsToolBar.prototype.elements.yash = {
type: 'button',
title: dotclear.getData('dc_editor_yash').title || 'Highlighted Code',
context: 'post',
icon: 'index.php?pf=yash/icon.svg',
shortkey: 'KeyY',
shortkey_name: 'Y',
fn: {},
fncall: {},
open_url: 'plugin.php?p=yash&popup=1',
data: {},
popup() {
window.the_toolbar = this;
this.elements.yash.data = {};
jsToolBar.prototype.elements.yashSpace = {
type: 'space',
format: {
wysiwyg: true,
wiki: true,
xhtml: true,
markdown: true,
},
};

window.open(
this.elements.yash.open_url,
'dc_popup',
'alwaysRaised=yes,dependent=yes,toolbar=yes,height=240,width=480,menubar=no,resizable=yes,scrollbars=yes,status=no',
);
},
};
jsToolBar.prototype.elements.yash = {
type: 'button',
title: data.title || 'Highlighted Code',
context: 'post',
icon: data.icon,
shortkey: 'KeyY',
shortkey_name: 'Y',
fn: {},
fncall: {},
open_url: data.open_url,
data: {},
popup() {
window.the_toolbar = this;
this.elements.yash.data = {};

jsToolBar.prototype.elements.yash.fn.wiki = function () {
this.elements.yash.popup.call(this);
};
jsToolBar.prototype.elements.yash.fn.xhtml = function () {
this.elements.yash.popup.call(this);
};
jsToolBar.prototype.elements.yash.fn.markdown = function () {
this.elements.yash.popup.call(this);
};
window.open(
this.elements.yash.open_url,
'dc_popup',
'alwaysRaised=yes,dependent=yes,toolbar=yes,height=240,width=480,menubar=no,resizable=yes,scrollbars=yes,status=no',
);
},
};

jsToolBar.prototype.elements.yash.fncall.wiki = function () {
const stag = `\n///yash ${this.elements.yash.data.syntax}\n`;
const etag = '\n///\n';
this.encloseSelection(stag, etag);
};
jsToolBar.prototype.elements.yash.fncall.xhtml = function () {
const stag = `<pre class="brush: ${this.elements.yash.data.syntax}">\n`;
const etag = '\n</pre>\n';
this.encloseSelection(stag, etag);
};
jsToolBar.prototype.elements.yash.fncall.markdown = function () {
const stag = `<pre class="brush: ${this.elements.yash.data.syntax}">\n`;
const etag = '\n</pre>\n';
this.encloseSelection(stag, etag);
};
jsToolBar.prototype.elements.yash.fn.wiki = function () {
this.elements.yash.popup.call(this);
};
jsToolBar.prototype.elements.yash.fn.xhtml = function () {
this.elements.yash.popup.call(this);
};
jsToolBar.prototype.elements.yash.fn.markdown = function () {
this.elements.yash.popup.call(this);
};

jsToolBar.prototype.elements.yash.fncall.wiki = function () {
const stag = `\n///yash ${this.elements.yash.data.syntax}\n`;
const etag = '\n///\n';
this.encloseSelection(stag, etag);
};
jsToolBar.prototype.elements.yash.fncall.xhtml = function () {
const stag = `<pre class="brush: ${this.elements.yash.data.syntax}">\n`;
const etag = '\n</pre>\n';
this.encloseSelection(stag, etag);
};
jsToolBar.prototype.elements.yash.fncall.markdown = function () {
const stag = `<pre class="brush: ${this.elements.yash.data.syntax}">\n`;
const etag = '\n</pre>\n';
this.encloseSelection(stag, etag);
};
});
2 changes: 1 addition & 1 deletion js/post.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/BackendBehaviors.php
Expand Up @@ -26,7 +26,11 @@ public static function adminPostEditor($editor = ''): string
}

return
dcPage::jsJson('dc_editor_yash', ['title' => __('Highlighted Code')]) .
dcPage::jsJson('dc_editor_yash', [
'title' => __('Highlighted Code'),
'icon' => urldecode(dcPage::getPF(My::id() . '/icon.svg')),
'open_url' => urldecode(My::makeUrl(['popup' => 1])),
]) .
dcPage::jsModuleLoad(My::id() . '/js/post.js', dcCore::app()->getVersion(My::id()));
}
}

0 comments on commit 4262772

Please sign in to comment.