summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Sotoudeh <masotoudeh@ucdavis.edu>2020-09-03 15:09:16 -0700
committerGitHub <noreply@github.com>2020-09-03 15:09:16 -0700
commit0f54f5a46c5883afcb0b5bb9d4eafc44449098be (patch)
treececfe97df202a95a934e19a2b110fa027a6b9f55
parente8ffe5e7bb1a9983a39eac21389867dd1aa0cbfe (diff)
parentfd1ff4b4d6517dab0936c64556ca3823ba573f78 (diff)
Merge pull request #4 from matthewsot/matthew-add-link
Added docs.insertLink(target, text)
-rw-r--r--docs.js9
-rw-r--r--test.js4
2 files changed, 13 insertions, 0 deletions
diff --git a/docs.js b/docs.js
index b59b72e..052ab41 100644
--- a/docs.js
+++ b/docs.js
@@ -161,6 +161,15 @@ docs.toggleBold = function () {
docs.pressKey(66, true, false);
};
+// Inserts a link with the given text.
+docs.insertLink = function (target, text) {
+ docs.pressButton($("[aria-label='Insert link (Ctrl+K)']")[0]);
+ $("[aria-label='Paste a link, or search']")[0].value = target;
+ $(".docs-link-insertlinkbubble-text.jfk-textinput.label-input-label")[0].value = text;
+ $("[aria-label='Paste a link, or search']")[0].dispatchEvent(new CustomEvent("input"));
+ docs.pressButton($(".docs-link-insertlinkbubble-buttonbar > div")[0]);
+};
+
/*********** MENU OPTIONS ***********/
docs.undo = function () {
docs.pressButton($("[aria-label='Undo u']")[0]);
diff --git a/test.js b/test.js
index c5e234c..d3e19b0 100644
--- a/test.js
+++ b/test.js
@@ -60,6 +60,10 @@ docs.keydown = async function (e) {
docs.pasteText("Back to normal.\n");
await sleep(500);
+ docs.insertLink("https://example.com/", "This should be a link to https://example.com/");
+ docs.pasteText("Back to normal.\n");
+ await sleep(500);
+
docs.pasteText("A few tests require user input:\n" +
"1) Select something (or not) and press alt+s to " +
"check the selection methods.\n" +
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback