-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd76d11
commit 5ef127e
Showing
7 changed files
with
1,280 additions
and
140 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const mongoose = require('mongoose') | ||
const { Schema } = mongoose | ||
|
||
const CommentSchema = new Schema( | ||
{ | ||
// reference_code would be parent ticket here | ||
reference_code: { type: String, index: true }, | ||
commment: { type: String }, | ||
}, | ||
{ | ||
timestamps: true, | ||
} | ||
) | ||
|
||
const Comment = mongoose.model('Comment', CommentSchema) | ||
|
||
module.exports = Comment |
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
// modified version of https://github.com/ianstormtaylor/slate/blob/main/site/examples/richtext.tsx | ||
import React, { useCallback, useMemo } from 'react' | ||
import isHotkey from 'is-hotkey' | ||
import { Editable, withReact, useSlate, Slate } from 'slate-react' | ||
import { | ||
Editor, | ||
Transforms, | ||
createEditor, | ||
Element as SlateElement, | ||
} from 'slate' | ||
import { withHistory } from 'slate-history' | ||
|
||
import { | ||
BlockButton, | ||
Button, | ||
Element, | ||
Icon, | ||
Leaf, | ||
MarkButton, | ||
TEXT_ALIGN_TYPES, | ||
Toolbar, | ||
isBlockActive, | ||
isMarkActive, | ||
toggleBlock, | ||
toggleMark, | ||
} from './SlateComponents' | ||
import { Box, Heading } from '@chakra-ui/react' | ||
|
||
const HOTKEYS = { | ||
'mod+b': 'bold', | ||
'mod+i': 'italic', | ||
'mod+u': 'underline', | ||
'mod+`': 'code', | ||
} | ||
|
||
const CommentSection = () => { | ||
const renderElement = useCallback((props) => <Element {...props} />, []) | ||
const renderLeaf = useCallback((props) => <Leaf {...props} />, []) | ||
const editor = useMemo(() => withHistory(withReact(createEditor())), []) | ||
|
||
return ( | ||
<Box mt="20px"> | ||
<Heading textAlign="center">Comment Section </Heading> | ||
<Slate editor={editor} initialValue={initialValue}> | ||
<Toolbar> | ||
<MarkButton format="bold" icon="format_bold" /> | ||
<MarkButton format="italic" icon="format_italic" /> | ||
<MarkButton format="underline" icon="format_underlined" /> | ||
<MarkButton format="code" icon="code" /> | ||
<BlockButton format="heading-one" icon="looks_one" /> | ||
<BlockButton format="heading-two" icon="looks_two" /> | ||
<BlockButton format="block-quote" icon="format_quote" /> | ||
<BlockButton | ||
format="numbered-list" | ||
icon="format_list_numbered" | ||
/> | ||
<BlockButton | ||
format="bulleted-list" | ||
icon="format_list_bulleted" | ||
/> | ||
<BlockButton format="left" icon="format_align_left" /> | ||
<BlockButton format="center" icon="format_align_center" /> | ||
<BlockButton format="right" icon="format_align_right" /> | ||
<BlockButton format="justify" icon="format_align_justify" /> | ||
</Toolbar> | ||
<Editable | ||
renderElement={renderElement} | ||
renderLeaf={renderLeaf} | ||
placeholder="Enter some rich text…" | ||
spellCheck | ||
autoFocus | ||
onKeyDown={(event) => { | ||
for (const hotkey in HOTKEYS) { | ||
if (isHotkey(hotkey, event)) { | ||
event.preventDefault() | ||
const mark = HOTKEYS[hotkey] | ||
toggleMark(editor, mark) | ||
} | ||
} | ||
}} | ||
/> | ||
</Slate> | ||
</Box> | ||
) | ||
} | ||
|
||
// example taken from https://github.com/ianstormtaylor/slate/blob/main/site/components.tsx | ||
// remove once dynamically fetched from backend | ||
const initialValue = [ | ||
{ | ||
type: 'paragraph', | ||
children: [ | ||
{ text: 'This is editable ' }, | ||
{ text: 'rich', bold: true }, | ||
{ text: ' text, ' }, | ||
{ text: 'much', italic: true }, | ||
{ text: ' better than a ' }, | ||
{ text: '<textarea>', code: true }, | ||
{ text: '!' }, | ||
], | ||
}, | ||
{ | ||
type: 'paragraph', | ||
children: [ | ||
{ | ||
text: "Since it's rich text, you can do things like turn a selection of text ", | ||
}, | ||
{ text: 'bold', bold: true }, | ||
{ | ||
text: ', or add a semantically rendered block quote in the middle of the page, like this:', | ||
}, | ||
], | ||
}, | ||
{ | ||
type: 'block-quote', | ||
children: [{ text: 'A wise quote.' }], | ||
}, | ||
{ | ||
type: 'paragraph', | ||
align: 'center', | ||
children: [{ text: 'Try it out for yourself!' }], | ||
}, | ||
] | ||
|
||
export default CommentSection |
Oops, something went wrong.