Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rich text editor | Enable input rules for specific formatting options #1549

Merged
merged 21 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f5d1b11
Disabled input rules for bold italics in Tiptap
vivinkrishna-ni Sep 19, 2023
7cd2817
Change files
vivinkrishna-ni Sep 19, 2023
18ccf8b
Fix lint error
vivinkrishna-ni Sep 19, 2023
7ad6b4d
Updated test cases for formatting options
vivinkrishna-ni Sep 19, 2023
0712320
Updated change file description
vivinkrishna-ni Sep 19, 2023
67f7022
Updated the test cases
vivinkrishna-ni Sep 20, 2023
72fd6ec
Merge branch 'main' into users/vivin/disable-input-rules-for-marks
vivinkrishna-ni Sep 20, 2023
773194e
Updated test case name
vivinkrishna-ni Sep 20, 2023
c626147
Merge branch 'users/vivin/disable-input-rules-for-marks' of https://g…
vivinkrishna-ni Sep 20, 2023
66fe9c3
Merge branch 'main' into users/vivin/disable-input-rules-for-marks
vivinkrishna-ni Sep 20, 2023
d14793c
Resolve PR comments
vivinkrishna-ni Sep 20, 2023
841fe66
Merge branch 'users/vivin/disable-input-rules-for-marks' of https://g…
vivinkrishna-ni Sep 20, 2023
66fb153
Merge branch 'main' into users/vivin/disable-input-rules-for-marks
vivinkrishna-ni Sep 20, 2023
17a03eb
Fix lint error
vivinkrishna-ni Sep 20, 2023
8538bf4
Merge branch 'users/vivin/disable-input-rules-for-marks' of https://g…
vivinkrishna-ni Sep 20, 2023
5d6e444
Updated the comment in the code
vivinkrishna-ni Sep 20, 2023
3ee4a3a
Updated the paste event pageobject method to work in firefox
vivinkrishna-ni Sep 20, 2023
db70735
Merge branch 'users/vivin/disable-input-rules-for-marks' of https://g…
vivinkrishna-ni Sep 20, 2023
f95b2e3
Updated the test cases to parameterizeNamedList
vivinkrishna-ni Sep 21, 2023
8f8453b
Fix lint error
vivinkrishna-ni Sep 21, 2023
b59be28
Merge branch 'main' into users/vivin/disable-input-rules-for-marks
vivinkrishna-ni Sep 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Enable only necessary formatting input rules in editor",
vivinkrishna-ni marked this conversation as resolved.
Show resolved Hide resolved
"packageName": "@ni/nimble-components",
"email": "123377523+vivinkrishna-ni@users.noreply.github.com",
"dependentChangeType": "patch"
}
1 change: 1 addition & 0 deletions packages/nimble-components/src/rich-text/editor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ export class RichTextEditor extends FoundationElement implements ErrorPattern {
*/
return new Editor({
element: this.editor,
enableInputRules: [BulletList, OrderedList],
vivinkrishna-ni marked this conversation as resolved.
Show resolved Hide resolved
vivinkrishna-ni marked this conversation as resolved.
Show resolved Hide resolved
extensions: [
Document,
Paragraph,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,83 @@ describe('RichTextEditor', () => {
]);
});

it('should render as a plain text for bold markdown input(**) to the editor', async () => {
vivinkrishna-ni marked this conversation as resolved.
Show resolved Hide resolved
await pageObject.setEditorTextContent('**bold**');

expect(pageObject.getEditorTagNames()).toEqual(['P']);
expect(pageObject.getEditorLeafContents()).toEqual(['**bold**']);
});

it('should render as a plain text for bold markdown input(__) to the editor', async () => {
await pageObject.setEditorTextContent('__bold__');

expect(pageObject.getEditorTagNames()).toEqual(['P']);
expect(pageObject.getEditorLeafContents()).toEqual(['__bold__']);
});

it('should render as a plain text for italics markdown input(*) to the editor', async () => {
await pageObject.setEditorTextContent('*italics*');

expect(pageObject.getEditorTagNames()).toEqual(['P']);
expect(pageObject.getEditorLeafContents()).toEqual(['*italics*']);
});

it('should render as a plain text for italics markdown input(_) to the editor', async () => {
await pageObject.setEditorTextContent('_italics_');

expect(pageObject.getEditorTagNames()).toEqual(['P']);
expect(pageObject.getEditorLeafContents()).toEqual(['_italics_']);
});

it('should have "bullet list(*)" tag name for markdown input to the editor', async () => {
vivinkrishna-ni marked this conversation as resolved.
Show resolved Hide resolved
await pageObject.setEditorTextContent('*');
await pageObject.pressEnterKeyInEditor();
await pageObject.setEditorTextContent('Bullet list');

expect(pageObject.getEditorTagNames()).toEqual(['UL', 'LI', 'P']);
expect(pageObject.getEditorLeafContents()).toEqual(['Bullet list']);
});

it('should have "bullet list(+)" tag name for markdown input to the editor', async () => {
await pageObject.setEditorTextContent('+');
await pageObject.pressEnterKeyInEditor();
await pageObject.setEditorTextContent('Bullet list');

expect(pageObject.getEditorTagNames()).toEqual(['UL', 'LI', 'P']);
expect(pageObject.getEditorLeafContents()).toEqual(['Bullet list']);
});

it('should have "bullet list(-)" tag name for markdown input to the editor', async () => {
await pageObject.setEditorTextContent('-');
await pageObject.pressEnterKeyInEditor();
await pageObject.setEditorTextContent('Bullet list');

expect(pageObject.getEditorTagNames()).toEqual(['UL', 'LI', 'P']);
expect(pageObject.getEditorLeafContents()).toEqual(['Bullet list']);
});

it('should have "numbered list" tag name for markdown input to the editor', async () => {
await pageObject.setEditorTextContent('1.');
await pageObject.pressEnterKeyInEditor();
await pageObject.setEditorTextContent('Numbered list');

expect(pageObject.getEditorTagNames()).toEqual(['OL', 'LI', 'P']);
expect(pageObject.getEditorLeafContents()).toEqual([
'Numbered list'
]);
});

it('should have "numbered list" with a different starting number tag name for markdown input to the editor', async () => {
await pageObject.setEditorTextContent('5.');
await pageObject.pressEnterKeyInEditor();
await pageObject.setEditorTextContent('Numbered list');

expect(pageObject.getEditorTagNames()).toEqual(['OL', 'LI', 'P']);
expect(pageObject.getEditorLeafContents()).toEqual([
'Numbered list'
]);
});

it('should have br tag name when pressing shift + Enter with numbered list content', async () => {
await pageObject.setEditorTextContent('numbered list1');
await pageObject.clickFooterButton(ToolbarButton.numberedList);
Expand Down
Loading