Skip to content
Snippets Groups Projects
Commit b2218f5e authored by Marius Dumitru Florea's avatar Marius Dumitru Florea
Browse files

XWIKI-22220: Quick Actions doesn't insert macros inline even if they support inline mode

* Take into account the macro descriptor
* Move the caret at the start of the first nested editable when the selection is before a macro widget wrapper (after the content is refreshed).

(cherry picked from commit 8671be3b)
parent 16c52b17
No related branches found
No related tags found
No related merge requests found
......@@ -434,6 +434,12 @@
var insertParam = {
name: macro.id.id,
parameters: {},
// We consider the macro call to be inline if the macro supports inline mode, as indicated by
// its descriptor, because the caret is placed in an inline context most of the time (e.g.
// inside a paragraph) in order to allow the user to type text. Moreover, the
// 'xwiki-macro-maybe-install-insert' editor command is used mainly by quick actions which are
// triggered by the user typing text, so in an inline context.
inline: descriptor.supportsInlineMode
};
// Set an empty default content when it is mandatory.
......
......@@ -654,7 +654,9 @@
name: 'xwiki-macro-insert',
data: {
name: 'info',
content: editor.localization.get('xwiki-slash.action.info.defaultContent')
content: editor.localization.get('xwiki-slash.action.info.defaultContent'),
// We know this macro can be called inline.
inline: true
}
}
}, {
......@@ -667,7 +669,9 @@
name: 'xwiki-macro-insert',
data: {
name: 'success',
content: editor.localization.get('xwiki-slash.action.success.defaultContent')
content: editor.localization.get('xwiki-slash.action.success.defaultContent'),
// We know this macro can be called inline.
inline: true
}
}
}, {
......@@ -680,7 +684,9 @@
name: 'xwiki-macro-insert',
data: {
name: 'warning',
content: editor.localization.get('xwiki-slash.action.warning.defaultContent')
content: editor.localization.get('xwiki-slash.action.warning.defaultContent'),
// We know this macro can be called inline.
inline: true
}
}
}, {
......@@ -693,7 +699,9 @@
name: 'xwiki-macro-insert',
data: {
name: 'error',
content: editor.localization.get('xwiki-slash.action.error.defaultContent')
content: editor.localization.get('xwiki-slash.action.error.defaultContent'),
// We know this macro can be called inline.
inline: true
}
}
}, {
......
......@@ -59,7 +59,7 @@
},
resolveExtraJARs = true
)
public class QuickActionsIT extends AbstractCKEditorIT
class QuickActionsIT extends AbstractCKEditorIT
{
/**
* Test string that will be inserted to check formatting.
......@@ -92,7 +92,7 @@ void afterEach(TestUtils setup, TestReference testReference)
@Test
@Order(1)
void heading1AndParagraph() throws Exception
void heading1AndParagraph()
{
// Switch to another style
textArea.sendKeys("/hea");
......@@ -121,7 +121,7 @@ void heading1AndParagraph() throws Exception
@Test
@Order(2)
void heading2() throws Exception
void heading2()
{
textArea.sendKeys("/hea");
AutocompleteDropdown qa = new AutocompleteDropdown();
......@@ -139,7 +139,7 @@ void heading2() throws Exception
@Test
@Order(3)
void heading3() throws Exception
void heading3()
{
textArea.sendKeys("/hea");
AutocompleteDropdown qa = new AutocompleteDropdown();
......@@ -157,7 +157,7 @@ void heading3() throws Exception
@Test
@Order(4)
void heading4() throws Exception
void heading4()
{
textArea.sendKeys("/hea");
AutocompleteDropdown qa = new AutocompleteDropdown();
......@@ -175,7 +175,7 @@ void heading4() throws Exception
@Test
@Order(5)
void heading5() throws Exception
void heading5()
{
textArea.sendKeys("/hea");
AutocompleteDropdown qa = new AutocompleteDropdown();
......@@ -193,7 +193,7 @@ void heading5() throws Exception
@Test
@Order(6)
void heading6() throws Exception
void heading6()
{
textArea.sendKeys("/hea");
AutocompleteDropdown qa = new AutocompleteDropdown();
......@@ -211,7 +211,7 @@ void heading6() throws Exception
@Test
@Order(7)
void bulletedList() throws Exception
void bulletedList()
{
textArea.sendKeys("/bu");
AutocompleteDropdown qa = new AutocompleteDropdown();
......@@ -227,7 +227,7 @@ void bulletedList() throws Exception
@Test
@Order(8)
void numberedList() throws Exception
void numberedList()
{
textArea.sendKeys("/nu");
AutocompleteDropdown qa = new AutocompleteDropdown();
......@@ -243,7 +243,7 @@ void numberedList() throws Exception
@Test
@Order(9)
void table() throws Exception
void table()
{
textArea.sendKeys("/tab");
AutocompleteDropdown qa = new AutocompleteDropdown();
......@@ -262,7 +262,7 @@ void table() throws Exception
@Test
@Order(10)
void blockQuote() throws Exception
void blockQuote()
{
textArea.sendKeys("/quo");
AutocompleteDropdown qa = new AutocompleteDropdown();
......@@ -278,7 +278,7 @@ void blockQuote() throws Exception
@Test
@Order(11)
void infoBox() throws Exception
void infoBox()
{
textArea.sendKeys("/inf");
AutocompleteDropdown qa = new AutocompleteDropdown();
......@@ -291,12 +291,12 @@ void infoBox() throws Exception
textArea.sendKeys(Keys.chord(Keys.SHIFT, Keys.END), Keys.BACK_SPACE);
textArea.sendKeys("my info message");
assertSourceEquals("{{info}}\nmy info message\n{{/info}}\n\n ");
assertSourceEquals("{{info}}\nmy info message\n{{/info}}");
}
@Test
@Order(12)
void successBox() throws Exception
void successBox()
{
textArea.sendKeys("/suc");
AutocompleteDropdown qa = new AutocompleteDropdown();
......@@ -309,12 +309,12 @@ void successBox() throws Exception
textArea.sendKeys(Keys.chord(Keys.SHIFT, Keys.END), Keys.BACK_SPACE);
textArea.sendKeys("my success message");
assertSourceEquals("{{success}}\nmy success message\n{{/success}}\n\n ");
assertSourceEquals("{{success}}\nmy success message\n{{/success}}");
}
@Test
@Order(13)
void warningBox() throws Exception
void warningBox()
{
textArea.sendKeys("/war");
AutocompleteDropdown qa = new AutocompleteDropdown();
......@@ -327,12 +327,12 @@ void warningBox() throws Exception
textArea.sendKeys(Keys.chord(Keys.SHIFT, Keys.END), Keys.BACK_SPACE);
textArea.sendKeys("my warning message");
assertSourceEquals("{{warning}}\nmy warning message\n{{/warning}}\n\n ");
assertSourceEquals("{{warning}}\nmy warning message\n{{/warning}}");
}
@Test
@Order(14)
void errorBox() throws Exception
void errorBox()
{
textArea.sendKeys("/err");
AutocompleteDropdown qa = new AutocompleteDropdown();
......@@ -345,12 +345,12 @@ void errorBox() throws Exception
textArea.sendKeys(Keys.chord(Keys.SHIFT, Keys.END), Keys.BACK_SPACE);
textArea.sendKeys("my error message");
assertSourceEquals("{{error}}\nmy error message\n{{/error}}\n\n ");
assertSourceEquals("{{error}}\nmy error message\n{{/error}}");
}
@Test
@Order(15)
void divider() throws Exception
void divider()
{
textArea.sendKeys("/div");
AutocompleteDropdown qa = new AutocompleteDropdown();
......@@ -363,7 +363,7 @@ void divider() throws Exception
@Test
@Order(16)
void link() throws Exception
void link()
{
textArea.sendKeys("/lin");
AutocompleteDropdown qa = new AutocompleteDropdown();
......@@ -382,7 +382,7 @@ void link() throws Exception
@Test
@Order(17)
void image() throws Exception
void image()
{
textArea.sendKeys("/im");
AutocompleteDropdown qa = new AutocompleteDropdown();
......@@ -396,7 +396,7 @@ void image() throws Exception
@Test
@Order(18)
void mention() throws Exception
void mention()
{
textArea.sendKeys("/men");
AutocompleteDropdown qa = new AutocompleteDropdown();
......@@ -418,7 +418,7 @@ void mention() throws Exception
@Test
@Order(19)
void emoji() throws Exception
void emoji()
{
textArea.sendKeys("/emo");
AutocompleteDropdown qa = new AutocompleteDropdown();
......@@ -435,7 +435,7 @@ void emoji() throws Exception
@Test
@Order(20)
void include() throws Exception
void include()
{
textArea.sendKeys("/inc");
AutocompleteDropdown qa = new AutocompleteDropdown();
......@@ -453,7 +453,7 @@ void include() throws Exception
@Test
@Order(21)
void code() throws Exception
void code()
{
textArea.sendKeys("/cod");
AutocompleteDropdown qa = new AutocompleteDropdown();
......@@ -471,7 +471,7 @@ void code() throws Exception
@Test
@Order(22)
void toc() throws Exception
void toc()
{
textArea.sendKeys("/toc");
AutocompleteDropdown qa = new AutocompleteDropdown();
......@@ -486,7 +486,7 @@ void toc() throws Exception
@Test
@Order(23)
void find() throws Exception
void find()
{
textArea.sendKeys("/fin");
AutocompleteDropdown qa = new AutocompleteDropdown();
......@@ -500,7 +500,7 @@ void find() throws Exception
@Test
@Order(24)
void emojiClickTriggersDropDown(TestUtils setup) throws Exception
void emojiClickTriggersDropDown(TestUtils setup)
{
textArea.sendKeys("/emo");
AutocompleteDropdown qa = new AutocompleteDropdown();
......@@ -523,7 +523,7 @@ void emojiClickTriggersDropDown(TestUtils setup) throws Exception
@Test
@Order(25)
void icon() throws Exception
void icon()
{
textArea.sendKeys("/icon");
AutocompleteDropdown qa = new AutocompleteDropdown();
......@@ -542,4 +542,46 @@ void icon() throws Exception
assertSourceEquals("{{displayIcon name=\"wiki\"/}} ");
}
@Test
@Order(26)
void infoBoxInline()
{
// Type some text in a paragraph.
textArea.sendKeys("before after");
// Place the caret between the typed words.
textArea.sendKeys(Keys.chord(Keys.CONTROL, Keys.LEFT, Keys.LEFT, Keys.RIGHT));
textArea.sendKeys(" /inf");
AutocompleteDropdown qa = new AutocompleteDropdown();
qa.waitForItemSelected("/inf", "Info Box");
textArea.sendKeys(Keys.ENTER);
qa.waitForItemSubmitted();
// The content is reloaded after a macro is inserted.
textArea = editor.getRichTextArea();
// Note that we didn't modify the default info message because inline macros are not editable in-place.
assertSourceEquals("before {{info}}Type your information message here.{{/info}} after");
}
@Test
@Order(27)
void velocityInline()
{
// Type some text in a paragraph.
textArea.sendKeys("one two");
// Place the caret between the typed words.
textArea.sendKeys(Keys.chord(Keys.CONTROL, Keys.LEFT, Keys.LEFT, Keys.RIGHT));
textArea.sendKeys(" /velo");
AutocompleteDropdown qa = new AutocompleteDropdown();
qa.waitForItemSelected("/velo", "Velocity");
textArea.sendKeys(Keys.ENTER);
qa.waitForItemSubmitted();
// The content is reloaded after a macro is inserted.
textArea = editor.getRichTextArea();
// Note that we didn't modify the default info message because inline macros are not editable in-place.
assertSourceEquals("one {{velocity}} {{/velocity}} two");
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment