-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(web): add story text block (#653)
- Loading branch information
Showing
106 changed files
with
4,789 additions
and
45 deletions.
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
31 changes: 31 additions & 0 deletions
31
web/src/beta/features/Editor/StoryPanel/Block/builtin/Text/Editor.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,31 @@ | ||
import { debounce } from "lodash-es"; | ||
import { useMemo, useContext } from "react"; | ||
|
||
import RichTextEditor from "@reearth/beta/lib/lexical/RichTextEditor"; | ||
|
||
import { BlockContext } from "../common/Wrapper"; | ||
|
||
export type Props = { | ||
text?: string; | ||
onUpdate?: (text: string) => void; | ||
}; | ||
|
||
const TextBlockEditor: React.FC<Props> = ({ text, onUpdate }) => { | ||
const debouncedHandleTextUpdate = useMemo( | ||
() => (onUpdate ? debounce(onUpdate, 1000) : undefined), | ||
[onUpdate], | ||
); | ||
|
||
const context = useContext(BlockContext); | ||
|
||
return ( | ||
<RichTextEditor | ||
editMode={!!context?.editMode} | ||
text={text} | ||
onChange={debouncedHandleTextUpdate} | ||
scrollableContainerId="story-page" | ||
/> | ||
); | ||
}; | ||
|
||
export default TextBlockEditor; |
29 changes: 22 additions & 7 deletions
29
web/src/beta/features/Editor/StoryPanel/Block/builtin/Text/index.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
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
29 changes: 29 additions & 0 deletions
29
web/src/beta/features/Editor/StoryPanel/Block/builtin/common/usePropertyValueUpdate.ts
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,29 @@ | ||
import { useCallback } from "react"; | ||
|
||
import { ValueType, ValueTypes } from "@reearth/beta/utils/value"; | ||
import { usePropertyFetcher } from "@reearth/services/api"; | ||
|
||
// Unlick common story blocks which will use the auto generted field components editor, | ||
// Some special story blocks will use the custom editor components and need to update date directly. | ||
export default () => { | ||
const { useUpdatePropertyValue } = usePropertyFetcher(); | ||
|
||
const handlePropertyValueUpdate = useCallback( | ||
( | ||
schemaGroupId: string, | ||
propertyId: string, | ||
fieldId: string, | ||
vt: ValueType, | ||
itemId?: string, | ||
) => { | ||
return async (v?: ValueTypes[ValueType]) => { | ||
await useUpdatePropertyValue(propertyId, schemaGroupId, itemId, fieldId, "en", v, vt); | ||
}; | ||
}, | ||
[useUpdatePropertyValue], | ||
); | ||
|
||
return { | ||
handlePropertyValueUpdate, | ||
}; | ||
}; |
3 changes: 3 additions & 0 deletions
3
web/src/beta/lib/lexical/RichTextEditor/images/icons/3-columns.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions
5
web/src/beta/lib/lexical/RichTextEditor/images/icons/LICENSE.md
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,5 @@ | ||
Bootstrap Icons | ||
https://icons.getbootstrap.com | ||
|
||
Licensed under MIT license | ||
https://github.com/twbs/icons/blob/main/LICENSE.md |
1 change: 1 addition & 0 deletions
1
web/src/beta/lib/lexical/RichTextEditor/images/icons/arrow-clockwise.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
web/src/beta/lib/lexical/RichTextEditor/images/icons/arrow-counterclockwise.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
web/src/beta/lib/lexical/RichTextEditor/images/icons/bg-color.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
web/src/beta/lib/lexical/RichTextEditor/images/icons/camera.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
web/src/beta/lib/lexical/RichTextEditor/images/icons/card-checklist.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
web/src/beta/lib/lexical/RichTextEditor/images/icons/caret-right-fill.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
web/src/beta/lib/lexical/RichTextEditor/images/icons/chat-left-text.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
web/src/beta/lib/lexical/RichTextEditor/images/icons/chat-right-dots.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
web/src/beta/lib/lexical/RichTextEditor/images/icons/chat-right-text.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
web/src/beta/lib/lexical/RichTextEditor/images/icons/chat-right.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
web/src/beta/lib/lexical/RichTextEditor/images/icons/chat-square-quote.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
web/src/beta/lib/lexical/RichTextEditor/images/icons/chevron-down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
web/src/beta/lib/lexical/RichTextEditor/images/icons/clipboard.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
web/src/beta/lib/lexical/RichTextEditor/images/icons/comments.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
web/src/beta/lib/lexical/RichTextEditor/images/icons/diagram-2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
web/src/beta/lib/lexical/RichTextEditor/images/icons/download.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
web/src/beta/lib/lexical/RichTextEditor/images/icons/draggable-block-menu.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
web/src/beta/lib/lexical/RichTextEditor/images/icons/dropdown-more.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.