Skip to content

Add collapsible container plugin - #3082

Merged
acywatson merged 3 commits into
mainfrom
toggle-with-nested-element-nodes
Sep 30, 2022
Merged

acywatson merged 3 commits into
mainfrom
toggle-with-nested-element-nodes

Conversation

@fantactuka

@fantactuka fantactuka commented Sep 28, 2022 •

Copy link
Copy Markdown
Contributor

Kind of an experiment with nested elements (vs going w/decorator and nested editors). Main part is in transformers that enforce nesting structure (and if it's violated unwrap content and convert collapsible content into regular paragraphs)

CollapsibleContainer
  > CollapsibleTitle
  > CollapsibleContent[isShadowRoot]
    > Paragraph
    > Heading
    > ...
Screen.Recording.2022-09-28.at.10.31.15.AM.mov

@vercel

vercel Bot commented Sep 28, 2022 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
lexical ✅ Ready (Inspect) Visit Preview Sep 30, 2022 at 1:42AM (UTC)
lexical-playground ✅ Ready (Inspect) Visit Preview Sep 30, 2022 at 1:42AM (UTC)

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 28, 2022
editor.dispatchCommand(INSERT_COLLAPSIBLE_COMMAND, undefined);
}}
className="item">
<i className="icon plus" />

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe arrow-right instead?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1

@thegreatercurve thegreatercurve left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Out of interest, how badly does this mess up browser search for the document? You could possibly look at adding something like hidden=until-found but it's still in early development: https://developer.chrome.com/articles/hidden-until-found

@Nirlah

Nirlah commented Sep 29, 2022

Copy link
Copy Markdown

I like the nested nodes approach, it could be nice to have draggable blocks support inside the container and from/to the outside.

@zurfyx zurfyx left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Awesome work! Not sure how to best validate the CollapsiblePlugin logic besides assuming that you came across them via trial and error and that we potentially still missed some that we will have to address over time.

@acywatson

Copy link
Copy Markdown
Contributor

Never got a chance to finish this, but a while back I was messing around with doing this leaning more on browser native behaviors and semantic html:

https://codesandbox.io/s/lexical-plain-text-example-forked-jrrb38?file=/src/nodes/ToggleNode.js

Yours is certainly way better, just thought I would share

@fantactuka

Copy link
Copy Markdown
Contributor Author

Never got a chance to finish this, but a while back I was messing around with doing this leaning more on browser native behaviors and semantic html:
codesandbox.io/s/lexical-plain-text-example-forked-jrrb38?file=/src/nodes/ToggleNode.js

I completely forgot about details/summary tags, thank you! It's actually a way better html structure as it both solves collab problem (collapsed/open state won't be synchronized) and auto-open if content matches CMD+F query

@acywatson

Copy link
Copy Markdown
Contributor

Never got a chance to finish this, but a while back I was messing around with doing this leaning more on browser native behaviors and semantic html:
codesandbox.io/s/lexical-plain-text-example-forked-jrrb38?file=/src/nodes/ToggleNode.js

I completely forgot about details/summary tags, thank you! It's actually a way better html structure as it both solves collab problem (collapsed/open state won't be synchronized) and auto-open if content matches CMD+F query

@acywatson
acywatson merged commit 9a51c6f into main Sep 30, 2022
@acywatson
acywatson deleted the toggle-with-nested-element-nodes branch September 30, 2022 15:22
acywatson pushed a commit that referenced this pull request Oct 18, 2022
* Add collapsible container plugin

* Change icon, improve newline handling

* Use summary/details tags for a native support
thegreatercurve pushed a commit that referenced this pull request Nov 25, 2022
* Add collapsible container plugin

* Change icon, improve newline handling

* Use summary/details tags for a native support

This branch was successfully deployed

2 active deployments
Preview – lexical-playground — 77aea7cc Deployed Sep 30, 2022 by vercel[bot]
Preview – lexical — 77aea7cc Deployed Sep 30, 2022 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants