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

Paragraph selector #999

Merged
merged 9 commits into from
Feb 27, 2025
Merged

Paragraph selector #999

merged 9 commits into from
Feb 27, 2025

Conversation

allisonking
Copy link
Contributor

@allisonking allisonking commented Feb 26, 2025

Issue(s) Resolved

Paragraph, heading, and blockquote part of #938

High-level Explanation of PR

Adds a paragraph/heading selector, as well as the ability to add blockquotes

Test Plan

Run storybook in the context editor folder, and play around with making paragraphs/headings/blockquotes.

Screenshots (if applicable)

Screen.Recording.2025-02-26.at.3.46.10.PM.mov
Screen.Recording.2025-02-26.at.3.48.18.PM.mov

Notes

The blockquote heading doesn't look great because it overlaps with the paragraph heading. not sure what should be done here? haven't looked into that code too much yet to see how we'd tweak the positioning
image

@@ -0,0 +1,89 @@
import { lift, setBlockType, wrapIn } from "prosemirror-commands";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

pretty much lifted from legacy

@@ -0,0 +1,32 @@
import type { MarkType } from "prosemirror-model";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

also lifted from legacy—this pattern of creating toggles is much more flexible than what I originally had when it was only bold/italics

@@ -0,0 +1,48 @@
import type { Mark, MarkType, Node, NodeType, Schema } from "prosemirror-model";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

lifted from legacy

@@ -0,0 +1,27 @@
import type { EditorState } from "prosemirror-state";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

lifted from legacy

@allisonking allisonking marked this pull request as ready for review February 26, 2025 20:50
const activeType = paragraphTypeItems.filter((item) => {
const { isActive } = item.command(view)(view.state);
return isActive;
})[0];
Copy link
Member

Choose a reason for hiding this comment

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

Could be simplified like so:

paragraphTypeItems.find((item) => item.command(view)(view.state).isActive)

@allisonking allisonking merged commit 20eba94 into main Feb 27, 2025
6 checks passed
@allisonking allisonking deleted the aking/938/paragraph-selector branch February 27, 2025 22:41
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.

2 participants