Merge branch 'MDL-68548' of https://github.com/Neosi/moodle
authorAndrew Nicols <andrew@nicols.co.uk>
Wed, 6 May 2020 00:55:51 +0000 (08:55 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Wed, 6 May 2020 00:55:51 +0000 (08:55 +0800)
lib/editor/atto/plugins/italic/tests/behat/italic.feature
lib/editor/atto/plugins/italic/yui/build/moodle-atto_italic-button/moodle-atto_italic-button-debug.js
lib/editor/atto/plugins/italic/yui/build/moodle-atto_italic-button/moodle-atto_italic-button-min.js
lib/editor/atto/plugins/italic/yui/build/moodle-atto_italic-button/moodle-atto_italic-button.js
lib/editor/atto/plugins/italic/yui/src/button/js/button.js
lib/editor/atto/tests/behat/customtoolbar.feature
lib/editor/atto/tests/behat/disablecontrol.feature

index 6449ef5..b62b377 100644 (file)
@@ -15,7 +15,7 @@ Feature: Atto italic button
     And I set the field "Text editor" to "Plain text area"
     And I press "Save changes"
     And I click on "Edit profile" "link" in the "region-main" "region"
-    Then I should see "<i>Tower of Pisa</i>"
+    Then I should see "<em>Tower of Pisa</em>"
 
   @javascript
   Scenario: Toggle italics in some text
@@ -31,5 +31,5 @@ Feature: Atto italic button
     And I set the field "Text editor" to "Plain text area"
     And I press "Save changes"
     And I click on "Edit profile" "link" in the "region-main" "region"
-    Then I should not see "<i>GHD - for hair</i>"
+    Then I should not see "<em>GHD - for hair</em>"
     And I should see "GHD - for hair"
index dcba9e9..d316663 100644 (file)
Binary files a/lib/editor/atto/plugins/italic/yui/build/moodle-atto_italic-button/moodle-atto_italic-button-debug.js and b/lib/editor/atto/plugins/italic/yui/build/moodle-atto_italic-button/moodle-atto_italic-button-debug.js differ
index 6a64c70..52208d1 100644 (file)
Binary files a/lib/editor/atto/plugins/italic/yui/build/moodle-atto_italic-button/moodle-atto_italic-button-min.js and b/lib/editor/atto/plugins/italic/yui/build/moodle-atto_italic-button/moodle-atto_italic-button-min.js differ
index dcba9e9..d316663 100644 (file)
Binary files a/lib/editor/atto/plugins/italic/yui/build/moodle-atto_italic-button/moodle-atto_italic-button.js and b/lib/editor/atto/plugins/italic/yui/build/moodle-atto_italic-button/moodle-atto_italic-button.js differ
index 8823c30..fadc5e5 100644 (file)
 
 Y.namespace('M.atto_italic').Button = Y.Base.create('button', Y.M.editor_atto.EditorPlugin, [], {
     initializer: function() {
-        this.addBasicButton({
-            exec: 'italic',
+        var italic;
+
+        this.addButton({
+            callback: this._toggleItalic,
+            icon: 'e/italic',
+            buttonName: italic,
+            inlineFormat: true,
 
             // Key code for the keyboard shortcut which triggers this button:
             keys: '73',
 
             // Watch the following tags and add/remove highlighting as appropriate:
-            tags: 'i'
+            tags: 'em, i'
         });
+    },
+    /**
+     * Toggle the italic setting.
+     *
+     * @method _toggleItalic
+     * @param {EventFacade} e
+     */
+    _toggleItalic: function() {
+        var host = this.get('host');
+
+        // Use the "italic" command for simplicity. This will toggle <em> tags off as well.
+        document.execCommand('italic', false, null);
+
+        // Then change all <i> tags to <em> tags. This will change any existing <i> tags as well.
+        host.changeToCSS('i', 'bf-editor-italic-emphasis');
+        host.changeToTags('bf-editor-italic-emphasis', 'em');
     }
 });
index 02f5665..ec282c2 100644 (file)
@@ -21,6 +21,6 @@ Feature: Atto editor with customised toolbar
     Then ".atto_link_button" "css_element" should exist in the ".normaldiv" "css_element"
     And ".atto_link_button" "css_element" should not exist in the ".specialdiv" "css_element"
     And ".atto_bold_button" "css_element" should exist in the ".normaldiv" "css_element"
-    And ".atto_italic_button_italic" "css_element" should exist in the ".normaldiv" "css_element"
+    And ".atto_italic_button" "css_element" should exist in the ".normaldiv" "css_element"
     And ".atto_bold_button" "css_element" should exist in the ".specialdiv" "css_element"
-    And ".atto_italic_button_italic" "css_element" should exist in the ".specialdiv" "css_element"
+    And ".atto_italic_button" "css_element" should exist in the ".specialdiv" "css_element"
index a3a6590..4e1d16a 100644 (file)
@@ -22,7 +22,7 @@ Feature: Atto with enable/disable function.
     Then the "disabled" attribute of "button.atto_collapse_button" "css_element" should contain "disabled"
     And the "disabled" attribute of "button.atto_title_button" "css_element" should contain "disabled"
     And the "disabled" attribute of "button.atto_bold_button" "css_element" should contain "disabled"
-    And the "disabled" attribute of "button.atto_italic_button_italic" "css_element" should contain "disabled"
+    And the "disabled" attribute of "button.atto_italic_button" "css_element" should contain "disabled"
     And the "disabled" attribute of "button.atto_unorderedlist_button_insertUnorderedList" "css_element" should contain "disabled"
     And the "disabled" attribute of "button.atto_orderedlist_button_insertOrderedList" "css_element" should contain "disabled"
     And the "disabled" attribute of "button.atto_link_button" "css_element" should contain "disabled"
@@ -36,7 +36,7 @@ Feature: Atto with enable/disable function.
     Then "button.atto_collapse_button[disabled]" "css_element" should not exist
     And "button.atto_title_button[disabled]" "css_element" should not exist
     And "button.atto_bold_button[disabled]" "css_element" should not exist
-    And "button.atto_italic_button_italic[disabled]" "css_element" should not exist
+    And "button.atto_italic_button[disabled]" "css_element" should not exist
     And "button.atto_unorderedlist_button_insertUnorderedList[disabled]" "css_element" should not exist
     And "button.atto_orderedlist_button_insertOrderedList[disabled]" "css_element" should not exist
     And "button.atto_link_button[disabled]" "css_element" should not exist