-
Notifications
You must be signed in to change notification settings - Fork 5
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
feat: page editor #240
Merged
+2,369
−137
Merged
feat: page editor #240
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
d3836a3
TipTap basic editor
badgeth-dao e11c45b
Merge branch 'master' into tip-tap
badgeth-dao 202589a
Exploring tip tap commands
badgeth-dao 9059533
Exploring how to toggle state
badgeth-dao 8b42d2f
Rendering tip tap custom react component
badgeth-dao 779f498
Show header boolean prop toggle added to entity table container
badgeth-dao 2e0ce78
Rename react component to table-node
badgeth-dao 1633096
Insert table with click
badgeth-dao 6536fc6
Memoize this shit
badgeth-dao 6542d84
Inserting table node with a paragraph after
badgeth-dao 766b9af
Command list looking fly
badgeth-dao e11e8b2
Image start
badgeth-dao 44bb000
Memoize some things
badgeth-dao 10635d5
Custom v2 page for reading/writing TipTap
badgeth-dao 2c1efac
Exploring how to add this plus button in tiptap...
badgeth-dao 2c1ccf0
It works for plus button too
badgeth-dao 9e2c9a8
Commands looking good
badgeth-dao 3f13cc7
Frustrating ability to style components
badgeth-dao 1d84ab5
Command list showing up properly
badgeth-dao bf2e50b
Command list popover best
badgeth-dao 0b1957d
Merge branch 'master' into tip-tap-v2-bugfix
badgeth-dao 2e5501d
Type fetching for table
badgeth-dao 8f10b20
Simpler command code
badgeth-dao fbd4b86
Inserting table of type
badgeth-dao e0fc423
Type fixing
badgeth-dao b0f0379
Working on serializing data
badgeth-dao a2958f2
Wire up Docker to TipTap's private registry
badgeth-dao 2c9636b
Producing a lot of blocks
badgeth-dao ff7bf8f
Loading blocks step 1
badgeth-dao 8425719
Load blocks
badgeth-dao 7ac4e3f
More comments on how this Editing works
badgeth-dao 9b8c5c3
Tiptap hell
badgeth-dao f303a6b
WIP on block IDs triple
badgeth-dao 50b72e9
Tip tap v2 hell
badgeth-dao 1f6ef2e
Content goodness
badgeth-dao 94c38cf
Minor clean up on the code
badgeth-dao 8784f8f
WIP
badgeth-dao 373af10
Making entity-store look like edit-events
badgeth-dao 1cdf01e
Setting the parent entity on blocks
badgeth-dao 1871b82
Clean up unused code in editor
badgeth-dao f5bae4d
Figuring out how to create our home-brew UUID extension
badgeth-dao ae61e50
ID generation working
badgeth-dao 6a3604e
Update test
badgeth-dao 9290320
Fixing re-render and id problem
badgeth-dao f82dd14
Remove unused packages
badgeth-dao d34e011
Ensure paste works for editor
badgeth-dao f8ccffb
Make name property from EntityStore computed
badgeth-dao d289bd4
Remove unneeded memoization and guard statement
badgeth-dao b36ff25
Remove uneeded useEffect
badgeth-dao 63e6ce1
Rebuilt
badgeth-dao 6e97e6c
Merge branch 'master' into tip-tap-editor
badgeth-dao 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
Wire up Docker to TipTap's private registry
commit a2958f25f8699734f369c340f68633e6b635cfdb
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -6,5 +6,4 @@ build | |
.turbo | ||
dist | ||
.env | ||
.npmrc | ||
|
This file contains 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,2 @@ | ||
@tiptap-pro:registry=https://registry.tiptap.dev/ | ||
//registry.tiptap.dev/:_authToken=${NPM_TOKEN} |
43 changes: 43 additions & 0 deletions
43
apps/web/modules/components/entity/editor/editor-utils.tsx
This file contains 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,43 @@ | ||
import { Extensions, generateHTML, JSONContent } from '@tiptap/react'; | ||
import TurndownService from 'turndown'; | ||
|
||
const turndownService = new TurndownService(); | ||
|
||
interface TiptapNode { | ||
content: string; | ||
nodeName?: string; | ||
type?: string; | ||
attrs?: Record<string, unknown>; | ||
} | ||
|
||
export const tiptapJsonToTriples = ({ | ||
content, | ||
extensions, | ||
spaceId, | ||
entityId, | ||
}: { | ||
content: JSONContent[]; | ||
extensions: Extensions; | ||
spaceId: string; | ||
entityId: string; | ||
}) => { | ||
/* We are converting TipTap text nodes to a markdown representation for backwards compatibility */ | ||
|
||
return content.map(node => { | ||
if (node.type === 'tableNode') { | ||
return node; | ||
} else { | ||
const html = generateHTML({ type: 'doc', content: [node] }, extensions); | ||
const nodeNameLength = 20; | ||
const nodeName = htmlToPlainText(html).slice(0, nodeNameLength); | ||
const markdown = turndownService.turndown(html); | ||
return { ...node, content: markdown, nodeName }; | ||
} | ||
}); | ||
}; | ||
|
||
export const htmlToPlainText = (html: string) => { | ||
const div = document.createElement('div'); | ||
div.innerHTML = html; | ||
return div.textContent || ''; | ||
}; |
This file contains 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 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 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
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'm making changes to the main |
This file contains 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 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 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 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 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
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.
useEditor takes a dependency array - I think there's potential for problems if entityStore.editorJson isn't fully hydrated by the time we reach this point.
We don't always want editorJson as a dependency however, since it will update onBlur and defocus and close our command popover triggered by the "/" or the "+" button.
Will know if this is a problem once we put it into our actual entity page.