This commit is contained in:
Andrew Nicols 2020-05-05 11:48:46 +08:00
commit 561fc87034
5 changed files with 80 additions and 11 deletions

View File

@ -16,4 +16,4 @@ Feature: Atto strike 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 "<strike>MUA</strike>"
Then I should see "<del>MUA</del>"

View File

@ -35,13 +35,36 @@ YUI.add('moodle-atto_strike-button', function (Y, NAME) {
Y.namespace('M.atto_strike').Button = Y.Base.create('button', Y.M.editor_atto.EditorPlugin, [], {
initializer: function() {
this.addBasicButton({
exec: 'strikeThrough',
var strike;
this.addButton({
callback: this._toggleStrike,
icon: 'e/strikethrough',
buttonName: strike,
inlineFormat: true,
// Watch the following tags and add/remove highlighting as appropriate:
tags: 'strike'
tags: 'del, strike'
});
this._strikeApplier = window.rangy.createClassApplier("bf-editor-strike-del");
},
/**
* Toggle the strikethrough setting.
*
* @method _toggleStrike
*/
_toggleStrike: function() {
var host = this.get('host');
// Change all <del> and <strike> tags to applier class.
host.changeToCSS('del', 'bf-editor-strike-del');
host.changeToCSS('strike', 'bf-editor-strike-del');
// Use the applier toggle selection.
this._strikeApplier.toggleSelection();
// Then change the applier class back to <del> tags.
host.changeToTags('bf-editor-strike-del', 'del');
}
});

View File

@ -1 +1 @@
YUI.add("moodle-atto_strike-button",function(e,t){e.namespace("M.atto_strike").Button=e.Base.create("button",e.M.editor_atto.EditorPlugin,[],{initializer:function(){this.addBasicButton({exec:"strikeThrough",icon:"e/strikethrough",tags:"strike"})}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]});
YUI.add("moodle-atto_strike-button",function(e,t){e.namespace("M.atto_strike").Button=e.Base.create("button",e.M.editor_atto.EditorPlugin,[],{initializer:function(){var e;this.addButton({callback:this._toggleStrike,icon:"e/strikethrough",buttonName:e,inlineFormat:!0,tags:"del, strike"}),this._strikeApplier=window.rangy.createClassApplier("bf-editor-strike-del")},_toggleStrike:function(){var e=this.get("host");e.changeToCSS("del","bf-editor-strike-del"),e.changeToCSS("strike","bf-editor-strike-del"),this._strikeApplier.toggleSelection(),e.changeToTags("bf-editor-strike-del","del")}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]});

View File

@ -35,13 +35,36 @@ YUI.add('moodle-atto_strike-button', function (Y, NAME) {
Y.namespace('M.atto_strike').Button = Y.Base.create('button', Y.M.editor_atto.EditorPlugin, [], {
initializer: function() {
this.addBasicButton({
exec: 'strikeThrough',
var strike;
this.addButton({
callback: this._toggleStrike,
icon: 'e/strikethrough',
buttonName: strike,
inlineFormat: true,
// Watch the following tags and add/remove highlighting as appropriate:
tags: 'strike'
tags: 'del, strike'
});
this._strikeApplier = window.rangy.createClassApplier("bf-editor-strike-del");
},
/**
* Toggle the strikethrough setting.
*
* @method _toggleStrike
*/
_toggleStrike: function() {
var host = this.get('host');
// Change all <del> and <strike> tags to applier class.
host.changeToCSS('del', 'bf-editor-strike-del');
host.changeToCSS('strike', 'bf-editor-strike-del');
// Use the applier toggle selection.
this._strikeApplier.toggleSelection();
// Then change the applier class back to <del> tags.
host.changeToTags('bf-editor-strike-del', 'del');
}
});

View File

@ -33,12 +33,35 @@
Y.namespace('M.atto_strike').Button = Y.Base.create('button', Y.M.editor_atto.EditorPlugin, [], {
initializer: function() {
this.addBasicButton({
exec: 'strikeThrough',
var strike;
this.addButton({
callback: this._toggleStrike,
icon: 'e/strikethrough',
buttonName: strike,
inlineFormat: true,
// Watch the following tags and add/remove highlighting as appropriate:
tags: 'strike'
tags: 'del, strike'
});
this._strikeApplier = window.rangy.createClassApplier("bf-editor-strike-del");
},
/**
* Toggle the strikethrough setting.
*
* @method _toggleStrike
*/
_toggleStrike: function() {
var host = this.get('host');
// Change all <del> and <strike> tags to applier class.
host.changeToCSS('del', 'bf-editor-strike-del');
host.changeToCSS('strike', 'bf-editor-strike-del');
// Use the applier toggle selection.
this._strikeApplier.toggleSelection();
// Then change the applier class back to <del> tags.
host.changeToTags('bf-editor-strike-del', 'del');
}
});