Skip to content

Commit

Permalink
Merge pull request #44 from raralabs/dev
Browse files Browse the repository at this point in the history
release: sync from dev to main
  • Loading branch information
devibhattaraii authored May 4, 2023
2 parents d35cc8f + a885574 commit e40b75a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 31 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
- [x] Code
- [x] Checklist
- [x] Copy from html
- [ ] Text Align
- [ ] Mention
- [x] Text Align
- [x] Mention
- [ ] Ordered List
- [ ] Unordered List
- [ ] Nested List
Expand Down
34 changes: 10 additions & 24 deletions src/components/Elements/Leaf.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,16 @@
import * as React from 'react';
// import { CustomTextElement } from '../../types';
// import { ElementProps } from './Element';
import { RenderLeafProps } from 'slate-react';
import { RaraEditorType } from '../../types';

interface LeafProps extends RenderLeafProps {
editor:RaraEditorType
}

const Leaf = ({ attributes, children, leaf }:LeafProps) => {

// declare module 'slate-react' {
// interface ColumnMeta<TData extends RowData, TValue> {
// column?: ColumnDef<TData, TValue>;
// isNumeric?: boolean;
// width?: number | string;
// Footer?: {
// colspan?: number;
// display?: 'none';
// };
// }
// }
// interface LeafProps {
// attributes?: ElementProps
// children?: React.ReactNode;
// leaf?:CustomTextElement
// element?:any
// text?:CustomTextElement
// }//need to extend the leaf props to RenderLeafProps

////need to fix leafProps to any
const Leaf = ({ attributes, children, leaf }:any) => {
if (leaf?.bold) {
children = <strong>{children}</strong>;
children = <strong>{children}</strong>;
}
if (leaf?.code) {
children = <code>{children}</code>;
Expand All @@ -48,7 +34,7 @@ const Leaf = ({ attributes, children, leaf }:any) => {
{children}
</span>
);
}
}
// if (leaf.placeholder) {
// return (
// <>
Expand Down
7 changes: 3 additions & 4 deletions src/components/RaraEditor/RaraEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ const RaraEditor = (props: RaraEditorProps) => {
]
);
const renderLeaf = React.useCallback(
(props: RenderLeafProps) => <Leaf {...props} />,
(props: RenderLeafProps) => <Leaf {...props} editor={editor}/>,
[]
);

Expand Down Expand Up @@ -243,7 +243,6 @@ const RaraEditor = (props: RaraEditorProps) => {
} else {
onChange && onChange(JSON.stringify(change));
}

//managing mention data

const edtr = editor.operations;
Expand All @@ -255,15 +254,15 @@ const RaraEditor = (props: RaraEditorProps) => {

const removeMentionUser = edtr.filter(
(e: BaseOperation): e is RemoveNodeOperation =>
e.type === 'remove_node' && (e?.node?.type === 'mention' || e?.node?.text === ""),
e.type === 'remove_node' && (e?.node?.type === 'mention' ||(e?.node?.type === 'mention' && e?.node?.text === "")),
);
const mentionContact = edtr.find(
(e: BaseOperation): e is BaseInsertNodeOperation =>
e.type === 'insert_node' && e?.node?.type === 'mentionContact'
);
const removeMentionContact = edtr.filter(
(e: BaseOperation): e is RemoveNodeOperation =>
e.type === 'remove_node' && (e?.node?.type === 'mentionContact' || e?.node?.text === "")
e.type === 'remove_node' && (e?.node?.type === 'mentionContact' || (e?.node?.type === 'mentionContact' && e?.node?.text === ""))
);
if (mentionUser) {
setMentionUsers((pre: any) => [...pre, mentionUser?.node?.id]);
Expand Down
6 changes: 5 additions & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ export type CustomTextElement = {
underline?: boolean;
type?: string;
children?: any[];
id?:string|number
id?:string|number;
code?:boolean;
color?:string;
highlight?:boolean
editor?:RaraEditorType
};

export type CodeElement = {
Expand Down

0 comments on commit e40b75a

Please sign in to comment.