1- import { FC , useCallback , useEffect , useMemo , useState } from 'react'
1+ import { FC , useEffect , useState } from 'react'
22import { use100vh } from 'react-div-100vh'
33import MarkdownEditor , { Props } from 'rich-markdown-editor'
44import { useEditorTheme } from './theme'
55import useMounted from 'libs/web/hooks/use-mounted'
6- import useI18n from 'libs/web/hooks/use-i18n'
76import Tooltip from './tooltip'
87import extensions from './extensions'
98import EditorState from 'libs/web/state/editor'
109import { useToast } from 'libs/web/hooks/use-toast'
10+ import { useDictionary } from './dictionary'
11+ import { useEmbeds } from './embeds'
1112
1213export type EditorProps = Pick < Props , 'readOnly' >
1314
@@ -18,88 +19,18 @@ const Editor: FC<EditorProps> = ({ readOnly }) => {
1819 onClickLink,
1920 onUploadImage,
2021 onHoverLink,
21- onNoteChange ,
22+ onEditorChange ,
2223 backlinks,
2324 editorEl,
2425 note,
2526 } = EditorState . useContainer ( )
2627 const height = use100vh ( )
2728 const mounted = useMounted ( )
28- const { t } = useI18n ( )
2929 const editorTheme = useEditorTheme ( )
3030 const [ hasMinHeight , setHasMinHeight ] = useState ( true )
3131 const toast = useToast ( )
32-
33- const dictionary = useMemo (
34- ( ) => ( {
35- addColumnAfter : t ( 'Insert column after' ) ,
36- addColumnBefore : t ( 'Insert column before' ) ,
37- addRowAfter : t ( 'Insert row after' ) ,
38- addRowBefore : t ( 'Insert row before' ) ,
39- alignCenter : t ( 'Align center' ) ,
40- alignLeft : t ( 'Align left' ) ,
41- alignRight : t ( 'Align right' ) ,
42- bulletList : t ( 'Bulleted list' ) ,
43- checkboxList : t ( 'Todo list' ) ,
44- codeBlock : t ( 'Code block' ) ,
45- codeCopied : t ( 'Copied to clipboard' ) ,
46- codeInline : t ( 'Code' ) ,
47- createLink : t ( 'Create link' ) ,
48- createLinkError : t ( 'Sorry, an error occurred creating the link' ) ,
49- createNewDoc : t ( 'Create a new note' ) ,
50- deleteColumn : t ( 'Delete column' ) ,
51- deleteRow : t ( 'Delete row' ) ,
52- deleteTable : t ( 'Delete table' ) ,
53- deleteImage : t ( 'Delete image' ) ,
54- alignImageLeft : t ( 'Float left half width' ) ,
55- alignImageRight : t ( 'Float right half width' ) ,
56- alignImageDefault : t ( 'Center large' ) ,
57- em : t ( 'Italic' ) ,
58- embedInvalidLink : t ( 'Sorry, that link won’t work for this embed type' ) ,
59- findOrCreateDoc : t ( 'Find or create a note…' ) ,
60- h1 : t ( 'Big heading' ) ,
61- h2 : t ( 'Medium heading' ) ,
62- h3 : t ( 'Small heading' ) ,
63- heading : t ( 'Heading' ) ,
64- hr : t ( 'Divider' ) ,
65- image : t ( 'Image' ) ,
66- imageUploadError : t ( 'Sorry, an error occurred uploading the image' ) ,
67- info : t ( 'Info' ) ,
68- infoNotice : t ( 'Info notice' ) ,
69- link : t ( 'Link' ) ,
70- linkCopied : t ( 'Link copied to clipboard' ) ,
71- mark : t ( 'Highlight' ) ,
72- newLineEmpty : t ( "Type '/' to insert…" ) ,
73- newLineWithSlash : t ( 'Keep typing to filter…' ) ,
74- noResults : t ( 'No results' ) ,
75- openLink : t ( 'Open link' ) ,
76- orderedList : t ( 'Ordered list' ) ,
77- pageBreak : t ( 'Page break' ) ,
78- pasteLink : t ( 'Paste a link…' ) ,
79- pasteLinkWithTitle : ( title : string ) : string =>
80- t ( `Paste a {{title}} link…` , { title } ) ,
81- placeholder : t ( 'Placeholder' ) ,
82- quote : t ( 'Quote' ) ,
83- removeLink : t ( 'Remove link' ) ,
84- searchOrPasteLink : t ( 'Search or paste a link…' ) ,
85- strikethrough : t ( 'Strikethrough' ) ,
86- strong : t ( 'Bold' ) ,
87- subheading : t ( 'Subheading' ) ,
88- table : t ( 'Table' ) ,
89- tip : t ( 'Tip' ) ,
90- tipNotice : t ( 'Tip notice' ) ,
91- warning : t ( 'Warning' ) ,
92- warningNotice : t ( 'Warning notice' ) ,
93- } ) ,
94- [ t ]
95- )
96-
97- const onEditorChange = useCallback (
98- ( value : ( ) => string ) : void => {
99- onNoteChange . callback ( { content : value ( ) } )
100- } ,
101- [ onNoteChange ]
102- )
32+ const dictionary = useDictionary ( )
33+ const embeds = useEmbeds ( )
10334
10435 useEffect ( ( ) => {
10536 setHasMinHeight ( ( backlinks ?. length ?? 0 ) <= 0 )
@@ -124,6 +55,7 @@ const Editor: FC<EditorProps> = ({ readOnly }) => {
12455 tooltip = { Tooltip }
12556 extensions = { extensions }
12657 className = "px-4 md:px-0"
58+ embeds = { embeds }
12759 />
12860 < style jsx global > { `
12961 .ProseMirror ul {
@@ -150,7 +82,7 @@ const Editor: FC<EditorProps> = ({ readOnly }) => {
15082 .ProseMirror h3 {
15183 font-size: 1.5em;
15284 }
153- .ProseMirror a {
85+ .ProseMirror a:not(.bookmark) {
15486 text-decoration: underline;
15587 }
15688 ` } </ style >
0 commit comments