Skip to content

Commit

Permalink
测试添加package
Browse files Browse the repository at this point in the history
  • Loading branch information
jss-less-step committed Nov 29, 2023
1 parent 3f029b9 commit 9268034
Show file tree
Hide file tree
Showing 21 changed files with 231 additions and 18 deletions.
2 changes: 1 addition & 1 deletion apps/e2e-examples/tsconfig.tsbuildinfo

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions apps/www/public/registry/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,15 @@
],
"type": "components:plate-ui"
},
{
"name": "demo1",
"dependencies": [],
"registryDependencies": [],
"files": [
"plate-ui/demo1.tsx"
],
"type": "components:plate-ui"
},
{
"name": "dialog",
"dependencies": [
Expand Down
12 changes: 12 additions & 0 deletions apps/www/public/registry/styles/default/demo1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "demo1",
"dependencies": [],
"registryDependencies": [],
"files": [
{
"name": "demo1.tsx",
"content": "import React from 'react';\nimport { PlateElement, PlateElementProps, Value } from '@udecode/plate-common';\n\n\nimport { cn } from '@/lib/utils';\n\nconst Demo1Element = React.forwardRef<\n React.ElementRef<typeof PlateElement>,\n PlateElementProps<Value, any>\n>(({ className, children, ...props }, ref) => {\n return (\n <PlateElement\n asChild\n ref={ref}\n className={cn(\n 'font-medium text-primary underline decoration-primary underline-offset-4',\n className\n )}\n {...(props as any)}\n >\n\n <strong>{children} <span>demo1</span></strong>\n </PlateElement>\n );\n});\nDemo1Element.displayName = 'Demo1Element';\n\nexport { Demo1Element };"
}
],
"type": "components:plate-ui"
}
7 changes: 7 additions & 0 deletions apps/www/src/__registry__/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,13 @@ export const Index: Record<string, any> = {
files: ['registry/default/plate-ui/cursor-overlay.tsx'],
component: React.lazy(() => import('@/registry/default/plate-ui/cursor-overlay')),
},
'demo1': {
name: 'demo1',
type: 'components:plate-ui',
registryDependencies: [],
files: ['registry/default/plate-ui/demo1.tsx'],
component: React.lazy(() => import('@/registry/default/plate-ui/demo1')),
},
'dialog': {
name: 'dialog',
type: 'components:plate-ui',
Expand Down
5 changes: 3 additions & 2 deletions apps/www/src/components/settings-combobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const categories = [
customizerPlugins.table,
customizerPlugins.todoli,
customizerPlugins.trailingblock,
customizerPlugins.demo1
],
},
];
Expand Down Expand Up @@ -122,8 +123,8 @@ export function SettingsCombobox() {
valuePlugins.forEach((pluginKey) => {
const deps = (
customizerItems[pluginKey] as
| SettingPlugin
| undefined
| SettingPlugin
| undefined
)?.dependencies;

deps?.forEach((dep) => {
Expand Down
8 changes: 8 additions & 0 deletions apps/www/src/config/customizer-plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
import { KEY_CAPTION } from '@udecode/plate-caption';
import { KEY_COMBOBOX } from '@udecode/plate-combobox';
import { MARK_COMMENT } from '@udecode/plate-comments';
import { ELEMENT_DEMO1 } from '@udecode/plate-demo1';
import { KEY_DND } from '@udecode/plate-dnd';
import { KEY_EMOJI } from '@udecode/plate-emoji';
import { ELEMENT_EXCALIDRAW } from '@udecode/plate-excalidraw';
Expand Down Expand Up @@ -338,4 +339,11 @@ export const customizerPlugins = {
route: '/docs/trailing-block',
plugins: [KEY_TRAILING_BLOCK],
},
demo1:{
id:'demo1',
label:'demo1',
value:'demo1',
route: '/docs/todo-list',
plugins:[ELEMENT_DEMO1]
}
};
4 changes: 3 additions & 1 deletion apps/www/src/lib/plate/create-plate-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ import { TableElement } from '@/registry/default/plate-ui/table-element';
import { TableRowElement } from '@/registry/default/plate-ui/table-row-element';
import { TodoListElement } from '@/registry/default/plate-ui/todo-list-element';
import { withDraggables } from '@/registry/default/plate-ui/with-draggables';

import {ELEMENT_DEMO1,createDemo1Plugin} from '@udecode/plate-demo1'
import { Demo1Element } from '@/registry/default/plate-ui/demo1';
export const createPlateUI = (
overrideByKey?: Partial<Record<string, PlatePluginComponent>>,
{
Expand Down Expand Up @@ -124,6 +125,7 @@ export const createPlateUI = (
[MARK_SUPERSCRIPT]: withProps(PlateLeaf, { as: 'sup' }),
[MARK_UNDERLINE]: withProps(PlateLeaf, { as: 'u' }),
[MARK_COMMENT]: CommentLeaf,
[ELEMENT_DEMO1]:Demo1Element
};

if (overrideByKey) {
Expand Down
12 changes: 9 additions & 3 deletions apps/www/src/registry/default/example/playground-demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ import { Editor } from '@/registry/default/plate-ui/editor';
import { FixedToolbar } from '@/registry/default/plate-ui/fixed-toolbar';
import { FloatingToolbar } from '@/registry/default/plate-ui/floating-toolbar';
import { MentionCombobox } from '@/registry/default/plate-ui/mention-combobox';
import { createDemo1Plugin } from '@udecode/plate-demo1';

export const usePlaygroundPlugins = ({
id,
Expand Down Expand Up @@ -251,6 +252,7 @@ export const usePlaygroundPlugins = ({
createDeserializeDocxPlugin({ enabled: !!enabled.deserializeDocx }),
createDeserializeMdPlugin({ enabled: !!enabled.deserializeMd }),
createJuicePlugin({ enabled: !!enabled.juice }),
createDemo1Plugin(),
],
{
components,
Expand Down Expand Up @@ -300,13 +302,17 @@ export default function PlaygroundDemo({ id }: { id?: ValueId }) {
}
),
});

return (
<DndProvider backend={HTML5Backend}>
<div className="relative">
<Plate
key={key}
initialValue={initialValue}
initialValue={[{
children: [
{ text: '' }
],
type: 'demo1'
}]}
plugins={plugins}
normalizeInitialValue
>
Expand All @@ -327,7 +333,7 @@ export default function PlaygroundDemo({ id }: { id?: ValueId }) {
'[&_.slate-start-area-top]:!h-4',
'[&_.slate-start-area-left]:!w-3 [&_.slate-start-area-right]:!w-3',
!id &&
'md:[&_.slate-start-area-left]:!w-[64px] md:[&_.slate-start-area-right]:!w-[64px]'
'md:[&_.slate-start-area-left]:!w-[64px] md:[&_.slate-start-area-right]:!w-[64px]'
)}
>
<Editor
Expand Down
28 changes: 28 additions & 0 deletions apps/www/src/registry/default/plate-ui/demo1.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react';
import { PlateElement, PlateElementProps, Value } from '@udecode/plate-common';


import { cn } from '@/lib/utils';

const Demo1Element = React.forwardRef<
React.ElementRef<typeof PlateElement>,
PlateElementProps<Value, any>
>(({ className, children, ...props }, ref) => {
return (
<PlateElement
asChild
ref={ref}
className={cn(
'font-medium text-primary underline decoration-primary underline-offset-4',
className
)}
{...(props as any)}
>

<strong>{children} <span>demo1</span></strong>
</PlateElement>
);
});
Demo1Element.displayName = 'Demo1Element';

export { Demo1Element };
8 changes: 8 additions & 0 deletions apps/www/src/registry/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@ const ui: Registry = [
registryDependencies: [],
files: ['plate-ui/cursor-overlay.tsx'],
},
{
name: 'demo1',
type: 'components:plate-ui',
dependencies: [],
registryDependencies: [],
files: ['plate-ui/demo1.tsx'],
},
{
name: 'dialog',
type: 'components:plate-ui',
Expand Down Expand Up @@ -712,6 +719,7 @@ const example: Registry = [
external: true,
files: ['types/plate-types.ts'],
},

];

export const registry: Registry = [...ui, ...example];
1 change: 1 addition & 0 deletions config/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const silent = false;

const PACKAGE_ROOT_PATH = process.cwd();
const INPUT_FILE_PATH = path.join(PACKAGE_ROOT_PATH, 'src/index.ts');
console.log(process.cwd());
const INPUT_FILE = fs.existsSync(INPUT_FILE_PATH)
? INPUT_FILE_PATH
: path.join(PACKAGE_ROOT_PATH, 'src/index.tsx');
Expand Down
3 changes: 2 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"import": "./dist/index.mjs",
"module": "./dist/index.mjs",
"require": "./dist/index.js"
}
},
"./package.json": "./package.json"
},
"scripts": {
"build": "yarn p:build",
Expand Down
3 changes: 3 additions & 0 deletions packages/demo1/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
__tests__
__test-utils__
__mocks__
11 changes: 11 additions & 0 deletions packages/demo1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# demo1



## Documentation

WIP

## License

[MIT](../../LICENSE)
59 changes: 59 additions & 0 deletions packages/demo1/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"name": "@udecode/plate-demo1",
"version": "26.0.3",
"description": "demo1",
"license": "MIT",
"homepage": "https://platejs.org",
"repository": {
"type": "git",
"url": "https://github.com/udecode/plate.git",
"directory": "packages/demo1"
},
"bugs": {
"url": "https://github.com/udecode/plate/issues"
},
"sideEffects": false,
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [
"dist/**/*"
],
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"module": "./dist/index.mjs",
"require": "./dist/index.js"
}
},
"scripts": {
"build": "yarn p:build",
"build:watch": "yarn p:build:watch",
"brl": "yarn p:brl",
"lint": "yarn p:lint",
"lint:fix": "yarn p:lint:fix",
"test": "yarn p:test",
"test:watch": "yarn p:test:watch",
"typecheck": "yarn p:typecheck"
},
"dependencies": {
"@udecode/plate-common": "25.0.1"
},
"peerDependencies": {
"react": ">=16.8.0",
"react-dom": ">=16.8.0",
"slate": ">=0.94.0",
"slate-history": ">=0.93.0",
"slate-hyperscript": ">=0.66.0",
"slate-react": ">=0.99.0"
},
"keywords": [
"plate",
"plugin",
"slate"
],
"publishConfig": {
"access": "public"
}
}
29 changes: 29 additions & 0 deletions packages/demo1/src/createDemo1Plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {
createPluginFactory,
HotkeyPlugin,
onKeyDownToggleElement,
} from '@udecode/plate-common';

export const ELEMENT_DEMO1 = 'demo1';

/**
* Enables support for paragraphs.
*/
export const createDemo1Plugin = createPluginFactory<HotkeyPlugin>({
key: ELEMENT_DEMO1,
isElement: true,
handlers: {
onKeyDown: onKeyDownToggleElement,
},
options: {
hotkey: ['mod+opt+0', 'mod+shift+0'],
},
deserializeHtml: {
rules: [
{
validNodeName: 'P',
},
],
query: (el) => el.style.fontFamily !== 'Consolas',
},
});
2 changes: 2 additions & 0 deletions packages/demo1/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

export * from './createDemo1Plugin'
8 changes: 8 additions & 0 deletions packages/demo1/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../../config/tsconfig.build.json",
"compilerOptions": {
"declarationDir": "./dist",
"outDir": "./dist"
},
"include": ["src"]
}
6 changes: 4 additions & 2 deletions packages/plate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"import": "./dist/index.mjs",
"module": "./dist/index.mjs",
"require": "./dist/index.js"
}
},
"./package.json": "./package.json"
},
"scripts": {
"build": "yarn p:build",
Expand Down Expand Up @@ -79,7 +80,8 @@
"@udecode/plate-suggestion": "25.0.1",
"@udecode/plate-tabbable": "25.0.1",
"@udecode/plate-table": "26.0.3",
"@udecode/plate-trailing-block": "25.0.1"
"@udecode/plate-trailing-block": "25.0.1",
"@udecode/plate-demo1": "26.0.3"
},
"peerDependencies": {
"react": ">=16.8.0",
Expand Down
1 change: 1 addition & 0 deletions packages/plate/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ export * from '@udecode/plate-tabbable';
export * from '@udecode/plate-table';
export * from '@udecode/plate-trailing-block';
export * from '@udecode/plate-resizable';
export * from '@udecode/plate-demo1';
Loading

0 comments on commit 9268034

Please sign in to comment.