Skip to content

Commit c41591d

Browse files
hieuvuAnupamaSarjoshi
authored andcommitted
Update CI and document, increase version.
1 parent 4249517 commit c41591d

File tree

5 files changed

+50
-6
lines changed

5 files changed

+50
-6
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@ jobs:
1414
moodle-branch: 'main'
1515
database: 'pgsql'
1616
- php: '8.3'
17-
moodle-branch: 'MOODLE_405_STABLE'
17+
moodle-branch: 'MOODLE_500_STABLE'
1818
database: 'mariadb'
1919
- php: '8.2'
20-
moodle-branch: 'MOODLE_404_STABLE'
20+
moodle-branch: 'MOODLE_405_STABLE'
2121
database: 'pgsql'
22+
- php: '8.2'
23+
moodle-branch: 'MOODLE_404_STABLE'
24+
database: 'mariadb'
2225

2326
services:
2427
postgres:

changes.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Change log for the superscript-subscript editor
22

33
## Change in 1.3
4-
* Updated rangy lib to work with Moodle 4.2+.
4+
5+
- Update behat to work with Moodle 5.0+.
6+
57

68
## Changes in 1.2
79

tests/behat/behat_editor_ousupsub.php

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ public function i_am_on_standalone_test_page() {
5454
$this->getSession()->visit($this->locate_path('/lib/editor/ousupsub/standalone/index.html'));
5555
}
5656

57+
/**
58+
* Select the text in an ousupsub field.
59+
*
60+
* @Given /^I select the text in the "([^"]*)" ousupsub editor$/
61+
* @throws ElementNotFoundException Thrown by behat_base::find
62+
* @param string $fieldlocator
63+
* @return void
64+
*/
5765
/**
5866
* Select the text in an ousupsub field.
5967
*
@@ -73,7 +81,36 @@ public function select_the_text_in_the_ousupsub_editor($fieldlocator) {
7381
if (!method_exists($field, 'select_text')) {
7482
throw new coding_exception('Field does not support the select_text function.');
7583
}
76-
$field->select_text();
84+
$editorid = $field->get_attribute('id');
85+
// Inject and run JavaScript to select the text content.
86+
$js = ' (function() {
87+
var e = document.getElementById("' . $editorid . 'editable");
88+
89+
if (!e) {
90+
console.error("Editable element not found with ID: ' . $editorid . 'editable");
91+
return;
92+
}
93+
94+
var node = e;
95+
while (node.firstChild && node.firstChild.nodeType !== Node.TEXT_NODE) {
96+
node = node.firstChild;
97+
}
98+
99+
var range = document.createRange();
100+
var selection = window.getSelection();
101+
102+
if (node && node.nodeType === Node.TEXT_NODE) {
103+
range.selectNodeContents(node);
104+
} else {
105+
range.selectNodeContents(e);
106+
}
107+
108+
selection.removeAllRanges();
109+
selection.addRange(range);
110+
e.focus();
111+
}()); ';
112+
113+
behat_base::execute_script_in_session($field->getSession(), $js);
77114
}
78115

79116
/**

tests/fixtures/editortestpage.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@
6363
echo html_writer::tag('h2', 'ATTO Editor');
6464
echo html_writer::label('ATTO Input', 'attoeditor');
6565
echo html_writer::tag('textarea', '', ['name' => 'attoeditor', 'id' => 'attoeditor', 'rows' => 2, 'cols' => 20]);
66-
$attoeditor->use_editor('attoeditor', ['supsub' => $type]);
66+
if ($attoeditor) {
67+
$attoeditor->use_editor('attoeditor', ['supsub' => $type]);
68+
}
6769
$submitoptions['id'] = 'submitattoeditor';
6870
echo html_writer::tag('input', '', $submitoptions);
6971
echo $OUTPUT->footer();

version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828
$plugin->requires = 2020061500;
2929
$plugin->component = 'editor_ousupsub';
3030
$plugin->maturity = MATURITY_STABLE;
31-
$plugin->release = '1.2 for Moodle 3.9+';
31+
$plugin->release = '1.3 for Moodle 5.0+';
3232

3333
$plugin->outestssufficient = true;

0 commit comments

Comments
 (0)