-
Notifications
You must be signed in to change notification settings - Fork 10
feat: store richtext data as HTML rather than a Prosemirror tree #1239
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
Merged
Merged
Changes from 36 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
f5d42cb
feat(serialization): add first pass at serialization
tefkah ce77fcd
feat(ui): add new show more component
tefkah 204fa4f
feat(serialization): add proper serialization libs
tefkah c33097f
refactor(serialization): parse and convert prosemirror tree during
tefkah 8f49b17
feat(fts|serialization): properly index html
tefkah d9f4f20
fix(serialization): sort of fix loading
tefkah e92f261
fix: fix weird redis install issue
tefkah 550c767
dev: make legacy seed have useful richtext
tefkah 71439d6
dev: make legacy seed have useful richtext
tefkah 642bbd1
feat(math): serialize math to mathml and back reliably
tefkah 9997e8f
feat(serialization): find a happy way to store html and serialize on …
tefkah 2b3c8b5
chore: remove old validation function, fix test
tefkah e5bf99f
fix: fix the stories
tefkah b83d855
fix: really fix math, cleanup
tefkah e2b5978
feat: add migration to clear current richtext values
tefkah 276fffe
Merge branch 'main' into tfk/html-richtext
tefkah 6c740c6
chore: meaningless change to trigger ci
tefkah 53bb547
fix: fix fts related type issues
tefkah 162b545
fix: fix contexteditor related type issues
tefkah 0ced401
chore: don't format html
tefkah 76e70e8
fix: fix test to work with figures
tefkah 7831b83
chore: revert and merge with main
tefkah ec44cc8
fix: modify tests
tefkah 39b0628
Merge branch 'main' into tfk/html-richtext
tefkah 829eb08
chore: remove silly console.log messages in cache layer
tefkah b892c62
refactor: move the html/prosemirror boundary to the form
tefkah 0dded00
chore: merge with main
tefkah 114206f
fix: handle no value for richtext
tefkah e0f038d
fix: use more predictable handling of temp richtext value, add explan…
tefkah 7a6ea14
refactor: get rid of forward ref, it is cringe
tefkah 971e977
Merge branch 'main' into tfk/html-richtext
tefkah 81d60fc
fix: make ref optional
tefkah 848a258
fix: use consolidate prosemirror/html conversion fns a bit
tefkah 1bbb209
Merge branch 'main' into tfk/html-richtext
tefkah 05564bd
docs: update rich text docs
tefkah a3d9614
fix: find math display correctly
tefkah 22c80b2
Merge branch 'main' into tfk/html-richtext
tefkah 25f761d
fix?: use localhost instead of docker-host for minio init
tefkah 3edd460
debug: add some logs
tefkah 4b4c059
fix?: upgrade aws?
tefkah 7ced2c4
fix(minio): use new minio client syntax after breaking change
tefkah 243d4ea
Merge branch 'main' into tfk/html-richtext
tefkah 9881d52
chore: merge
tefkah e77d8a5
chore: merge
tefkah 0aa25f9
fix: cave to erics CRAZY demands
tefkah 71984ef
fix: remove unnecessary memo
tefkah 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| app/c/\[communitySlug\]/developers/docs/stoplight.styles.css | ||
| vitest-bench.local.json | ||
| vitest-bench.local.json | ||
| **/*.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
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 |
|---|---|---|
| @@ -1,8 +1,9 @@ | ||
| "use client"; | ||
|
|
||
| import type { PropsWithChildren } from "react"; | ||
| import type { ContextEditorGetter } from "context-editor"; | ||
| import type { PropsWithChildren, RefObject } from "react"; | ||
|
|
||
| import { createContext, useContext, useState } from "react"; | ||
| import { createContext, useCallback, useContext, useMemo, useState } from "react"; | ||
|
|
||
| import type { ProcessedPub } from "contracts"; | ||
| import type { PubsId, PubTypesId } from "db/public"; | ||
|
|
@@ -14,11 +15,28 @@ export type ContextEditorContext = { | |
| pubTypes: GetPubTypesResult; | ||
| pubId?: PubsId; | ||
| pubTypeId?: PubTypesId; | ||
| /** | ||
| * Refs which are able to retrieve the current state of the context editor | ||
| * on demand, rather than having the form state manage the value (which is slower) | ||
| */ | ||
| contextEditorGetters: ContextEditorGetters; | ||
|
Collaborator
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. Good comments! |
||
| /** | ||
| * Register a new context editor getter, which is able to retrieve the current state of the context editor | ||
| * on demand, rather than having the form state manage the value (which is slower) | ||
| * @param key - The key to register the getter under | ||
| * @param ref - The ref to the context editor | ||
| */ | ||
| registerGetter: (key: string, ref: ContextEditorGetterRef) => void; | ||
| }; | ||
|
|
||
| export type ContextEditorGetterRef = RefObject<ContextEditorGetter | null>; | ||
| export type ContextEditorGetters = Record<string, ContextEditorGetterRef>; | ||
|
|
||
| const ContextEditorContext = createContext<ContextEditorContext>({ | ||
| pubs: [], | ||
| pubTypes: [], | ||
| contextEditorGetters: {}, | ||
| registerGetter: () => {}, | ||
| }); | ||
|
|
||
| export type ContextEditorPub = ProcessedPub<{ | ||
|
|
@@ -31,12 +49,33 @@ type Props = PropsWithChildren< | |
| } | ||
| >; | ||
|
|
||
| export const ContextEditorContextProvider = (props: Props) => { | ||
| const [cachedPubId] = useState(props.pubId); | ||
| export const ContextEditorContextProvider = ( | ||
| props: Omit<Props, "contextEditorGetters" | "registerGetter"> | ||
| ) => { | ||
| const cachedPubId = useMemo(() => { | ||
| return props.pubId; | ||
| }, [props.pubId]); | ||
|
|
||
| const [contextEditorGetters, setContextEditorGetters] = useState< | ||
| Record<string, ContextEditorGetterRef> | ||
| >({}); | ||
|
|
||
| const registerGetter = useCallback((key: string, ref: ContextEditorGetterRef) => { | ||
| setContextEditorGetters((prev) => ({ ...prev, [key]: ref })); | ||
| }, []); | ||
|
|
||
| const { children, pubId, pubs, ...value } = props; | ||
|
|
||
| return ( | ||
| <ContextEditorContext.Provider value={{ ...value, pubs, pubId: cachedPubId }}> | ||
| <ContextEditorContext.Provider | ||
| value={{ | ||
| ...value, | ||
| pubs, | ||
| pubId: cachedPubId, | ||
| contextEditorGetters, | ||
| registerGetter, | ||
| }} | ||
| > | ||
| {children} | ||
| </ContextEditorContext.Provider> | ||
| ); | ||
|
|
||
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.
ideally we wouldnt do manual check here, but have InputComponents maybe define some default
ReadOnlyversion of themselves which can be displayed here.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.
i might look into this here #1209