Skip to content
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

Wip800212 #5

Merged
merged 6 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions amd/build/editor.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions amd/build/editor.min.js.map

Large diffs are not rendered by default.

993 changes: 993 additions & 0 deletions amd/src/editor.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions lang/en/editor_ousupsub.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

$string['button_sub_title'] = 'Subscript [Shift + _ or Down arrow]';
$string['button_sup_title'] = 'Superscript [Shift + ^ or Up arrow]';
$string['editor_command_keycode'] = 'Cmd + {$a}';
$string['editor_control_keycode'] = 'Ctrl + {$a}';
$string['editor_shift_keycode'] = 'Shift + {$a}';
Expand Down
38 changes: 17 additions & 21 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function supports_repositories() {
* @param null $fpoptions
*/
public function use_editor($elementid, array $options = null, $fpoptions = null) {
global $PAGE;
global $PAGE, $OUTPUT;

if (empty($options['context'])) {
$options['context'] = context_system::instance();
Expand Down Expand Up @@ -106,27 +106,23 @@ public function use_editor($elementid, array $options = null, $fpoptions = null)
foreach ($groups['style1'] as $plugin) {
$groupplugins[] = array('name' => $plugin, 'params' => array());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We aren't using $groupplugins and $group. We can clean up some unnecessary code from line 87 to 108, though we might want to throw the exception when $options['supsub'] is invalid?

$jsplugins = array(array('group' => 'style1', 'plugins' => $groupplugins));

$PAGE->requires->strings_for_js(array(
'editor_command_keycode',
'editor_control_keycode',
'editor_shift_keycode',
'plugin_title_shortcut',
'subscript',
'superscript',
'redo',
'undo'
), 'editor_ousupsub');
$PAGE->requires->strings_for_js(array(
'warning',
'info'
), 'moodle');

$PAGE->requires->yui_module(array('moodle-editor_ousupsub-editor'),
'Y.M.editor_ousupsub.createEditor',
array($this->get_init_params($elementid, $options, $fpoptions, $jsplugins)));

$PAGE->requires->js_call_amd('editor_ousupsub/editor', 'loadEditor', [
[
'element' => $elementid,
'type' => $options['supsub'],
'buttons' => [
'superscript' => [
'icon' => $OUTPUT->pix_icon('e/superscript', '', 'core'),
'title' => get_string('button_sup_title', 'editor_ousupsub'),
],
'subscript' => [
'icon' => $OUTPUT->pix_icon('e/subscript', '', 'core'),
'title' => get_string('button_sub_title', 'editor_ousupsub'),
]
]
]
]);
}

/**
Expand Down
21 changes: 21 additions & 0 deletions pix/subscript.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions pix/superscript.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 9 additions & 3 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,23 @@ div.editor_ousupsub_toolbar button[disabled] {
cursor: default;
}

.editor_ousupsub_toolbar button:hover {
.editor_ousupsub .editor_ousupsub_toolbar button:hover {
background-image: radial-gradient(ellipse at center, #fff 60%, #d2691e 100%);
background-color: #ebebeb;
outline: none;
}

.editor_ousupsub_toolbar button:active,
.editor_ousupsub_toolbar button.highlight {
.editor_ousupsub .editor_ousupsub_toolbar button:active,
.editor_ousupsub .editor_ousupsub_toolbar button.highlight {
background-image: radial-gradient(ellipse at center, #fff 40%, #d2691e 100%);
background-color: #dfdfdf;
}

.editor_ousupsub .editor_ousupsub_toolbar button:focus {
background-image: unset;
background-color: #002158;
}

/* Make firefox button sizes match other browsers */
div.editor_ousupsub_toolbar button::-moz-focus-inner {
border: 0;
Expand Down