-
Notifications
You must be signed in to change notification settings - Fork 116
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
feat: superscipt and subscript support to rich text editor [TOL-30] #1280
Conversation
✅ Deploy Preview for contentful-field-editors ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
@@ -61,7 +61,16 @@ import { RichTextEditor } from '@contentful/field-editor-rich-text'; | |||
}; | |||
|
|||
const initialValue = JSON.parse(window.localStorage.getItem('initialValue')) || undefined | |||
const [field, mitt] = useMemo(() => createFakeFieldAPI(mock => mock, initialValue), []); | |||
const [fakeField, mitt] = useMemo(() => createFakeFieldAPI(mock => mock, initialValue), []); | |||
// Overriding mark validation here to show subscript and superscript marks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default we don't show the superscript and subscript marks but showing in the preview so doing an override here
@@ -0,0 +1,52 @@ | |||
import { createFakeFieldAPI } from '@contentful/field-editor-test-utils'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MayaGillilanContentful testing the logic for validating marks in these unit tests
const findMarkViaToolvar = (mark: MARKS) => cy.findByTestId(`${mark}-toolbar-button`); | ||
const toggleMarkViaToolbar = (mark: MARKS) => cy.findByTestId(`${mark}-toolbar-button`).click(); | ||
|
||
it(`hides ${MARKS.SUBSCRIPT} and ${MARKS.SUPERSCRIPT} marks if not explicitly allowed`, () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MayaGillilanContentful also some cypress tests here for checking the showing/hiding logic
@@ -61,7 +61,16 @@ import { RichTextEditor } from '@contentful/field-editor-rich-text'; | |||
}; | |||
|
|||
const initialValue = JSON.parse(window.localStorage.getItem('initialValue')) || undefined | |||
const [field, mitt] = useMemo(() => createFakeFieldAPI(mock => mock, initialValue), []); | |||
const fieldValidations = JSON.parse(window.localStorage.getItem('fieldValidations')) || undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this default to undefined and not []?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm falling back to undefined as I think local storage uses null by default. Then later on it will fallback to whatever value the mock gives us if it has one. I don't want to hard code this to []
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. Some clarifying questions and suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Don't forget to update the snapshot
Adding subscript and superscript support to rich text editor
@contentful/rich-text-types