Skip to content

Commit

Permalink
Rich Text Editor | Implementation of additional APIs (#1446)
Browse files Browse the repository at this point in the history
# Pull Request

## 🤨 Rationale

See the [API section of the
spec](https://github.com/ni/nimble/tree/main/packages/nimble-components/src/rich-text-editor/specs#api).

## 👩‍💻 Implementation

* Implemented the following APIs:
1. `disabled` - boolean attribute when enabled, set the Tiptap's
editable state to false through
[setEditable()](https://tiptap.dev/api/editor#set-editable) and set the
`disabled` attribute of "nimble-toggle-button".
    2. `footer-hidden` - hide the footer through styles.
3. `placeholder` - installed Tiptap's
[Placeholder](https://tiptap.dev/api/extensions/placeholder) extension
and configured the styles to show the placeholder text when the editor
is empty.
4. `empty` - read-only property that returns "true" if the editor is
empty by getting the current "textContent" of the editor.
5. `error-visible` - styled the editor with error color and added an
exclamation icon to the editor same as in the "nimble-textarea". Used
the "ResizeObserver" to update the scrollbar width and position of the
error icon in the editor accordingly.
6. `error-text` - shows the text in the bottom left of the editor just
like other nimble components.
* Bumped all the `@tiptap` extensions to the latest version.
 
## 🧪 Testing

* Added visual matrix tests to test the combinations of all the
UI-related APIs.
* Added unit tests for the APIs which cannot be covered in visual tests.
* Manually verified the functionalities in the local storybook build.

## ✅ Checklist

<!--- Review the list and put an x in the boxes that apply or ~~strike
through~~ around items that don't (along with an explanation). -->

- [x] I have updated the project documentation to reflect my changes or
determined no changes are needed.

---------
  • Loading branch information
vivinkrishna-ni authored Aug 31, 2023
1 parent db5ebd4 commit ce10bda
Show file tree
Hide file tree
Showing 11 changed files with 797 additions and 156 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Implementation of additional APIs for rich text editor",
"packageName": "@ni/nimble-components",
"email": "[email protected]",
"dependentChangeType": "patch"
}
94 changes: 54 additions & 40 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 11 additions & 10 deletions packages/nimble-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,17 @@
"@ni/nimble-tokens": "^6.3.0",
"@tanstack/table-core": "^8.9.3",
"@tanstack/virtual-core": "^3.0.0-beta.44",
"@tiptap/core": "^2.0.4",
"@tiptap/extension-bold": "^2.0.4",
"@tiptap/extension-bullet-list": "^2.0.4",
"@tiptap/extension-document": "^2.0.4",
"@tiptap/extension-history": "^2.0.4",
"@tiptap/extension-italic": "^2.0.4",
"@tiptap/extension-list-item": "^2.0.4",
"@tiptap/extension-ordered-list": "^2.0.4",
"@tiptap/extension-paragraph": "^2.0.4",
"@tiptap/extension-text": "^2.0.4",
"@tiptap/core": "^2.1.6",
"@tiptap/extension-bold": "^2.1.6",
"@tiptap/extension-bullet-list": "^2.1.6",
"@tiptap/extension-document": "^2.1.6",
"@tiptap/extension-history": "^2.1.6",
"@tiptap/extension-italic": "^2.1.6",
"@tiptap/extension-list-item": "^2.1.6",
"@tiptap/extension-ordered-list": "^2.1.6",
"@tiptap/extension-paragraph": "^2.1.6",
"@tiptap/extension-placeholder": "^2.1.6",
"@tiptap/extension-text": "^2.1.6",
"@types/d3-array": "^3.0.4",
"@types/d3-random": "^3.0.1",
"@types/d3-scale": "^4.0.2",
Expand Down
Loading

0 comments on commit ce10bda

Please sign in to comment.