Skip to content

Commit

Permalink
ci
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfeng33 committed Feb 9, 2025
1 parent c313d2d commit dcbb56b
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 62 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { CodePlugin ,
SkipMarkPlugin,
} from "@udecode/plate-basic-marks/react";
import { CommentsPlugin } from "@udecode/plate-comments/react";
import { SuggestionPlugin } from "@udecode/plate-suggestion/react";

import { CodePlugin, SkipMarkPlugin } from '@udecode/plate-basic-marks/react';
import { CommentsPlugin } from '@udecode/plate-comments/react';
import { SuggestionPlugin } from '@udecode/plate-suggestion/react';

export const skipMarkPlugin = SkipMarkPlugin.configure({
options: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@





import { SuggestionPlugin } from '@udecode/plate-suggestion/react';

import { renderSuggestionBelowNodes } from '@/registry/default/plate-ui/suggestion-line-break';


export const suggestionPlugin = SuggestionPlugin.extend({
options: {
currentUserId: 'testId',
Expand Down
9 changes: 6 additions & 3 deletions apps/www/src/registry/default/examples/playground-demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,12 @@ export default function PlaygroundDemo({ className }: { className?: string }) {
);

return (
<Plate onValueChange={({ value }) => {
console.log(value, 'fj')
}} editor={editor}>
<Plate
onValueChange={({ value }) => {
console.log(value, 'fj');
}}
editor={editor}
>
<EditorContainer className={className}>
<Editor variant="demo" className="pb-[20vh]" spellCheck={false} />
</EditorContainer>
Expand Down
17 changes: 5 additions & 12 deletions apps/www/src/registry/default/plate-ui/block-comments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ const BlockCommentsContent = ({
setOption('uniquePathMap', new Map(map).set(id, blockPath));
});



const resolvedSuggestion: ResolvedSuggestion[] = useMemo(() => {
const map = getOption('uniquePathMap');

Expand Down Expand Up @@ -216,7 +214,7 @@ const BlockCommentsContent = ({
case 'update': {
updateProps = {
...updateProps,
...data. properties,
...data.properties,
};

newText += node.text;
Expand Down Expand Up @@ -296,9 +294,9 @@ const BlockCommentsContent = ({
return res;
}, [blockPath, editor.api, getOption, suggestionNodes]);

const discussions:any[] = []
const discussions: any[] = [];

const activeDiscussion = -1
const activeDiscussion = -1;

const suggestionsCount = resolvedSuggestion.length;

Expand All @@ -320,8 +318,6 @@ const BlockCommentsContent = ({
const [_open, setOpen] = React.useState(selected);
const open = _open || selected;



const anchorElement = useMemo(() => {
// const domNode = editor.api.toDOMNode(element)!;

Expand All @@ -335,14 +331,11 @@ const BlockCommentsContent = ({

// return editor.api.toDOMNode(activeNode[0])!;

return document.body
return document.body;
// // eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

if (
suggestionsCount + discussions.length === 0
)
return <>{children}</>;
if (suggestionsCount + discussions.length === 0) return <>{children}</>;

return (
<div ref={ref} className="flex w-full justify-between">
Expand Down
27 changes: 12 additions & 15 deletions apps/www/src/registry/default/plate-ui/suggestion-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ import { CheckIcon, XIcon } from 'lucide-react';

import { Button } from './button';

export interface ResolvedSuggestion extends TResolvedSuggestion {
}
export interface ResolvedSuggestion extends TResolvedSuggestion {}

export const LINE_BREAK_SUGGESTION = '__line_break__';

Expand All @@ -45,24 +44,22 @@ export const BlockSuggestionCard = ({
isLast: boolean;
suggestion: ResolvedSuggestion;
}) => {

// const { data: userData } = useQuery(
// trpc.user.getUser.queryOptions({ id: suggestion.userId })
// );

const { api, editor } = useEditorPlugin(SuggestionPlugin);

const accept = (suggestion: ResolvedSuggestion) => {
api.suggestion.withoutSuggestions(()=>{
acceptSuggestion(editor, suggestion );
})
api.suggestion.withoutSuggestions(() => {
acceptSuggestion(editor, suggestion);
});
};

const reject = (suggestion: ResolvedSuggestion) => {
api.suggestion.withoutSuggestions(()=>{
rejectSuggestion(editor, suggestion );
})

api.suggestion.withoutSuggestions(() => {
rejectSuggestion(editor, suggestion);
});
};

const [hovering, setHovering] = useState(false);
Expand All @@ -71,14 +68,14 @@ export const BlockSuggestionCard = ({
return (
<div
key={`${suggestion.suggestionId}_${idx}`}
className="relative "
className="relative"
onMouseEnter={() => setHovering(true)}
onMouseLeave={() => setHovering(false)}
>
<div className="flex flex-col p-4">
<div className="relative flex items-center">
{/* <CommentAvatar user={userData} /> */}
<h4 className="text-sm font-semibold leading-none">
<h4 className="text-sm leading-none font-semibold">
{/* {userData?.name} */}
</h4>
<div className="ml-1.5 text-xs leading-none text-muted-foreground/80">
Expand All @@ -88,7 +85,7 @@ export const BlockSuggestionCard = ({
</div>
</div>

<div className="relative mb-4 mt-1 pl-[32px] ">
<div className="relative mt-1 mb-4 pl-[32px]">
<div className="flex flex-col gap-2">
{suggestion.type === 'remove' && (
<React.Fragment>
Expand Down Expand Up @@ -136,7 +133,7 @@ export const BlockSuggestionCard = ({
key={index}
className="flex items-center text-brand/80"
>
<span className="text-sm ">with:</span>
<span className="text-sm">with:</span>
<span className="text-sm">{text || 'line breaks'}</span>
</div>
</React.Fragment>
Expand Down Expand Up @@ -185,7 +182,7 @@ export const BlockSuggestionCard = ({
))} */}

{hovering && (
<div className="absolute right-4 top-4 flex gap-2">
<div className="absolute top-4 right-4 flex gap-2">
<Button
variant="ghost"
className="h-6 p-1 text-muted-foreground"
Expand Down
12 changes: 9 additions & 3 deletions apps/www/src/registry/default/plate-ui/suggestion-leaf.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@ export function SuggestionLeaf(props: PlateLeafProps) {
const { setOption } = useEditorPlugin(SuggestionPlugin);

const leafId: string = getSuggestionId(leaf) ?? '';
const activeSuggestionId = usePluginOption(SuggestionPlugin, 'activeSuggestionId');
const hoverSuggestionId = usePluginOption(SuggestionPlugin, 'hoverSuggestionId');
const activeSuggestionId = usePluginOption(
SuggestionPlugin,
'activeSuggestionId'
);
const hoverSuggestionId = usePluginOption(
SuggestionPlugin,
'hoverSuggestionId'
);
const hasRemove = getSuggestionDataList(leaf).some(
(data) => data.type === 'remove'
);
Expand Down Expand Up @@ -49,7 +55,7 @@ export function SuggestionLeaf(props: PlateLeafProps) {
as={Component}
className={cn(
'border-b-2 border-b-brand/[.24] bg-brand/[.08] text-brand/80 no-underline transition-colors duration-200',
(hasActive || hasHover) && 'border-b-brand/[.60] bg-brand/[.13]',
(hasActive || hasHover) && 'border-b-brand/[.60] bg-brand/[.13]',
hasRemove &&
'border-b-gray-300 bg-gray-300/25 text-gray-400 line-through',
(hasActive || hasHover) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ export const renderSuggestionBelowNodes = ({

if (!lineBreakData) return;

return function Component({
children,
}: {
children: React.ReactNode;
}) {
return function Component({ children }: { children: React.ReactNode }) {
return (
<React.Fragment>
{children}
Expand Down Expand Up @@ -57,10 +53,8 @@ const SuggestionLineBreak = ({
const isActive = activeSuggestionId === lineBreakData.id;
const isHover = hoverSuggestionId === lineBreakData.id;


const spanRef = useRef<HTMLSpanElement>(null);


return (
<span
ref={spanRef}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function SuggestionToolbarButton() {

return (
<ToolbarButton
className={cn(isSuggesting && 'text-brand/80 ')}
className={cn(isSuggesting && 'text-brand/80')}
onClick={() => setOption('isSuggesting', !isSuggesting)}
onMouseDown={(e) => e.preventDefault()}
tooltip={isSuggesting ? 'Turn off suggesting' : 'Suggestion edits'}
Expand Down
20 changes: 13 additions & 7 deletions packages/basic-marks/src/lib/BaseSkipMarkPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { type PluginConfig, type QueryNodeOptions, type Text, createTSlatePlugin, queryNode, RangeApi } from '@udecode/plate';
import {
type PluginConfig,
type QueryNodeOptions,
type Text,
createTSlatePlugin,
queryNode,
RangeApi,
} from '@udecode/plate';

export type SkipMarkConfig = PluginConfig<
'skip-mark',
Expand All @@ -7,26 +14,25 @@ export type SkipMarkConfig = PluginConfig<
}
>;


export const BaseSkipMarkPlugin = createTSlatePlugin<SkipMarkConfig>({
key: 'skip-mark',
options:{}
}).overrideEditor(({editor,getOption, tf: { insertText } }) => ({
options: {},
}).overrideEditor(({ editor, getOption, tf: { insertText } }) => ({
transforms: {
insertText(text, options) {
if (RangeApi.isExpanded(editor.selection))
return insertText(text, options);

const textNode = editor.api.node<Text>({
mode:"lowest",
mode: 'lowest',
});

const query = getOption("query");
const query = getOption('query');

if (
textNode &&
!queryNode(textNode, query) &&
editor.api.isEnd(editor.selection?.focus, textNode[1])
editor.api.isEnd(editor.selection?.focus, textNode[1])
) {
editor.tf.insertNode({ text });
const _nextPoint = editor.api.start(textNode[1], { next: true });
Expand Down
4 changes: 2 additions & 2 deletions packages/basic-marks/src/react/SkipMarkPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { toPlatePlugin } from "@udecode/plate/react";
import { toPlatePlugin } from '@udecode/plate/react';

import { BaseSkipMarkPlugin } from "../lib/BaseSkipMarkPlugin";
import { BaseSkipMarkPlugin } from '../lib/BaseSkipMarkPlugin';

export const SkipMarkPlugin = toPlatePlugin(BaseSkipMarkPlugin);

0 comments on commit dcbb56b

Please sign in to comment.