Skip to content

Collapse and Expand DevTools Tree Nodes - #2679

Merged
thegreatercurve merged 7 commits into
meta:mainfrom
MLH-Fellowship:collapse-expand-tree-nodes
Jul 22, 2022
Merged

thegreatercurve merged 7 commits into
meta:mainfrom
MLH-Fellowship:collapse-expand-tree-nodes

Conversation

@noi5e

@noi5e noi5e commented Jul 22, 2022 •

Copy link
Copy Markdown
Contributor

DevTools nodes now accordion open and closed.

Screen.Recording.2022-07-21.at.10.15.59.PM.mov

Developer Tools Web Extension Planning Issue: #2127

@vercel

vercel Bot commented Jul 22, 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 Jul 22, 2022 at 7:08PM (UTC)
lexical-playground ✅ Ready (Inspect) Visit Preview Jul 22, 2022 at 7:08PM (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 Jul 22, 2022
@zurfyx

zurfyx commented Jul 22, 2022

Copy link
Copy Markdown
Member

LGTM!

@thegreatercurve

Copy link
Copy Markdown
Contributor

Nic work @noi5e!

@noi5e

noi5e commented Jul 22, 2022

Copy link
Copy Markdown
Contributor Author

Pushed some new commits to take care of everyone's comments including this one:

Should this default to 0? Is there a case where you'd want to start at something other than zero other than in the implementation? Probably not a big deal since this isn't exported or anything.

I rewrote depthFirstSearch with default parameters, and also passing in nodeMap as an additional parameter. Seems like a better piece of code, thanks for the suggestion:

  const depthFirstSearch = (
    map: DevToolsTree = nodeMap,
    nodeKey = 'root',
    depth = 0,
  ): DevToolsNode => {
    const node = map[nodeKey];
    const children: Array<DevToolsNode> = [];

    if (Object.prototype.hasOwnProperty.call(node, '__children')) {
      node.__children.forEach((childKey: string) => {
        children.push(depthFirstSearch(map, childKey, depth + 1));
      });
    }

    return {
      ...node,
      __type: node.__type,
      children,
      depth,
      lexicalKey: node.__key,
    };
  };

@noi5e

noi5e commented Jul 22, 2022

Copy link
Copy Markdown
Contributor Author

This seems merge-ready, just failing some unrelated e2e tests in lexical-playground. This is the based on the most recent main as far as I know...

@thegreatercurve
thegreatercurve merged commit af31dee into meta:main Jul 22, 2022
@noi5e
noi5e deleted the collapse-expand-tree-nodes branch July 22, 2022 21:40
karam-qaoud pushed a commit to karam-qaoud/lexical that referenced this pull request Jul 26, 2022
karam-qaoud added a commit that referenced this pull request Jul 26, 2022
* Fixed getStyleObjectFromRawCSS function to work for unformatted css strings

* Testing that  handles unformatted css text

* Testing that $getStyleObjectFromRawCss handles unformatted css

* Added TableOfContents

* Renamed TableOfContetnsPlugin file name and added flow file

* Added TableOfContentsPlugin to config files and added styling

* Fixed types

* Added TableOfContentsList as a seperate module

* Fixed type of tag from string to HeadingTagType

* Table of contents updates as user scrolls

* Wrapped plugin in a feature

* Deleted package-lock.json

* Fixed conditioanl rendering syntax

* Removed extra parameter

* package-lock

* fix imports

* Update packages/lexical-playground/src/plugins/TableOfContentsPlugin.tsx

Co-authored-by: Gerard Rovira <[email protected]>

* Added sticky styling and handled text overflow

* Table of contents updates automtaically on scroll without observing all heading nodes

* Update table correctly  when headings are not visible but exist either up or down

* Fix failing E2E

* Changed isTableOfContentes to showTableOfContents in settings

* Added useEffect to fix memory leak

* Hoisted functions that don't use props

* Renamed isTableOfContets to showTableOfContents

* Changing selectedHeading by observing page top

* resolved lint error

* Refactored scroll up logic

* Added comments

* Added better css

* Changed place of toc div to fix failing test

* Fixed adjacent headings scrolling

* Fixed adjacent headings bug

* Renamed helper methods

* Fixed test

* Added dependency array to useEffect

* Added TableOfContents to dependency array

* Updated dependeny array in useEffect

* Created e2e test file for table of contents plugin

* Added scroll test

* E2E test: Adding heading to editor adds them to table-of-contents

* clean up

* Refactored getEditorElement

* Scrolling callback has better conditions

* Table of contents is now covering all edge cases and doesn't freeze webpage

* Solved page freezing

* Added one more assert statment to second test

* chore(lexical-playground): make directory clear (#2674)

* Conditionally utilize `startTransition` if it's present (#2676)

* Only utilize startTransition if it's available

* Add type annotation

* Run prettier

* fix(lexical-list): remove list breaks if selection in empty (#2672)

* fix(lexical-list): remove list breaks if selection in empty

* chore: add a comment

* chore: add test

* Separate `@lexical/code` into more atomic modules (#2673)

* separate code package into more atomic modules

* remove utils

* named exports

* Fixed typo (#2678)

* fix: path to icons (#2683)

* Fix VALID_TWITTER_URL to allow underscores. (#2690)

* fix(lexical-playground): LexicalTypeaheadMenuPlugin import (#2689)

Use the correct import path that available in NPM package

* Collapse and Expand DevTools Tree Nodes (#2679)

* fix(playground): fix rendering Exclidraw (#2694)

* Make includeHeaders a boolean (#2697)

Changed type for includeHeaders parameter from string to boolean to match the type of the parameter from the $createTableNodeWithDimensions function.

* Remove coverage reports (#2699)

* fix: check if options are empty (#2701)

* feat: Link node with target and rel (#2687)

* OnChangePlugin ignoreInitialChange -> ignoreHistoryMergeTagChange (#2706)

* OnChangePlugin ignoreInitialChange -> ignoreHistoryMergeTag

* .

* default to false because 0.4

Co-authored-by: Karam Qaoud <[email protected]>
Co-authored-by: Gerard Rovira <[email protected]>
Co-authored-by: 子瞻 Luci <[email protected]>
Co-authored-by: Jack Hanford <[email protected]>
Co-authored-by: John Flockton <[email protected]>
Co-authored-by: SalvadorLekan <[email protected]>
Co-authored-by: Adithya Vardhan <[email protected]>
Co-authored-by: hiraoka <[email protected]>
Co-authored-by: Elvin Dzhavadov <[email protected]>
Co-authored-by: Will <[email protected]>
Co-authored-by: Bryan <[email protected]>
Co-authored-by: alinamusuroi <[email protected]>
Co-authored-by: Andriy Chemerynskiy <[email protected]>
thegreatercurve added a commit that referenced this pull request Nov 25, 2022
* Fixed getStyleObjectFromRawCSS function to work for unformatted css strings

* Testing that  handles unformatted css text

* Testing that $getStyleObjectFromRawCss handles unformatted css

* Added TableOfContents

* Renamed TableOfContetnsPlugin file name and added flow file

* Added TableOfContentsPlugin to config files and added styling

* Fixed types

* Added TableOfContentsList as a seperate module

* Fixed type of tag from string to HeadingTagType

* Table of contents updates as user scrolls

* Wrapped plugin in a feature

* Deleted package-lock.json

* Fixed conditioanl rendering syntax

* Removed extra parameter

* package-lock

* fix imports

* Update packages/lexical-playground/src/plugins/TableOfContentsPlugin.tsx

Co-authored-by: Gerard Rovira <[email protected]>

* Added sticky styling and handled text overflow

* Table of contents updates automtaically on scroll without observing all heading nodes

* Update table correctly  when headings are not visible but exist either up or down

* Fix failing E2E

* Changed isTableOfContentes to showTableOfContents in settings

* Added useEffect to fix memory leak

* Hoisted functions that don't use props

* Renamed isTableOfContets to showTableOfContents

* Changing selectedHeading by observing page top

* resolved lint error

* Refactored scroll up logic

* Added comments

* Added better css

* Changed place of toc div to fix failing test

* Fixed adjacent headings scrolling

* Fixed adjacent headings bug

* Renamed helper methods

* Fixed test

* Added dependency array to useEffect

* Added TableOfContents to dependency array

* Updated dependeny array in useEffect

* Created e2e test file for table of contents plugin

* Added scroll test

* E2E test: Adding heading to editor adds them to table-of-contents

* clean up

* Refactored getEditorElement

* Scrolling callback has better conditions

* Table of contents is now covering all edge cases and doesn't freeze webpage

* Solved page freezing

* Added one more assert statment to second test

* chore(lexical-playground): make directory clear (#2674)

* Conditionally utilize `startTransition` if it's present (#2676)

* Only utilize startTransition if it's available

* Add type annotation

* Run prettier

* fix(lexical-list): remove list breaks if selection in empty (#2672)

* fix(lexical-list): remove list breaks if selection in empty

* chore: add a comment

* chore: add test

* Separate `@lexical/code` into more atomic modules (#2673)

* separate code package into more atomic modules

* remove utils

* named exports

* Fixed typo (#2678)

* fix: path to icons (#2683)

* Fix VALID_TWITTER_URL to allow underscores. (#2690)

* fix(lexical-playground): LexicalTypeaheadMenuPlugin import (#2689)

Use the correct import path that available in NPM package

* Collapse and Expand DevTools Tree Nodes (#2679)

* fix(playground): fix rendering Exclidraw (#2694)

* Make includeHeaders a boolean (#2697)

Changed type for includeHeaders parameter from string to boolean to match the type of the parameter from the $createTableNodeWithDimensions function.

* Remove coverage reports (#2699)

* fix: check if options are empty (#2701)

* feat: Link node with target and rel (#2687)

* OnChangePlugin ignoreInitialChange -> ignoreHistoryMergeTagChange (#2706)

* OnChangePlugin ignoreInitialChange -> ignoreHistoryMergeTag

* .

* default to false because 0.4

Co-authored-by: Karam Qaoud <[email protected]>
Co-authored-by: Gerard Rovira <[email protected]>
Co-authored-by: 子瞻 Luci <[email protected]>
Co-authored-by: Jack Hanford <[email protected]>
Co-authored-by: John Flockton <[email protected]>
Co-authored-by: SalvadorLekan <[email protected]>
Co-authored-by: Adithya Vardhan <[email protected]>
Co-authored-by: hiraoka <[email protected]>
Co-authored-by: Elvin Dzhavadov <[email protected]>
Co-authored-by: Will <[email protected]>
Co-authored-by: Bryan <[email protected]>
Co-authored-by: alinamusuroi <[email protected]>
Co-authored-by: Andriy Chemerynskiy <[email protected]>

This branch was successfully deployed

2 active deployments
Preview – lexical-playground — 91434942 Deployed Jul 22, 2022 by vercel[bot]
Preview – lexical — 91434942 Deployed Jul 22, 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.

5 participants