@blocklet/editor 2.3.80 → 2.3.82

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +0,0 @@
1
- export interface LottieProps {
2
- src: any;
3
- }
4
- export default function LottieComp({ src }: LottieProps): import("react/jsx-runtime").JSX.Element;
@@ -1,6 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { lazyRetry as lazy } from '@arcblock/ux/lib/Util';
3
- const Lottie = lazy(() => import('lottie-react'));
4
- export default function LottieComp({ src }) {
5
- return _jsx(Lottie, { animationData: src, loop: true });
6
- }
@@ -1,4 +0,0 @@
1
- import { AiImagePromptProps } from './context';
2
- export default function Prompt({ onSubmit }: {
3
- onSubmit: (value: AiImagePromptProps) => void;
4
- }): import("react/jsx-runtime").JSX.Element;
@@ -1,122 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- /* eslint-disable no-return-assign */
3
- import styled from '@emotion/styled';
4
- import { cx } from '@emotion/css';
5
- import { useReactive, useDebounceFn } from 'ahooks';
6
- import Slider from '@mui/material/Slider';
7
- import Typography from '@mui/material/Typography';
8
- import Box from '@mui/material/Box';
9
- import Button from '@mui/material/Button';
10
- import TextField from '@mui/material/TextField';
11
- import Grid from '@mui/material/Grid';
12
- import { useAiImageContext } from './context';
13
- const marks = [
14
- {
15
- label: 1024,
16
- value: 1024,
17
- },
18
- ];
19
- function valueLabelFormat(value) {
20
- return marks.findIndex((mark) => mark.value === value) + 1;
21
- }
22
- export default function Prompt({ onSubmit }) {
23
- const { loading } = useAiImageContext();
24
- const values = useReactive({
25
- prompt: '',
26
- sizeWidth: 1024,
27
- number: 1,
28
- });
29
- const submit = () => {
30
- const submitValue = JSON.parse(JSON.stringify(values));
31
- const v = Object.values(values);
32
- const allValued = v.every((param) => !!param);
33
- if (allValued) {
34
- onSubmit(submitValue);
35
- }
36
- };
37
- const { run } = useDebounceFn(submit, { wait: 500 });
38
- return (_jsxs(Root, { onSubmit: (e) => e.preventDefault(), children: [_jsx(Box, { sx: { flex: 1, overflowY: 'auto', overflowX: 'hidden' }, children: _jsxs(Grid, { container: true, gap: 2.5, children: [_jsxs(Grid, { item: true, xs: 12, children: [_jsx(Typography, { gutterBottom: true, className: "title label", children: "Prompt" }), _jsx(TextField, { sx: { width: 1, mt: 1 }, size: "small", type: "text", required: true, label: "Prompt", placeholder: "Please enter Prompt", multiline: true, minRows: 5, value: values.prompt ?? '', onChange: (e) => (values.prompt = e.target.value), inputProps: { maxLength: 1000 } })] }), _jsxs(Grid, { item: true, xs: 12, children: [_jsx(Typography, { gutterBottom: true, className: "title label", children: `Resolution: ${values.sizeWidth}px × ${values.sizeWidth}px` }), _jsx(Grid, { container: true, sx: { gap: 2.5, pt: 1 }, children: _jsx(Box, { flex: 1, children: _jsx(Box, { width: "90%", ml: "5%", children: _jsx(Slider, { size: "small", valueLabelDisplay: "off", marks: marks, min: 256, max: 1024, defaultValue: 512, value: values.sizeWidth, onChange: (e, newValue) => (values.sizeWidth = Number(newValue)), valueLabelFormat: valueLabelFormat, step: null }) }) }) })] }), _jsxs(Grid, { item: true, xs: 12, children: [_jsx(Typography, { gutterBottom: true, className: "title label", children: `Number of images: ${values.number}` }), _jsx(Box, { width: "90%", ml: "5%", children: _jsx(Slider, { size: "small", defaultValue: 1, valueLabelDisplay: "auto", step: 1, min: 1, max: 10, value: values.number, onChange: (e, newValue) => (values.number = Number(newValue)) }) })] })] }) }), _jsx(Button, { className: cx('submit-ai'), type: "submit", variant: "contained", onClick: run, disabled: loading, style: { transition: 'all 0.3s' }, children: loading ? 'Generate...' : 'Generate' })] }));
39
- }
40
- const Root = styled(Box) `
41
- display: flex;
42
- flex-direction: column;
43
- height: 100%;
44
-
45
- .title {
46
- padding: 0 0 8px 1px;
47
- }
48
-
49
- .label {
50
- font-weight: 500;
51
- font-size: 15px;
52
- line-height: 100%;
53
- margin: 0;
54
- word-wrap: break-word;
55
- text-align: left;
56
- }
57
-
58
- > .submit-ai {
59
- height: 43px;
60
- width: 100%;
61
- background: linear-gradient(90deg, #45e4fa 0%, #8a45fa 52.08%, #fa45bc 100%);
62
- border-radius: 30px;
63
- box-shadow: none;
64
- text-transform: none;
65
-
66
- &.Mui-disabled {
67
- color: rgba(0, 0, 0, 0.26);
68
- background: rgba(0, 0, 0, 0.12);
69
- }
70
- }
71
-
72
- .MuiFormHelperText-root {
73
- font-style: normal;
74
- font-weight: 500;
75
- font-size: 12px;
76
- line-height: 14px;
77
- color: #9397a1;
78
- margin: 0;
79
- margin-top: 4px;
80
- }
81
-
82
- .MuiOutlinedInput-root {
83
- background: #fbfbfb;
84
- border-radius: 4px;
85
-
86
- fieldset {
87
- border: 1px solid #f6f6f6;
88
- }
89
-
90
- &:hover fieldset {
91
- border: 1px solid #a482fe;
92
- }
93
- }
94
-
95
- .Mui-focused {
96
- &.MuiFormLabel-root {
97
- color: #a482fe;
98
- }
99
-
100
- &.MuiOutlinedInput-root {
101
- fieldset {
102
- border: 1px solid #a482fe;
103
- }
104
- }
105
- }
106
-
107
- .Mui-error {
108
- &.MuiFormLabel-root {
109
- color: #f16e6e;
110
- }
111
-
112
- &.MuiOutlinedInput-root + .MuiFormHelperText-root {
113
- color: #f16e6e;
114
- }
115
-
116
- &.MuiOutlinedInput-root {
117
- fieldset {
118
- border: 1px solid #f16e6e;
119
- }
120
- }
121
- }
122
- `;
@@ -1,3 +0,0 @@
1
- export { default as AiImagePlugin, INSERT_AI_IMAGE_COMMAND } from './plugin';
2
- export { default as AiImageModal } from './node';
3
- export { blockletExists, isExistAiKit } from './util';
@@ -1,3 +0,0 @@
1
- export { default as AiImagePlugin, INSERT_AI_IMAGE_COMMAND } from './plugin';
2
- export { default as AiImageModal } from './node';
3
- export { blockletExists, isExistAiKit } from './util';
@@ -1,5 +0,0 @@
1
- interface Props {
2
- onClose: () => void;
3
- }
4
- declare function AiImage({ onClose }: Props): import("react/jsx-runtime").JSX.Element;
5
- export default AiImage;
@@ -1,23 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useEffect } from 'react';
3
- import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
4
- import Generate from './generate';
5
- import { useEditorConfig } from '../../config';
6
- import { INSERT_AI_IMAGE_COMMAND } from './plugin';
7
- function AiImage({ onClose }) {
8
- const [editor] = useLexicalComposerContext();
9
- const { AI } = useEditorConfig();
10
- useEffect(() => {
11
- setTimeout(() => {
12
- editor.blur();
13
- }, 0);
14
- }, [editor]);
15
- const onSelect = (data) => {
16
- if (data.length) {
17
- editor.dispatchCommand(INSERT_AI_IMAGE_COMMAND, data);
18
- }
19
- onClose();
20
- };
21
- return _jsx(Generate, { onSelect: onSelect, api: AI?.imageGenerations });
22
- }
23
- export default AiImage;
@@ -1,5 +0,0 @@
1
- import { LexicalCommand } from 'lexical';
2
- type ImagePayload = string[];
3
- export declare const INSERT_AI_IMAGE_COMMAND: LexicalCommand<ImagePayload>;
4
- declare function AiImagePlugin(): null;
5
- export default AiImagePlugin;
@@ -1,24 +0,0 @@
1
- import { $createParagraphNode, $insertNodes, $isRootOrShadowRoot, COMMAND_PRIORITY_EDITOR, createCommand, } from 'lexical';
2
- import { $wrapNodeInElement, mergeRegister } from '@lexical/utils';
3
- import { useEffect } from 'react';
4
- import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
5
- import { $createImageNode } from '../../main/nodes/ImageNode';
6
- export const INSERT_AI_IMAGE_COMMAND = createCommand('INSERT_AI_IMAGE_COMMAND');
7
- function AiImagePlugin() {
8
- const [editor] = useLexicalComposerContext();
9
- useEffect(() => {
10
- return mergeRegister(editor.registerCommand(INSERT_AI_IMAGE_COMMAND, (payload) => {
11
- const $imageNodes = payload.map((item) => {
12
- return $createImageNode({ src: item, altText: item });
13
- });
14
- $insertNodes($imageNodes);
15
- const lastImageNode = $imageNodes[$imageNodes.length - 1];
16
- if ($isRootOrShadowRoot(lastImageNode.getParentOrThrow())) {
17
- $wrapNodeInElement(lastImageNode, $createParagraphNode).selectEnd();
18
- }
19
- return true;
20
- }, COMMAND_PRIORITY_EDITOR));
21
- }, [editor]);
22
- return null;
23
- }
24
- export default AiImagePlugin;
@@ -1,3 +0,0 @@
1
- declare const blockletExists: (name: string) => boolean;
2
- declare const isExistAiKit: () => boolean;
3
- export { blockletExists, isExistAiKit };
@@ -1,8 +0,0 @@
1
- const getBlockletMountPointInfo = (name) => {
2
- return window.blocklet?.componentMountPoints?.find((x) => x.name === name);
3
- };
4
- const blockletExists = (name) => {
5
- return !!getBlockletMountPointInfo(name);
6
- };
7
- const isExistAiKit = () => blockletExists('ai-kit');
8
- export { blockletExists, isExistAiKit };