Skip to content
This repository has been archived by the owner on Jul 14, 2022. It is now read-only.

Add editorjs renderer #947

Merged
merged 5 commits into from
Nov 16, 2020
Merged

Add editorjs renderer #947

merged 5 commits into from
Nov 16, 2020

Conversation

krzysztofwolski
Copy link
Member

@krzysztofwolski krzysztofwolski commented Nov 12, 2020

Support for new type of renderer (editorjs)

Screenshots

image

image

Pull Request Checklist

  1. All visible strings are translated with proper context.
  2. All data-formatting is locale-aware (dates, numbers, and so on).
  3. The changes are tested.
  4. The code is documented (docstrings, project documentation).
  5. Changes are mentioned in the changelog.

Test Environment Config

API_URI=https://master.staging.saleor.rocks/graphql/

@github-actions github-actions bot temporarily deployed to saleor-1587-editor-js November 12, 2020 11:53 Inactive
@github-actions github-actions bot temporarily deployed to storybook saleor-1587-editor-js November 12, 2020 11:53 Inactive
@github-actions github-actions bot temporarily deployed to saleor-1587-editor-js November 12, 2020 11:59 Inactive
@github-actions github-actions bot temporarily deployed to storybook saleor-1587-editor-js November 12, 2020 11:59 Inactive
@github-actions github-actions bot temporarily deployed to saleor-1587-editor-js November 12, 2020 12:00 Inactive
@github-actions github-actions bot temporarily deployed to storybook saleor-1587-editor-js November 12, 2020 12:00 Inactive
@patrys
Copy link
Member

patrys commented Nov 12, 2020

return editor.current?.destroy;
},
// Rerender editor only if changed from undefined to defined state
[data === undefined]
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on Props type above data should always be defined, is this condition necessary? If this issue occurs and TS doesn't catch it perhaps something is not typed correctly and a check should be applied before mounting this component

data && <RichTextEditorContent data={data} ... />

Copy link
Contributor

Choose a reason for hiding this comment

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

Can be undefined if loading. It serves it's purpose in dashboard so we can display outline etc, but we don't have anything like this here

Copy link
Contributor

Choose a reason for hiding this comment

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

If it's undefined we shouldn't be mounting this component in the first place, if we want to handle undefined state (like loading) it should be reflected in the Props data type so TS can catch that

Copy link
Member Author

Choose a reason for hiding this comment

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

Check is also done before mounting.
Strange, when I removed any of those two lines (60 and 62) editor initializes every time I change tabs (description/attrs) so I would say that it works as should and those are needed. WDYT?

// Rerender editor only if changed from undefined to defined state
[data === undefined]
);
React.useEffect(() => editor.current?.destroy, []);
Copy link
Contributor

Choose a reason for hiding this comment

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

Duplicate (destructor is already defined above)

Copy link
Contributor

Choose a reason for hiding this comment

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

It's connected to issue above, probably safe to remove it

Copy link
Contributor

Choose a reason for hiding this comment

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

It's not necessary no matter the case - all useEffect hooks call return fn on unmount

Copy link
Contributor

Choose a reason for hiding this comment

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

Right 🤔

Copy link
Contributor

@orzechdev orzechdev left a comment

Choose a reason for hiding this comment

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

Cypress tests fail

@krzysztofwolski
Copy link
Member Author

Re console error: codex-team/editor.js#1380 - soon there should be new release

@krzysztofwolski
Copy link
Member Author

Cypress seems to be failing because of test database - everything was green at 453c17b, after adding CHANGELOG tests started failing 🌵

@github-actions github-actions bot temporarily deployed to saleor-1587-editor-js November 13, 2020 14:04 Inactive
@github-actions github-actions bot temporarily deployed to storybook saleor-1587-editor-js November 13, 2020 14:04 Inactive
@github-actions github-actions bot temporarily deployed to saleor-1587-editor-js November 13, 2020 14:43 Inactive
@github-actions github-actions bot temporarily deployed to storybook saleor-1587-editor-js November 13, 2020 14:43 Inactive
@krzysztofwolski krzysztofwolski merged commit 7afaa35 into master Nov 16, 2020
@krzysztofwolski krzysztofwolski deleted the SALEOR-1587-editor-js branch November 16, 2020 09:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants