-
-
Notifications
You must be signed in to change notification settings - Fork 693
fix: use <details>/<summary> for toggle block HTML export #2524
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
Open
YousefED
wants to merge
1
commit into
main
Choose a base branch
from
fix/blo-936-toggle-block-details-summary
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+315
−7
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -146,6 +146,7 @@ export type LooseBlockSpec< | |
| | { | ||
| dom: HTMLElement | DocumentFragment; | ||
| contentDOM?: HTMLElement; | ||
| childrenDOM?: HTMLElement; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know about this |
||
| } | ||
| | undefined; | ||
|
|
||
|
|
@@ -203,6 +204,7 @@ export type BlockSpecs = { | |
| | { | ||
| dom: HTMLElement | DocumentFragment; | ||
| contentDOM?: HTMLElement; | ||
| childrenDOM?: HTMLElement; | ||
| } | ||
| | undefined; | ||
| }; | ||
|
|
@@ -476,6 +478,7 @@ export type BlockImplementation< | |
| | { | ||
| dom: HTMLElement | DocumentFragment; | ||
| contentDOM?: HTMLElement; | ||
| childrenDOM?: HTMLElement; | ||
| } | ||
| | undefined; | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...it/core/formatConversion/export/__snapshots__/blocknoteHTML/lists/toggleWithChildren.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| <div class="bn-block-group" data-node-type="blockGroup"> | ||
| <div class="bn-block-outer" data-node-type="blockOuter" data-id="1"> | ||
| <div class="bn-block" data-node-type="blockContainer" data-id="1"> | ||
| <div class="bn-block-content" data-content-type="toggleListItem"> | ||
| <div> | ||
| <div class="bn-toggle-wrapper" data-show-children="true"> | ||
| <button class="bn-toggle-button" type="button"> | ||
| <svg | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| height="24px" | ||
| viewBox="0 -960 960 960" | ||
| width="24px" | ||
| fill="CURRENTCOLOR" | ||
| > | ||
| <path d="M320-200v-560l440 280-440 280Z"></path> | ||
| </svg> | ||
| </button> | ||
| <p class="bn-inline-content">Toggle List Item</p> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <div class="bn-block-group" data-node-type="blockGroup"> | ||
| <div class="bn-block-outer" data-node-type="blockOuter" data-id="2"> | ||
| <div class="bn-block" data-node-type="blockContainer" data-id="2"> | ||
| <div class="bn-block-content" data-content-type="paragraph"> | ||
| <p class="bn-inline-content">Toggle Child 1</p> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <div class="bn-block-outer" data-node-type="blockOuter" data-id="3"> | ||
| <div class="bn-block" data-node-type="blockContainer" data-id="3"> | ||
| <div class="bn-block-content" data-content-type="paragraph"> | ||
| <p class="bn-inline-content">Toggle Child 2</p> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <div class="bn-block-outer" data-node-type="blockOuter" data-id="4"> | ||
| <div class="bn-block" data-node-type="blockContainer" data-id="4"> | ||
| <div | ||
| class="bn-block-content" | ||
| data-content-type="heading" | ||
| data-level="2" | ||
| data-is-toggleable="true" | ||
| > | ||
| <div> | ||
| <div class="bn-toggle-wrapper" data-show-children="true"> | ||
| <button class="bn-toggle-button" type="button"> | ||
| <svg | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| height="24px" | ||
| viewBox="0 -960 960 960" | ||
| width="24px" | ||
| fill="CURRENTCOLOR" | ||
| > | ||
| <path d="M320-200v-560l440 280-440 280Z"></path> | ||
| </svg> | ||
| </button> | ||
| <h2 class="bn-inline-content">Toggle Heading</h2> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <div class="bn-block-group" data-node-type="blockGroup"> | ||
| <div class="bn-block-outer" data-node-type="blockOuter" data-id="5"> | ||
| <div class="bn-block" data-node-type="blockContainer" data-id="5"> | ||
| <div class="bn-block-content" data-content-type="paragraph"> | ||
| <p class="bn-inline-content">Heading Child 1</p> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
tests/src/unit/core/formatConversion/export/__snapshots__/html/lists/toggleWithChildren.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <ul> | ||
| <li> | ||
| <details open=""> | ||
| <summary> | ||
| <p class="bn-inline-content">Toggle List Item</p> | ||
| </summary> | ||
| <p data-nesting-level="1">Toggle Child 1</p> | ||
| <p data-nesting-level="1">Toggle Child 2</p> | ||
| </details> | ||
| </li> | ||
| </ul> | ||
| <details open="" data-level="2" data-is-toggleable="true"> | ||
| <summary> | ||
| <h2 class="bn-inline-content">Toggle Heading</h2> | ||
| </summary> | ||
| <p data-nesting-level="1">Heading Child 1</p> | ||
| </details> |
9 changes: 9 additions & 0 deletions
9
...core/formatConversion/export/__snapshots__/markdown/lists/toggleWithChildren.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| * Toggle List Item | ||
|
|
||
| Toggle Child 1 | ||
|
|
||
| Toggle Child 2 | ||
|
|
||
| ## Toggle Heading | ||
|
|
||
| Heading Child 1 |
124 changes: 124 additions & 0 deletions
124
...s/src/unit/core/formatConversion/export/__snapshots__/nodes/lists/toggleWithChildren.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| [ | ||
| { | ||
| "attrs": { | ||
| "id": "1", | ||
| }, | ||
| "content": [ | ||
| { | ||
| "attrs": { | ||
| "backgroundColor": "default", | ||
| "textAlignment": "left", | ||
| "textColor": "default", | ||
| }, | ||
| "content": [ | ||
| { | ||
| "text": "Toggle List Item", | ||
| "type": "text", | ||
| }, | ||
| ], | ||
| "type": "toggleListItem", | ||
| }, | ||
| { | ||
| "content": [ | ||
| { | ||
| "attrs": { | ||
| "id": "2", | ||
| }, | ||
| "content": [ | ||
| { | ||
| "attrs": { | ||
| "backgroundColor": "default", | ||
| "textAlignment": "left", | ||
| "textColor": "default", | ||
| }, | ||
| "content": [ | ||
| { | ||
| "text": "Toggle Child 1", | ||
| "type": "text", | ||
| }, | ||
| ], | ||
| "type": "paragraph", | ||
| }, | ||
| ], | ||
| "type": "blockContainer", | ||
| }, | ||
| { | ||
| "attrs": { | ||
| "id": "3", | ||
| }, | ||
| "content": [ | ||
| { | ||
| "attrs": { | ||
| "backgroundColor": "default", | ||
| "textAlignment": "left", | ||
| "textColor": "default", | ||
| }, | ||
| "content": [ | ||
| { | ||
| "text": "Toggle Child 2", | ||
| "type": "text", | ||
| }, | ||
| ], | ||
| "type": "paragraph", | ||
| }, | ||
| ], | ||
| "type": "blockContainer", | ||
| }, | ||
| ], | ||
| "type": "blockGroup", | ||
| }, | ||
| ], | ||
| "type": "blockContainer", | ||
| }, | ||
| { | ||
| "attrs": { | ||
| "id": "4", | ||
| }, | ||
| "content": [ | ||
| { | ||
| "attrs": { | ||
| "backgroundColor": "default", | ||
| "isToggleable": true, | ||
| "level": 2, | ||
| "textAlignment": "left", | ||
| "textColor": "default", | ||
| }, | ||
| "content": [ | ||
| { | ||
| "text": "Toggle Heading", | ||
| "type": "text", | ||
| }, | ||
| ], | ||
| "type": "heading", | ||
| }, | ||
| { | ||
| "content": [ | ||
| { | ||
| "attrs": { | ||
| "id": "5", | ||
| }, | ||
| "content": [ | ||
| { | ||
| "attrs": { | ||
| "backgroundColor": "default", | ||
| "textAlignment": "left", | ||
| "textColor": "default", | ||
| }, | ||
| "content": [ | ||
| { | ||
| "text": "Heading Child 1", | ||
| "type": "text", | ||
| }, | ||
| ], | ||
| "type": "paragraph", | ||
| }, | ||
| ], | ||
| "type": "blockContainer", | ||
| }, | ||
| ], | ||
| "type": "blockGroup", | ||
| }, | ||
| ], | ||
| "type": "blockContainer", | ||
| }, | ||
| ] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Should check
allowToggleHeadings && block.props.isToggleable