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 | Implementation of additional APIs #1446

Merged
merged 151 commits into from
Aug 31, 2023

Conversation

vivinkrishna-ni
Copy link
Contributor

@vivinkrishna-ni vivinkrishna-ni commented Aug 22, 2023

Pull Request

🀨 Rationale

See the API section of the spec.

πŸ‘©β€πŸ’» Implementation

  • Implemented the following APIs:
    1. disabled - boolean attribute when enabled, set the Tiptap's editable state to false through setEditable() and set the disabled attribute of "nimble-toggle-button".
    2. footer-hidden - hide the footer through styles.
    3. placeholder - installed Tiptap's 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

  • I have updated the project documentation to reflect my changes or determined no changes are needed.

vivinkrishna-ni and others added 30 commits July 6, 2023 18:45
packages/nimble-components/src/rich-text-editor/index.ts Outdated Show resolved Hide resolved
packages/nimble-components/src/rich-text-editor/index.ts Outdated Show resolved Hide resolved
packages/nimble-components/src/rich-text-editor/index.ts Outdated Show resolved Hide resolved
packages/nimble-components/src/rich-text-editor/index.ts Outdated Show resolved Hide resolved
--ni-private-rich-text-editor-footer-section-height: 40px;
${
/** Minimum width is added to accommodate all the possible buttons in the toolbar and to support the mobile width. */ ''
}
min-width: 360px;
}

:host([fit-to-content]) {
max-height: inherit;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these inherits on sizing is a big red flag to me. You pretty much never want to inherit on dimensions. See an example here: #1416 (comment)

This example shows how things can go wrong. Here the user set a width on the editor of 500px and made it position fixed where it is intended to be positioned and sized unrealted to the parent. But the editor had default host styling of inherit. It caused the editor to unexpectedly inherit a width from an unrelated parent element: https://jsbin.com/feripobimu/2/edit?html,js,output

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a feeling based on this feedback and the discussions in the other threads that the style updates needed for fit-to-content may require a few more rounds of feedback.

You may want to consider splitting it into a separate PR but totally up to you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rajsite @jattasNI Due to a time constraint to integrate this component into SLE, which relies entirely on this PR and the angular support PR, we have decided to branch out the fit-to-content related changes into a separate PR as suggested.

We will address all the comments provided for fit-to-content in the follow-up PR which will be created right after we come up with a better implementation approach and after this PR goes in. Therefore, I have removed all the changes related to fit-to-content and other style changes related to inherit from this PR including storybook docs, storybook tests, etc,..

Please note that I will also be removing the fit-to-content related changes from the Angular PR (#1450) which is already approved by every reviewer and will be added along with the follow-up PR.

Copy link
Contributor

@jattasNI jattasNI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting very close!

@mollykreis
Copy link
Contributor

I decline to review.

1 similar comment
@atmgrifter00
Copy link
Contributor

I decline to review.

Copy link
Contributor

@jattasNI jattasNI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I played around in storybook after the removal of fit-to-content and it's looking good to me. I'm also OK with the plans described in the open threads. Just want to do one more check once those threads have been resolved.

Copy link
Contributor

@jattasNI jattasNI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good once you fix the Storybook change and approve the Chromatic diffs. No need to get approval from the remaining reviewers. Congrats!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants