Skip to content

Commit

Permalink
👷
Browse files Browse the repository at this point in the history
  • Loading branch information
zbeyens committed Oct 1, 2023
1 parent 81e1564 commit 22e7849
Show file tree
Hide file tree
Showing 41 changed files with 113 additions and 142 deletions.
8 changes: 7 additions & 1 deletion apps/www/src/app/_components/installation-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,13 @@ export default function InstallationTab() {
'',
...componentImportsGroup,
].join('\n');
}, [componentImports, customImports, groupedImportsByPackage, plateImports]);
}, [
componentImports,
customImports,
groupedImportsByPackage,
hasEditor,
plateImports,
]);

const pluginsCode: string[] = [];

Expand Down
7 changes: 1 addition & 6 deletions apps/www/src/lib/plate/demo/plugins/TabbableElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import React, { CSSProperties } from 'react';
import { PlateElementProps } from '@udecode/plate-common';
import { useFocused, useSelected } from 'slate-react';

import { MyValue } from '@/types/plate-types';

const boxStyle: CSSProperties = {
padding: '8px',
marginBottom: '8px',
Expand All @@ -19,10 +17,7 @@ const selectedBoxStyle: CSSProperties = {
border: '2px solid blue',
};

export function TabbableElement({
attributes,
children,
}: PlateElementProps<MyValue>) {
export function TabbableElement({ attributes, children }: PlateElementProps) {
const selected = useSelected();
const focused = useFocused();

Expand Down
5 changes: 2 additions & 3 deletions apps/www/src/lib/plate/demo/plugins/alignPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { PlatePlugin } from '@udecode/plate-common';
import {
ELEMENT_H1,
ELEMENT_H2,
Expand All @@ -8,9 +9,7 @@ import {
} from '@udecode/plate-heading';
import { ELEMENT_PARAGRAPH } from '@udecode/plate-paragraph';

import { MyPlatePlugin } from '@/types/plate-types';

export const alignPlugin: Partial<MyPlatePlugin> = {
export const alignPlugin: Partial<PlatePlugin> = {
inject: {
props: {
validTypes: [
Expand Down
7 changes: 2 additions & 5 deletions apps/www/src/lib/plate/demo/plugins/autoformatPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { AutoformatPlugin } from '@udecode/plate-autoformat';

import { MyEditor, MyPlatePlugin, MyValue } from '@/types/plate-types';
import { PlatePlugin } from '@udecode/plate-common';

import { autoformatLists } from './autoformatLists';
import { autoformatRules } from './autoformatRules';

export const autoformatPlugin: Partial<
MyPlatePlugin<AutoformatPlugin<MyValue, MyEditor>>
> = {
export const autoformatPlugin: Partial<PlatePlugin<AutoformatPlugin>> = {
options: {
rules: [...autoformatRules, ...autoformatLists] as any,
enableUndoOnDelete: true,
Expand Down
5 changes: 2 additions & 3 deletions apps/www/src/lib/plate/demo/plugins/basicElementsPlugins.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { plateUI } from '@/plate/demo/plateUI';
import { createBlockquotePlugin } from '@udecode/plate-block-quote';
import { createCodeBlockPlugin } from '@udecode/plate-code-block';
import { createPlugins } from '@udecode/plate-common';
import { createHeadingPlugin } from '@udecode/plate-heading';
import { createParagraphPlugin } from '@udecode/plate-paragraph';

import { createMyPlugins } from '@/types/plate-types';

export const basicElementsPlugins = createMyPlugins(
export const basicElementsPlugins = createPlugins(
[
createBlockquotePlugin(),
createCodeBlockPlugin(),
Expand Down
5 changes: 2 additions & 3 deletions apps/www/src/lib/plate/demo/plugins/basicMarksPlugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import {
createSuperscriptPlugin,
createUnderlinePlugin,
} from '@udecode/plate-basic-marks';
import { createPlugins } from '@udecode/plate-common';

import { createMyPlugins } from '@/types/plate-types';

export const basicMarksPlugins = createMyPlugins(
export const basicMarksPlugins = createPlugins(
[
createBoldPlugin(),
createCodePlugin(),
Expand Down
5 changes: 2 additions & 3 deletions apps/www/src/lib/plate/demo/plugins/basicNodesPlugins.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { plateUI } from '@/plate/demo/plateUI';

import { createMyPlugins } from '@/types/plate-types';
import { createPlugins } from '@udecode/plate-common';

import { basicElementsPlugins } from './basicElementsPlugins';
import { basicMarksPlugins } from './basicMarksPlugins';

export const basicNodesPlugins = createMyPlugins(
export const basicNodesPlugins = createPlugins(
[...basicElementsPlugins, ...basicMarksPlugins],
{
components: plateUI,
Expand Down
5 changes: 2 additions & 3 deletions apps/www/src/lib/plate/demo/plugins/captionPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { CaptionPlugin } from '@udecode/plate-caption';
import { PlatePlugin } from '@udecode/plate-common';
import { ELEMENT_IMAGE, ELEMENT_MEDIA_EMBED } from '@udecode/plate-media';

import { MyPlatePlugin } from '@/types/plate-types';

export const captionPlugin: Partial<MyPlatePlugin<CaptionPlugin>> = {
export const captionPlugin: Partial<PlatePlugin<CaptionPlugin>> = {
options: {
pluginKeys: [ELEMENT_IMAGE, ELEMENT_MEDIA_EMBED],
},
Expand Down
5 changes: 2 additions & 3 deletions apps/www/src/lib/plate/demo/plugins/dragOverCursorPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { findEventRange } from '@udecode/plate-common';
import { findEventRange, PlatePlugin } from '@udecode/plate-common';

import { MyPlatePlugin } from '@/types/plate-types';
import { cursorStore } from '@/registry/default/plate-ui/cursor-overlay';

export const KEY_DRAG_OVER_CURSOR = 'dragOverCursor';

export const dragOverCursorPlugin: MyPlatePlugin = {
export const dragOverCursorPlugin: PlatePlugin = {
key: KEY_DRAG_OVER_CURSOR,
handlers: {
onDragOver: (editor) => (event) => {
Expand Down
4 changes: 2 additions & 2 deletions apps/www/src/lib/plate/demo/plugins/emojiPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { PlatePlugin } from '@udecode/plate-common';
import { EmojiPlugin } from '@udecode/plate-emoji';

import { MyPlatePlugin } from '@/types/plate-types';
import { EmojiCombobox } from '@/registry/default/plate-ui/emoji-combobox';

export const emojiPlugin: Partial<MyPlatePlugin<EmojiPlugin>> = {
export const emojiPlugin: Partial<PlatePlugin<EmojiPlugin>> = {
renderAfterEditable: EmojiCombobox,
};
5 changes: 2 additions & 3 deletions apps/www/src/lib/plate/demo/plugins/exitBreakPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { ExitBreakPlugin } from '@udecode/plate-break';
import { PlatePlugin } from '@udecode/plate-common';
import { KEYS_HEADING } from '@udecode/plate-heading';

import { MyPlatePlugin } from '@/types/plate-types';

export const exitBreakPlugin: Partial<MyPlatePlugin<ExitBreakPlugin>> = {
export const exitBreakPlugin: Partial<PlatePlugin<ExitBreakPlugin>> = {
options: {
rules: [
{
Expand Down
14 changes: 6 additions & 8 deletions apps/www/src/lib/plate/demo/plugins/forcedLayoutPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { PlatePlugin } from '@udecode/plate-common';
import { ELEMENT_H1 } from '@udecode/plate-heading';
import { NormalizeTypesPlugin } from '@udecode/plate-normalizers';

import { MyPlatePlugin } from '@/types/plate-types';

export const forcedLayoutPlugin: Partial<MyPlatePlugin<NormalizeTypesPlugin>> =
{
options: {
rules: [{ path: [0], strictType: ELEMENT_H1 }],
},
};
export const forcedLayoutPlugin: Partial<PlatePlugin<NormalizeTypesPlugin>> = {
options: {
rules: [{ path: [0], strictType: ELEMENT_H1 }],
},
};
5 changes: 2 additions & 3 deletions apps/www/src/lib/plate/demo/plugins/imagePlugins.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { plateUI } from '@/plate/demo/plateUI';
import { createBasicElementsPlugin } from '@udecode/plate-basic-elements';
import { createComboboxPlugin } from '@udecode/plate-combobox';
import { createPlugins } from '@udecode/plate-core';
import { createImagePlugin } from '@udecode/plate-media';
import { createSelectOnBackspacePlugin } from '@udecode/plate-select';

import { createMyPlugins } from '@/types/plate-types';

import { basicMarksPlugins } from './basicMarksPlugins';
import { selectOnBackspacePlugin } from './selectOnBackspacePlugin';

export const imagePlugins = createMyPlugins(
export const imagePlugins = createPlugins(
[
createBasicElementsPlugin(),
...basicMarksPlugins,
Expand Down
5 changes: 2 additions & 3 deletions apps/www/src/lib/plate/demo/plugins/indentListPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ELEMENT_BLOCKQUOTE } from '@udecode/plate-block-quote';
import { ELEMENT_CODE_BLOCK } from '@udecode/plate-code-block';
import { PlatePlugin } from '@udecode/plate-common';
import {
ELEMENT_H1,
ELEMENT_H2,
Expand All @@ -11,9 +12,7 @@ import {
import { IndentListPlugin } from '@udecode/plate-indent-list';
import { ELEMENT_PARAGRAPH } from '@udecode/plate-paragraph';

import { MyPlatePlugin } from '@/types/plate-types';

export const indentListPlugin: Partial<MyPlatePlugin<IndentListPlugin>> = {
export const indentListPlugin: Partial<PlatePlugin<IndentListPlugin>> = {
inject: {
props: {
validTypes: [
Expand Down
5 changes: 2 additions & 3 deletions apps/www/src/lib/plate/demo/plugins/lineHeightPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { PlatePlugin } from '@udecode/plate-common';
import {
ELEMENT_H1,
ELEMENT_H2,
Expand All @@ -8,9 +9,7 @@ import {
} from '@udecode/plate-heading';
import { ELEMENT_PARAGRAPH } from '@udecode/plate-paragraph';

import { MyPlatePlugin } from '@/types/plate-types';

export const lineHeightPlugin: Partial<MyPlatePlugin> = {
export const lineHeightPlugin: Partial<PlatePlugin> = {
inject: {
props: {
defaultNodeValue: 1.5,
Expand Down
5 changes: 2 additions & 3 deletions apps/www/src/lib/plate/demo/plugins/linkPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { RenderAfterEditable } from '@udecode/plate-common';
import { PlatePlugin, RenderAfterEditable } from '@udecode/plate-common';
import { LinkPlugin } from '@udecode/plate-link';

import { MyPlatePlugin } from '@/types/plate-types';
import { LinkFloatingToolbar } from '@/registry/default/plate-ui/link-floating-toolbar';

export const linkPlugin: Partial<MyPlatePlugin<LinkPlugin>> = {
export const linkPlugin: Partial<PlatePlugin<LinkPlugin>> = {
renderAfterEditable: LinkFloatingToolbar as RenderAfterEditable,
};
5 changes: 2 additions & 3 deletions apps/www/src/lib/plate/demo/plugins/resetBlockTypePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ import {
import {
isBlockAboveEmpty,
isSelectionAtBlockStart,
PlatePlugin,
} from '@udecode/plate-common';
import { ELEMENT_TODO_LI } from '@udecode/plate-list';
import { ELEMENT_PARAGRAPH } from '@udecode/plate-paragraph';
import { ResetNodePlugin } from '@udecode/plate-reset-node';

import { MyPlatePlugin } from '@/types/plate-types';

const resetBlockTypesCommonRule = {
types: [ELEMENT_BLOCKQUOTE, ELEMENT_TODO_LI],
defaultType: ELEMENT_PARAGRAPH,
Expand All @@ -26,7 +25,7 @@ const resetBlockTypesCodeBlockRule = {
onReset: unwrapCodeBlock,
};

export const resetBlockTypePlugin: Partial<MyPlatePlugin<ResetNodePlugin>> = {
export const resetBlockTypePlugin: Partial<PlatePlugin<ResetNodePlugin>> = {
options: {
rules: [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { PlatePlugin } from '@udecode/plate-common';
import { ELEMENT_HR } from '@udecode/plate-horizontal-rule';
import { ELEMENT_IMAGE } from '@udecode/plate-media';
import { SelectOnBackspacePlugin } from '@udecode/plate-select';

import { MyPlatePlugin } from '@/types/plate-types';

export const selectOnBackspacePlugin: Partial<
MyPlatePlugin<SelectOnBackspacePlugin>
PlatePlugin<SelectOnBackspacePlugin>
> = {
options: {
query: {
Expand Down
5 changes: 2 additions & 3 deletions apps/www/src/lib/plate/demo/plugins/softBreakPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { ELEMENT_BLOCKQUOTE } from '@udecode/plate-block-quote';
import { SoftBreakPlugin } from '@udecode/plate-break';
import { ELEMENT_CODE_BLOCK } from '@udecode/plate-code-block';
import { PlatePlugin } from '@udecode/plate-common';
import { ELEMENT_TD } from '@udecode/plate-table';

import { MyPlatePlugin } from '@/types/plate-types';

export const softBreakPlugin: Partial<MyPlatePlugin<SoftBreakPlugin>> = {
export const softBreakPlugin: Partial<PlatePlugin<SoftBreakPlugin>> = {
options: {
rules: [
{ hotkey: 'shift+enter' },
Expand Down
10 changes: 6 additions & 4 deletions apps/www/src/lib/plate/demo/plugins/tabbablePlugin.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { ELEMENT_CODE_BLOCK } from '@udecode/plate-code-block';
import { isSelectionAtBlockStart, someNode } from '@udecode/plate-common';
import {
isSelectionAtBlockStart,
PlatePlugin,
someNode,
} from '@udecode/plate-common';
import { KEY_LIST_STYLE_TYPE } from '@udecode/plate-indent-list';
import { ELEMENT_LI } from '@udecode/plate-list';
import { TabbablePlugin } from '@udecode/plate-tabbable';
import { ELEMENT_TABLE } from '@udecode/plate-table';

import { MyPlatePlugin } from '@/types/plate-types';

import { TabbableElement } from './TabbableElement';

const TABBABLE_ELEMENT = 'tabbable_element';

export const tabbablePlugin: Partial<MyPlatePlugin<TabbablePlugin>> = {
export const tabbablePlugin: Partial<PlatePlugin<TabbablePlugin>> = {
options: {
query: (editor) => {
if (isSelectionAtBlockStart(editor)) return false;
Expand Down
10 changes: 4 additions & 6 deletions apps/www/src/lib/plate/demo/plugins/trailingBlockPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { PlatePlugin } from '@udecode/plate-common';
import { ELEMENT_PARAGRAPH } from '@udecode/plate-paragraph';
import { TrailingBlockPlugin } from '@udecode/plate-trailing-block';

import { MyPlatePlugin } from '@/types/plate-types';

export const trailingBlockPlugin: Partial<MyPlatePlugin<TrailingBlockPlugin>> =
{
options: { type: ELEMENT_PARAGRAPH },
};
export const trailingBlockPlugin: Partial<PlatePlugin<TrailingBlockPlugin>> = {
options: { type: ELEMENT_PARAGRAPH },
};
5 changes: 2 additions & 3 deletions apps/www/src/lib/plate/demo/values/commentsValue.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { TComment } from '@udecode/plate-comments';

import { MyValue } from '@/types/plate-types';
import { Value } from '@udecode/plate-common';

export const usersData = {
1: {
Expand Down Expand Up @@ -53,7 +52,7 @@ export const commentsData: Record<string, TComment> = {
},
};

export const commentsValue: MyValue = [
export const commentsValue: Value = [
{
type: 'h2',
children: [{ text: '💬 Comments' }],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @jsxRuntime classic */
import { TDescendant } from '@udecode/plate-common';
import { TDescendant, Value } from '@udecode/plate-common';
/** @jsx jsx */
import { jsx } from '@udecode/plate-test-utils';

Expand Down Expand Up @@ -37,5 +37,5 @@ export const createHugeDocumentValue = () => {
}
}

return hugeDocument;
return hugeDocument as Value;
};
5 changes: 2 additions & 3 deletions apps/www/src/lib/plate/demo/values/suggestionValue.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Value } from '@udecode/plate-common';
import { SuggestionUser, TSuggestion } from '@udecode/plate-suggestion';

import { MyValue } from '@/types/plate-types';

export const usersData: Record<string, SuggestionUser> = {
1: {
id: '1',
Expand Down Expand Up @@ -32,7 +31,7 @@ export const suggestionsData: Record<string, TSuggestion> = {
},
};

export const suggestionValue: MyValue = [
export const suggestionValue: Value = [
{
type: 'p',
children: [
Expand Down
4 changes: 2 additions & 2 deletions apps/www/src/lib/plate/demo/values/usePlaygroundValue.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useMemo } from 'react';
import { mapNodeId } from '@/plate/demo/mapNodeId';
import { Value } from '@udecode/plate-common';

import { MyValue } from '@/types/plate-types';
import { customizerPlugins, ValueId } from '@/config/customizer-plugins';
import { settingsStore } from '@/components/context/settings-store';

Expand Down Expand Up @@ -96,7 +96,7 @@ export const usePlaygroundValue = (id?: ValueId) => {
if (enabled.trailingBlock) value.push(...trailingBlockValue);
if (enabled.excalidraw) value.push(...excalidrawValue);

return mapNodeId(value) as MyValue;
return mapNodeId(value) as Value;
}, [
enabled.a,
enabled.action_item,
Expand Down
Loading

0 comments on commit 22e7849

Please sign in to comment.