mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 07:53:49 +08:00
DEV: refactor composer-editor/d-editor, a little more (#29973)
Adds setupEditor to ComposerEditor so it can setup/destroy events when the underlying editorComponent is switched. Moves putCursorAtEnd uses (which implementation is textarea-specific) to TextareaTextManipulation. Moves insertCurrentTime and a corresponding test, which is discourse-local-dates specific, to the plugin. Moves applyList and formatCode from DEditor to the TextareaTextManipulation. Moves DEditor._applySurround to TextareaTextManipulation.applySurroundSelection Avoids resetting the textarea value on applyList and formatCode, keeping the undo history.
This commit is contained in:
@ -1,6 +1,9 @@
|
||||
import { click, fillIn, visit } from "@ember/test-helpers";
|
||||
import { click, fillIn, triggerKeyEvent, visit } from "@ember/test-helpers";
|
||||
import { test } from "qunit";
|
||||
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
||||
import {
|
||||
acceptance,
|
||||
metaModifier,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
|
||||
acceptance("Local Dates - composer", function (needs) {
|
||||
@ -128,4 +131,24 @@ acceptance("Local Dates - composer", function (needs) {
|
||||
await click("ul.formats a.moment-format");
|
||||
assert.dom("input.format-input").hasValue("LLL");
|
||||
});
|
||||
|
||||
test("composer insert current time shortcut", async function (assert) {
|
||||
await visit("/t/internationalization-localization/280");
|
||||
await click("#topic-footer-buttons .btn.create");
|
||||
await fillIn(".d-editor-input", "and the time now is: ");
|
||||
|
||||
await triggerKeyEvent(".d-editor-input", "keydown", ".", {
|
||||
...metaModifier,
|
||||
shiftKey: true,
|
||||
});
|
||||
|
||||
const date = moment().format("YYYY-MM-DD");
|
||||
|
||||
assert
|
||||
.dom("#reply-control .d-editor-input")
|
||||
.hasValue(
|
||||
new RegExp(`and the time now is: \\[date=${date}`),
|
||||
"it adds the current date"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user