mirror of
https://github.com/zulip/zulip.git
synced 2026-07-03 21:10:12 +08:00
compose: Format button for strikethrough.
This commit is contained in:
parent
4ccbde23cc
commit
63e5e05643
@ -677,6 +677,11 @@ export function format_text($textarea, type, inserted_content) {
|
||||
case "numbered":
|
||||
format_list(type);
|
||||
break;
|
||||
case "strikethrough": {
|
||||
const strikethrough_syntax = "~~";
|
||||
format(strikethrough_syntax);
|
||||
break;
|
||||
}
|
||||
case "link": {
|
||||
// Ctrl + L: Insert a link to selected text
|
||||
wrapSelection(field, "[", "](url)");
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
<a role="button" data-format-type="link" class="compose_control_button fa fa-link formatting_button" aria-label="{{t 'Link' }}" {{#unless preview_mode_on}} tabindex=0 {{/unless}} data-tippy-content="{{t 'Link' }}"></a>
|
||||
<a role="button" data-format-type="bold" class="compose_control_button fa fa-bold formatting_button" aria-label="{{t 'Bold' }}" {{#unless preview_mode_on}} tabindex=0 {{/unless}} data-tippy-content="{{t 'Bold' }}"></a>
|
||||
<a role="button" data-format-type="italic" class="compose_control_button fa fa-italic formatting_button" aria-label="{{t 'Italic' }}" {{#unless preview_mode_on}} tabindex=0 {{/unless}} data-tippy-content="{{t 'Italic' }}"></a>
|
||||
<a role="button" data-format-type="strikethrough" class="compose_control_button fa fa-strikethrough formatting_button" aria-label="{{t 'Strikethrough' }}" {{#unless preview_mode_on}} tabindex=0 {{/unless}} data-tippy-content="{{t 'Strikethrough' }}"></a>
|
||||
<div class="divider">|</div>
|
||||
<a role="button" data-format-type="numbered" class="compose_control_button fa fa-list-ol formatting_button" aria-label="{{t 'Numbered list' }}" {{#unless preview_mode_on}} tabindex=0 {{/unless}} data-tippy-content="{{t 'Numbered list' }}"></a>
|
||||
<a role="button" data-format-type="bulleted" class="compose_control_button fa fa-list-ul formatting_button" aria-label="{{t 'Bulleted list' }}" {{#unless preview_mode_on}} tabindex=0 {{/unless}} data-tippy-content="{{t 'Bulleted list' }}"></a>
|
||||
|
||||
@ -766,6 +766,50 @@ run_test("format_text - bold and italic", ({override}) => {
|
||||
assert.equal(wrap_selection_called, false);
|
||||
});
|
||||
|
||||
run_test("format_text - strikethrough", ({override}) => {
|
||||
override(text_field_edit, "set", (_field, text) => {
|
||||
set_text = text;
|
||||
});
|
||||
override(text_field_edit, "wrapSelection", (_field, syntax_start, syntax_end) => {
|
||||
wrap_selection_called = true;
|
||||
wrap_syntax_start = syntax_start;
|
||||
wrap_syntax_end = syntax_end;
|
||||
});
|
||||
|
||||
const strikethrough_syntax = "~~";
|
||||
|
||||
// Strikethrough selected text
|
||||
reset_state();
|
||||
compose_ui.format_text($textarea, "strikethrough");
|
||||
assert.equal(set_text, "");
|
||||
assert.equal(wrap_selection_called, true);
|
||||
assert.equal(wrap_syntax_start, strikethrough_syntax);
|
||||
assert.equal(wrap_syntax_end, strikethrough_syntax);
|
||||
|
||||
// Undo strikethrough selected text, syntax not selected
|
||||
reset_state();
|
||||
init_textarea("~~abc~~", {
|
||||
start: 2,
|
||||
end: 5,
|
||||
text: "abc",
|
||||
length: 3,
|
||||
});
|
||||
compose_ui.format_text($textarea, "strikethrough");
|
||||
assert.equal(set_text, "abc");
|
||||
assert.equal(wrap_selection_called, false);
|
||||
|
||||
// Undo strikethrough selected text, syntax selected
|
||||
reset_state();
|
||||
init_textarea("~~abc~~", {
|
||||
start: 0,
|
||||
end: 7,
|
||||
text: "~~abc~~",
|
||||
length: 7,
|
||||
});
|
||||
compose_ui.format_text($textarea, "strikethrough");
|
||||
assert.equal(set_text, "abc");
|
||||
});
|
||||
|
||||
run_test("markdown_shortcuts", ({override_rewire}) => {
|
||||
let format_text_type;
|
||||
override_rewire(compose_ui, "format_text", (_$textarea, type) => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user