-
Notifications
You must be signed in to change notification settings - Fork 6
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
Sticky editor menu #977
Sticky editor menu #977
Conversation
28034dd
to
68c803f
Compare
suggestData, | ||
setSuggestData | ||
), | ||
new Plugin({ |
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's easier to include this plugin here rather than in basePlugins
since this one needs access to pluginViewFactory
which we get from the hook
import type { MarkType } from "prosemirror-model"; | ||
import type { EditorState } from "prosemirror-state"; | ||
|
||
export const markIsActive = (markType: MarkType, editorState: EditorState) => { |
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.
took this from legacy
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.
Clean and straightforward. Great work!
Issue(s) Resolved
Closes #937
Closes #941
Closes #942
High-level Explanation of PR
Adds a menu bar to the context editor which can stick to the top of an editor. The editor needs to have a
max-height
andoverflow: scroll
for the stickiness to kick in.Test Plan
pnpm run storybook
inpackages/context-editor
and play with the editor!Or, to see it in the app:
Screenshots (if applicable)
demo of bold/italic commands
Screen.Recording.2025-02-19.at.10.25.22.AM.mov
it's sticky!
Screen.Recording.2025-02-19.at.10.30.00.AM.mov
Notes
I based the bold and italic input rules off of the inline code one in legacy:
https://github.com/pubpub/pubpub/blob/4e39976b74a7204cb5703f2b5e5b2cf7f2ce3233/client/components/Editor/plugins/inputRules.ts#L45-L57
including the space at the end to trigger the rule. I thought the space was unnecessary at first, but I think in this case where the editor is applying rules as soon as the user types, it's necessary for
*italic*
vs**bold**
, otherwise**bold**
can never trigger. (It works for things like this GH editor because you have to navigate to the preview view which can then figure out you mean to bold instead of seeing**bold*
and immediately making it '*bold'