Skip to content

Commit 9b77e2f

Browse files
Small fixes post v0.7.0 (#101)
#101 * shortener tags fixed; Signed-off-by: Sahil Shubham <[email protected]> * fixed todos in readOnly editor; Signed-off-by: Sahil Shubham <[email protected]> * Added reminders info bar on the right; Signed-off-by: Sahil Shubham <[email protected]> * updated blockModal import; Signed-off-by: Sahil Shubham <[email protected]> * fix link hover overflow bug; Signed-off-by: Sahil Shubham <[email protected]> * fix block deletion; Signed-off-by: Sahil Shubham <[email protected]> * cross icon always in editor previews; Signed-off-by: Sahil Shubham <[email protected]> * fixed focus on click and scroll on outline click; Signed-off-by: Sahil Shubham <[email protected]> * now you can create reminders from combobox; Signed-off-by: Sahil Shubham <[email protected]> * a little better looking draft view; Signed-off-by: Sahil Shubham <[email protected]> * smaller reminders on webapp; Signed-off-by: Sahil Shubham <[email protected]>
1 parent b569950 commit 9b77e2f

File tree

29 files changed

+259
-146
lines changed

29 files changed

+259
-146
lines changed

apps/extension/src/Components/Editor/EditorPreview.tsx

+3-5
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,9 @@ const EditorPreview = ({
121121
</EditorPreviewNoteName>
122122
)}
123123
{/* <TagsRelatedTiny nodeid={nodeid} /> */}
124-
{allowClosePreview && (
125-
<Button transparent onClick={() => closePreview && closePreview()}>
126-
<Icon icon={closeCircleLine} />
127-
</Button>
128-
)}
124+
<Button transparent onClick={() => closePreview && closePreview()}>
125+
<Icon icon={closeCircleLine} />
126+
</Button>
129127
</EditorPreviewControls>
130128
)}
131129
<EditorPreviewEditorWrapper>

apps/webapp/src/Actions/Components/Shortener.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,15 @@ export const Shortener = () => {
128128
} else {
129129
const title = tags.filter((el) => el.name === 'title')[0].value.trim()
130130
if (!resultShortAlias) resultShortAlias = title
131-
setUserTags([
132-
{ id: nanoid(), text: title.toString().split('-').join(', ').split('|').join(', ').split(', ')[0] }
133-
])
131+
setUserTags([{ value: title.toString().split('-').join(', ').split('|').join(', ').split(', ')[0] }])
134132
setShort(resultShortAlias)
135133
}
136134
}
137135
}
138136
}
139137

140138
const removeUserTag = (tag: Tag) => {
141-
const updatedUserTags = userTags.filter((userTag) => tag.id !== userTag.id)
139+
const updatedUserTags = userTags.filter((userTag) => tag.value !== userTag.value)
142140
setUserTags(updatedUserTags)
143141
}
144142
useEffect(() => {

apps/webapp/src/Components/Editor/ContentEditor.tsx

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useMemo } from 'react'
1+
import React, { useEffect, useMemo, useRef } from 'react'
22
import { useParams } from 'react-router-dom'
33
import { usePlateEditorRef, selectEditor } from '@udecode/plate'
44
import shallow from 'zustand/shallow'
@@ -26,6 +26,7 @@ import { useLayoutStore } from '../../Stores/useLayoutStore'
2626

2727
const ContentEditor = () => {
2828
const { nodeId } = useParams()
29+
const editorWrapperRef = useRef<HTMLDivElement>(null)
2930

3031
const fetchingContent = useEditorStore((state) => state.fetchingContent)
3132
const setIsEditing = useEditorStore((store) => store.setIsEditing)
@@ -68,9 +69,19 @@ const ContentEditor = () => {
6869
const editorId = useMemo(() => getEditorId(node.nodeid, false), [node, fetchingContent])
6970
const editorRef = usePlateEditorRef()
7071

71-
const onFocusClick = () => {
72+
const onFocusClick = (ev) => {
73+
ev.preventDefault()
74+
ev.stopPropagation()
75+
7276
if (editorRef) {
73-
selectEditor(editorRef, { focus: true })
77+
if (editorWrapperRef.current) {
78+
const el = editorWrapperRef.current
79+
const hasScrolled = el.scrollTop > 0
80+
// mog('ElScroll', { hasScrolled })
81+
if (!hasScrolled) {
82+
selectEditor(editorRef, { focus: true })
83+
}
84+
}
7485
}
7586
}
7687

@@ -106,7 +117,7 @@ const ContentEditor = () => {
106117
<EditorInfoBar />
107118
{isBlockMode ? <BlockInfoBar /> : <Metadata node={node} />}
108119

109-
<EditorWrapper onClick={onFocusClick}>
120+
<EditorWrapper ref={editorWrapperRef} onMouseUpCapture={onFocusClick}>
110121
<Editor
111122
readOnly={readOnly}
112123
nodeUID={nodeId}

apps/webapp/src/Components/Editor/Editor.tsx

+19-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@ import { LinkElement, MediaEmbedElement, TableWrapper } from '@mexit/shared'
77

88
import TagWrapper from './TagWrapper'
99
import BallonMarkToolbarButtons from './BalloonToolbar/EditorBalloonToolbar'
10-
import { ELEMENT_ILINK, ELEMENT_INLINE_BLOCK, ELEMENT_TAG, ELEMENT_TODO_LI, NodeEditorContent } from '@mexit/core'
10+
import {
11+
ELEMENT_ILINK,
12+
ELEMENT_INLINE_BLOCK,
13+
ELEMENT_PARAGRAPH,
14+
ELEMENT_TAG,
15+
ELEMENT_TODO_LI,
16+
NodeEditorContent
17+
} from '@mexit/core'
1118
import Todo from '../Todo'
1219
import { useEditorChange } from '@mexit/shared'
1320
import { EditorStyles } from '@mexit/shared'
@@ -23,6 +30,7 @@ import { TagComboboxItem } from '../../Editor/Components/Tags/TagComboboxItem'
2330
import { QuickLinkComboboxItem } from '../../Editor/Components/QuickLink/QuickLinkComboboxItem'
2431
import components from '../../Editor/Components/EditorPreviewComponents'
2532
import { useNewNodes } from '../../Hooks/useNewNodes'
33+
import { useOpenReminderModal } from '../Reminders/CreateReminderModal'
2634

2735
const EditorWrapper = styled(EditorStyles)`
2836
flex: 1;
@@ -48,6 +56,8 @@ const Editor: React.FC<EditorProps> = ({ nodeUID, nodePath, content, readOnly, o
4856
const addILink = useDataStore((store) => store.addILink)
4957
const slashCommands = useDataStore((store) => store.slashCommands)
5058

59+
const { openReminderModal } = useOpenReminderModal()
60+
5161
const { getSnippetConfigs } = useSnippets()
5262

5363
const snippetConfigs = getSnippetConfigs()
@@ -138,6 +148,13 @@ const Editor: React.FC<EditorProps> = ({ nodeUID, nodePath, content, readOnly, o
138148
table: {
139149
slateElementType: ELEMENT_TABLE,
140150
command: 'table'
151+
},
152+
remind: {
153+
slateElementType: ELEMENT_PARAGRAPH,
154+
command: 'remind',
155+
onExtendedCommand: (newValue, editor) => {
156+
openReminderModal(newValue)
157+
}
141158
}
142159
}
143160
}
@@ -168,7 +185,7 @@ const Editor: React.FC<EditorProps> = ({ nodeUID, nodePath, content, readOnly, o
168185

169186
const editorOptions: MexEditorOptions = {
170187
editableProps: {
171-
readOnly: readOnly,
188+
readOnly,
172189
// placeholder: "Let's try something here...",
173190
autoFocus: true
174191
},

apps/webapp/src/Components/Editor/Toolbar.tsx

+14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react'
2+
import timerFlashLine from '@iconify/icons-ri/timer-flash-line'
23
import focusLine from '@iconify/icons-ri/focus-line'
34
import { useSingleton } from '@tippyjs/react'
45
import shareLine from '@iconify/icons-ri/share-line'
@@ -12,6 +13,7 @@ import { InfoTools, NodeInfo } from '@mexit/shared'
1213
import BookmarkButton from '../Buttons/BookmarkButton'
1314
import { useEditorStore } from '../../Stores/useEditorStore'
1415
import NodeRenameOnlyTitle from './Rename/NodeRename'
16+
import useToggleElements from '../../Hooks/useToggleElements'
1517

1618
const Toolbar = () => {
1719
const fetchingContent = useEditorStore((state) => state.fetchingContent)
@@ -21,8 +23,11 @@ const Toolbar = () => {
2123
const [source, target] = useSingleton()
2224
const shortcuts = useHelpStore((store) => store.shortcuts)
2325
const showShareOptions = useLayoutStore((store) => store.showShareOptions)
26+
const infobar = useLayoutStore((store) => store.infobar)
2427
const toggleShareOptions = useLayoutStore((store) => store.toggleShareOptions)
2528

29+
const { toggleReminder } = useToggleElements()
30+
2631
return (
2732
<NodeInfo {...getFocusProps(focusMode)}>
2833
<NodeRenameOnlyTitle />
@@ -42,6 +47,15 @@ const Toolbar = () => {
4247
<BookmarkButton nodeid={nodeid} />
4348
</span>
4449
</ToolbarTooltip> */}
50+
<IconButton
51+
size={24}
52+
singleton={target}
53+
icon={timerFlashLine}
54+
shortcut={shortcuts?.showReminder?.keystrokes}
55+
title="Reminders"
56+
highlight={infobar.mode === 'reminders'}
57+
onClick={toggleReminder}
58+
/>
4559
<IconButton
4660
singleton={target}
4761
size={24}

apps/webapp/src/Components/EditorInfobar/BlockInfobar.tsx

+33-33
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ import moveToIcon from '@iconify/icons-ri/anticlockwise-2-fill'
88
import useBlockStore from '../../Stores/useBlockStore'
99
import { Button, MexIcon } from '@mexit/shared'
1010
import { ButtonWrapper } from '../../Style/Settings'
11-
import { ContextMenuActionType } from "@mexit/core"
11+
import { ContextMenuActionType } from '@mexit/core'
1212

1313
export const PrimaryText = styled.span`
1414
color: ${({ theme }) => theme.colors.primary};
1515
`
1616

17-
1817
const BlockMenu = styled.div`
1918
display: flex;
2019
align-items: center;
2120
justify-content: space-between;
2221
2322
margin: 2px 0;
23+
z-index: 999999;
2424
2525
p {
2626
margin: 0;
@@ -29,39 +29,39 @@ const BlockMenu = styled.div`
2929
`
3030

3131
const BlockInfoBar = () => {
32-
const setIsModalOpen = useBlockStore((store) => store.setIsModalOpen)
33-
const isBlockMode = useBlockStore((store) => store.isBlockMode)
34-
const blocks = useBlockStore((store) => store.blocks)
35-
const setIsBlockMode = useBlockStore((store) => store.setIsBlockMode)
32+
const setIsModalOpen = useBlockStore((store) => store.setIsModalOpen)
33+
const isBlockMode = useBlockStore((store) => store.isBlockMode)
34+
const blocks = useBlockStore((store) => store.blocks)
35+
const setIsBlockMode = useBlockStore((store) => store.setIsBlockMode)
3636

37-
const theme = useTheme()
38-
const length = Object.values(blocks).length
39-
const blockHeading = length === 0 ? 'Select Blocks' : `Block${length > 1 ? 's' : ''} selected:`
37+
const theme = useTheme()
38+
const length = Object.values(blocks).length
39+
const blockHeading = length === 0 ? 'Select Blocks' : `Block${length > 1 ? 's' : ''} selected:`
4040

41-
return (
42-
<BlockMenu>
43-
<Button onClick={() => setIsBlockMode(!isBlockMode)}>
44-
<MexIcon fontSize={20} noHover color={theme.colors.primary} icon={xBold} /> Cancel
45-
</Button>
46-
<p>
47-
{blockHeading}
48-
{length > 0 && <PrimaryText>&#32;{length}</PrimaryText>}
49-
</p>
50-
<ButtonWrapper>
51-
<Button onClick={() => setIsModalOpen(ContextMenuActionType.move)}>
52-
<MexIcon fontSize={20} noHover color={theme.colors.primary} icon={moveToIcon} />
53-
Move
54-
</Button>
55-
<Button onClick={() => setIsModalOpen(ContextMenuActionType.send)}>
56-
<MexIcon fontSize={20} noHover color={theme.colors.primary} icon={sendToIcon} /> Send
57-
</Button>
58-
<Button onClick={() => setIsModalOpen(ContextMenuActionType.del)}>
59-
<MexIcon fontSize={20} noHover color={theme.colors.primary} icon={deleteBin6Line} />
60-
Delete
61-
</Button>
62-
</ButtonWrapper>
63-
</BlockMenu>
64-
)
41+
return (
42+
<BlockMenu>
43+
<Button onClick={() => setIsBlockMode(!isBlockMode)}>
44+
<MexIcon fontSize={20} noHover color={theme.colors.primary} icon={xBold} /> Cancel
45+
</Button>
46+
<p>
47+
{blockHeading}
48+
{length > 0 && <PrimaryText>&#32;{length}</PrimaryText>}
49+
</p>
50+
<ButtonWrapper>
51+
<Button onClick={() => setIsModalOpen(ContextMenuActionType.move)}>
52+
<MexIcon fontSize={20} noHover color={theme.colors.primary} icon={moveToIcon} />
53+
Move
54+
</Button>
55+
<Button onClick={() => setIsModalOpen(ContextMenuActionType.send)}>
56+
<MexIcon fontSize={20} noHover color={theme.colors.primary} icon={sendToIcon} /> Send
57+
</Button>
58+
<Button onClick={() => setIsModalOpen(ContextMenuActionType.del)}>
59+
<MexIcon fontSize={20} noHover color={theme.colors.primary} icon={deleteBin6Line} />
60+
Delete
61+
</Button>
62+
</ButtonWrapper>
63+
</BlockMenu>
64+
)
6565
}
6666

6767
export default BlockInfoBar

apps/webapp/src/Components/EditorInfobar/PublicNodeMetadata.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const Data = styled.div`
1313
`
1414

1515
const PublicNodeMetadata = ({ metadata }) => {
16-
console.log(metadata)
16+
// console.log(metadata)
1717
const isEmpty =
1818
metadata &&
1919
metadata.createdAt === undefined &&

0 commit comments

Comments
 (0)