-
Notifications
You must be signed in to change notification settings - Fork 3k
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(editor): improve documentation editor using Remirror #6631
feat(editor): improve documentation editor using Remirror #6631
Conversation
b114d15
to
739654c
Compare
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.
This is looking incredible! I have some comments here and there, some suggestions and some requests for things like docs and tests. However overall this is looking so good.
I pulled it down myself and am having a blast with it locally! You guys absolutely killed this. After you get back to us with my comments / suggestions let's work to get this in soon!
datahub-web-react/craco.config.js
Outdated
jest: { | ||
configure: (jestConfig) => { | ||
jestConfig.transformIgnorePatterns = [ | ||
'node_modules/(?!(lib0|y-protocols)).+\\.(js|jsx|mjs|cjs|ts|tsx)$', | ||
'^.+\\.module\\.(css|sass|scss)$', | ||
]; | ||
return jestConfig; | ||
}, | ||
}, |
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.
can you add a comment as to what this is doing and what it's necessary?
const hideLinksButton = properties?.hideLinksButton; | ||
const { urn, entityData } = useEntityData(); | ||
const refetch = useRefetch(); | ||
const description = entityData?.editableProperties?.description || entityData?.properties?.description || ''; | ||
const sanitizedDescription = DOMPurify.sanitize(description); |
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.
even if remirror also handles this, do you think it's a problem to sanitize here as well? just in case anything ever changes with remirror I really want to avoid any unsafe scripts or anything getting into documentation
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.
same idea with sanitizing below before sending to the BE
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.
Hmm, I remembered the double sanitisation did throw out some unwanted syntax in the output. Let me take a look at it again.
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.
okay if that's the case I don't think it's a problem as long as we feel good about remirror being able to handle this for us
onChange?: (md: string) => void; | ||
}; | ||
|
||
export const Editor = forwardRef((props: EditorProps, ref) => { |
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.
nice this is my first time seeing forwardRef
- nicer than having to explicitly pass in a ref
as another old prop!
useMount(() => { | ||
manager.view.focus(); | ||
}); |
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've been waiting for something like useMount
... what a time to be alive
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.
Haha yup, react-use is a lifesaver!
import { MentionsComponent } from './extensions/mentions/MentionsComponent'; | ||
|
||
type EditorProps = { | ||
readonly?: boolean; |
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.
minor: can we change to camel case and be readOnly
?
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.
Will make the change
handleEvents?: Handler<(action: AutocompleteAction) => boolean>; | ||
} | ||
|
||
class DataHubMentionsExtension extends NodeExtension<DataHubMentionsOptions> { |
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.
yeah as I mentioned in another comment, some docs here would be great as creating out own remirror extension requires a lot of special knowledge.
import { CommandButton } from './CommandButton'; | ||
import { LinkModal } from './LinkModal'; | ||
|
||
export const AddLinkButton = () => { |
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.
these are great individual toolbar components! very useful and organzied
import Icon from '@ant-design/icons'; | ||
import { CustomIconComponentProps } from '@ant-design/icons/lib/components/Icon'; | ||
|
||
export const CodeIcon = (props: Partial<CustomIconComponentProps>) => ( |
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.
this is awesome
overflow: hidden; | ||
`; | ||
|
||
export const FloatingToolbar = () => { |
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.
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.
Will fix this!
<Toolbar /> | ||
<CodeBlockToolbar /> | ||
<FloatingToolbar /> | ||
<TableComponents tableCellMenuProps={{ Component: TableCellMenu }} /> |
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.
is it possible to resize columns and rows of the table with your mouse? I'm trying to do it locally but not figuring out how if it is possible
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.
Actually it's possible and it's enabled in Grab's fork. The downside is that the table will be stored in HTML rather than Markdown format. I wasn't sure if DataHub wanted that activated since you can't 'un-resize' a table (or we could also introduce a button to 'un-resize' it but I'll need more time to investigate it).
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.
okay gotcha! yeah if it were possible to resize and store in markdown I think that would be fantastic, but if it's too much of a lift initially I think we can come back to that as a followup improvement.
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.
This is looking so great!
Thanks so much for getting back to my comments and adding all the tests and what not. I pulled down again and tried locally and things are looking awesome :)
I have one more comment about making links target="_blank"
so they open in a new tab, but otherwise I think this thing is ready to rumble!
I did notice that there's a few conflicts with master, though, so once those are resolved and we get CI to pass everything, let's get this guy merged.
@@ -0,0 +1,69 @@ | |||
import { htmlToMarkdown } from '../../../../components/editor/extensions/htmlToMarkdown'; | |||
|
|||
const cases = [ |
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.
thank you!
handleClose: () => void; | ||
}; | ||
|
||
export const LinkModal = (props: LinkModalProps) => { |
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.
is there a way that we can add target: "_blank"
to links created in documentation so they open in a new tab?
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.
Sure, fixed in bd3d8d2
bd3d8d2
to
3dd5e1f
Compare
env: | ||
NODE_OPTIONS: "--max-old-space-size=3072" |
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.
why is this change necessary?
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.
Oh it's to resolve the failing build that was caused by FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory.
in https://github.com/datahub-project/datahub/actions/runs/3804191769/jobs/6471221050. This line simply increases the memory limit allocated to node. If there are other solutions please feel free to make changes to the PR too!
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.
it looks like this failure is still happening :( do you know if we need to put this type of change elsewhere?
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.
another initiative we've discussed is removing the unneeded dependencies from our package.json - unsure how many things we can remove but if we can shrink our dependencies this may help solve this problem! it's something i'm looking into and will see if it helps here
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.
Hmm, the latest build passed though: https://github.com/datahub-project/datahub/actions/runs/3805789729/jobs/6559405831. The only pipeline that's failing is https://github.com/datahub-project/datahub/actions/runs/3805789729/jobs/6559407548 which looks unrelated to the documentation, probably a flaky test (but I can't rereun it :x)
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.
Also let me know if you need help looking into shrinking the dependencies 🗡️ !
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.
ah so it looks like it's fixed in the Docker, Build, Scan, Test runs, but i'm still seeing the error in the logs on the general build & test / build job (https://github.com/datahub-project/datahub/actions/runs/3805789734/jobs/6521531814) - you'll have to search for it cuz that's a huge log lol
also it seems that that's timing out after 60 minutes, my hunch is that it's related to this build failing or even that something is taking much longer for some reason.
ffb810a
to
5cbf5ac
Compare
5cbf5ac
to
a255acc
Compare
everything is passing in CI now woo! except for these failing Monitoring tests but those are failing for all open PRs |
Awesome, thanks for the help @chriscollins3456 ! |
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 finally got a chance to take a deep look at this PR.
All I have to say is: WOW. The new experience looks and feels incredible - A major improvement on usability that will benefit many people (thousands of active users) in the community directly!
This PR represents an incredible piece of collaboration between Grab and the DataHub Community. I want to say thank you to @ngamanda, @chriscollins3456, and of course Harvey on behalf of the entire DataHub Team and the broader community. I look forward to continued partnership between our teams as we continue to improve DataHub.
Very happy to give this a final "LGTM" stamp.
Cheers!
John
…oject#6631) Co-authored-by: Chris Collins <[email protected]>
…oject#6631) Co-authored-by: Chris Collins <[email protected]>
Highlights
@
. More details about the entity shown upon hovering over the mention![alt text](my-image.png)
). Upon resizing, the image will be stored as HTML Markup (i.e.<img height="46" width="54" src="my-image.png" alt="alt text" />
)Summary of Changes
@remirror/*
for editor,prosemirror-autocomplete
for powering inline suggestions,turndown-plugin-gfm
to addgfm
support for tablesprosemirror-autocomplete
pluginlib0
andy-protocols
, keeping'^.+\\.module\\.(css|sass|scss)$'
from default configurationsChecklist