Skip to content
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

Public note copy url fix #264

Merged
merged 3 commits into from
Nov 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions apps/webapp/src/Components/EditorInfobar/Metadata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ const Metadata = ({
return usersWithStatus
}, [location, activeUsers, mentionable, namespaceId, nodeId])

const onNoteShareClick = (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
openShareModal('permission', 'note', nodeId)
}

if (!publicMetadata && (content === undefined || content.metadata === undefined || metadata === undefined || isEmpty))
return null

Expand Down Expand Up @@ -111,11 +115,14 @@ const Metadata = ({
{!publicMetadata && !hideShareDetails && (
<Data>
<AvatarGroups users={sharedUsers} limit={5} margin="0 1.5rem 0" />
<Menu values={<MexIcon noHover icon="bi:three-dots-vertical" width={20} height={20} />}>
<Menu
key={`Share-modal-menu-${nodeId}`}
values={<MexIcon noHover icon="bi:three-dots-vertical" width={20} height={20} />}
>
<MenuItem
key="share-menu"
icon={{ type: 'ICON', value: 'ri:share-line' }}
onClick={() => openShareModal('permission', 'note', nodeId)}
onClick={onNoteShareClick}
label="Share"
/>
</Menu>
Expand Down
16 changes: 8 additions & 8 deletions apps/webapp/src/Editor/Components/EditorPreviewComponents.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

import { createPlateUI, withProps } from '@udecode/plate'
import { StyledElement } from '@udecode/plate-styled-components'

import Todo from '../../Components/Todo'
import { QuickLinkElement } from './QuickLink/QuickLinkElement'
import { LinkElement, MediaEmbedElement, TableWrapper } from '@mexit/shared'
import InlineBlock from './InlineBlock'
import TagWrapper from '../../Components/Editor/TagWrapper'
import {
ELEMENT_ILINK,
ELEMENT_INLINE_BLOCK,
Expand All @@ -20,10 +14,16 @@ import {
ELEMENT_TASK_VIEW_LINK,
ELEMENT_TODO_LI
} from '@mexit/core'
import { LinkElement, MediaEmbedElement, TableWrapper } from '@mexit/shared'

import TagWrapper from '../../Components/Editor/TagWrapper'
import Todo from '../../Components/Todo'
import InlineBlock from './InlineBlock'
import { MentionElement } from './Mentions/MentionElement'
import { QuickLinkElement } from './QuickLink/QuickLinkElement'
import TaskViewLink from './TaskViewLink'

export const editorPreviewComponents = {
export const editorPreviewComponents = createPlateUI({
[ELEMENT_LINK]: withProps(LinkElement, {
as: 'a'
}),
Expand All @@ -41,7 +41,7 @@ export const editorPreviewComponents = {
[ELEMENT_TABLE]: TableWrapper,
[ELEMENT_MENTION]: MentionElement as any,
[ELEMENT_TASK_VIEW_LINK]: TaskViewLink as any
}
})

const components = createPlateUI({
...editorPreviewComponents,
Expand Down
22 changes: 19 additions & 3 deletions apps/webapp/src/Editor/Plugins/todoUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { getMentionsFromContent, getTagsFromContent, NodeEditorContent, TodoType } from "@mexit/core"
import { createTodo } from "../../Stores/useTodoStore"
import { ELEMENT_TODO_LI, getMentionsFromContent, getTagsFromContent, NodeEditorContent, TodoType } from '@mexit/core'

import { createTodo } from '../../Stores/useTodoStore'

export const createDefaultTodo = (nodeid: string, content?: NodeEditorContent): TodoType => {
const block = content?.[0]
Expand All @@ -8,5 +9,20 @@ export const createDefaultTodo = (nodeid: string, content?: NodeEditorContent):

const todo = createTodo(nodeid, block.id, content, tags, mentions)

return todo;
return todo
}

export const getTodoMetadata = (content: NodeEditorContent) => {
if (!content) return

const block = content[0]

if (block && block.type === ELEMENT_TODO_LI) {
const { priority, status, ...rest } = block

return {
priority,
status
}
}
}
6 changes: 4 additions & 2 deletions apps/webapp/src/Hooks/useUpdater.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getTodosFromContent, NodeEditorContent } from '@mexit/core'
import { getTodosFromContent, mog, NodeEditorContent } from '@mexit/core'
import { useSlashCommands } from '@mexit/shared'

import { useContentStore } from '../Stores/useContentStore'
Expand Down Expand Up @@ -31,7 +31,9 @@ export const useUpdater = () => {
if (metadata) setMetadata(noteId, metadata)
updateLinksFromContent(noteId, content)
updateTagsFromContent(noteId, content)
updateNodeTodos(noteId, getTodosFromContent(content))
const todos = getTodosFromContent(content)
mog('CONTENT FOR TODOS', { todos })
updateNodeTodos(noteId, todos)

updateDocument('node', noteId, content)
}
Expand Down
Loading