@blocklet/editor 2.4.89 → 2.4.91
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.
- package/lib/blocklet-editor-viewer.d.ts +4 -0
- package/lib/blocklet-editor-viewer.js +12 -0
- package/lib/blocklet-editor.d.ts +2 -0
- package/lib/blocklet-editor.js +12 -0
- package/lib/ext/CustomComponent/CustomComponentNode.js +1 -0
- package/lib/ext/CustomComponent/components/Code.js +2 -1
- package/lib/ext/CustomComponent/components/Field.d.ts +9 -0
- package/lib/ext/CustomComponent/components/Field.js +32 -0
- package/lib/ext/CustomComponent/components/index.d.ts +2 -0
- package/lib/ext/CustomComponent/components/index.js +2 -0
- package/lib/ext/PagesKitComponent/PagesKitComponentRenderer.js +2 -2
- package/lib/index.d.ts +0 -3
- package/lib/index.js +2 -2
- package/lib/main/editor-root.d.ts +2 -0
- package/lib/main/editor-root.js +46 -0
- package/lib/main/hooks/use-mobile.d.ts +4 -0
- package/lib/main/hooks/use-mobile.js +6 -0
- package/lib/main/index.css +0 -954
- package/lib/main/index.d.ts +3 -0
- package/lib/main/index.js +7 -12
- package/lib/main/markdown-editor/index.js +1 -9
- package/lib/main/nodes/PlaygroundNodes.js +0 -2
- package/lib/main/style/editable.css +476 -0
- package/lib/main/themes/code-highlight/index.d.ts +2 -32
- package/lib/main/themes/code-highlight/index.js +10 -65
- package/lib/main/themes/customTheme.js +17 -18
- package/lib/main/viewer/index.d.ts +5 -0
- package/lib/main/viewer/index.js +26 -0
- package/lib/main/viewer/types.d.ts +14 -0
- package/lib/main/viewer/types.js +1 -0
- package/lib/main/viewer/viewer.d.ts +3 -0
- package/lib/main/viewer/viewer.js +30 -0
- package/lib/types.d.ts +2 -1
- package/package.json +4 -2
- package/lib/main/Settings.d.ts +0 -9
- package/lib/main/Settings.js +0 -39
- package/lib/main/plugins/KeywordsPlugin/index.d.ts +0 -9
- package/lib/main/plugins/KeywordsPlugin/index.js +0 -38
- package/lib/main/plugins/PasteLogPlugin/index.d.ts +0 -9
- package/lib/main/plugins/PasteLogPlugin/index.js +0 -34
- package/lib/main/plugins/TestRecorderPlugin/index.d.ts +0 -10
- package/lib/main/plugins/TestRecorderPlugin/index.js +0 -340
- package/lib/main/ui/Switch.d.ts +0 -15
- package/lib/main/ui/Switch.js +0 -6
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { EditorViewerProps } from './main/viewer/types';
|
|
2
|
+
export declare const BlockletEditorViewer: import("react-lazy-with-preload").PreloadableComponent<typeof import("./main/viewer").BlockletEditorViewer>;
|
|
3
|
+
export declare const useBlockletEditorViewerLoaded: () => boolean;
|
|
4
|
+
export type { EditorViewerProps };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { lazyWithPreload } from 'react-lazy-with-preload';
|
|
3
|
+
export const BlockletEditorViewer = lazyWithPreload(() => import('./main/viewer').then((m) => ({ default: m.BlockletEditorViewer })));
|
|
4
|
+
export const useBlockletEditorViewerLoaded = () => {
|
|
5
|
+
const [loaded, setLoaded] = useState(false);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
BlockletEditorViewer.preload().then(() => {
|
|
8
|
+
setLoaded(true);
|
|
9
|
+
});
|
|
10
|
+
}, []);
|
|
11
|
+
return loaded;
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { lazyWithPreload } from 'react-lazy-with-preload';
|
|
3
|
+
export const BlockletEditor = lazyWithPreload(() => import('./main'));
|
|
4
|
+
export const useBlockletEditorLoaded = () => {
|
|
5
|
+
const [loaded, setLoaded] = useState(false);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
BlockletEditor.preload().then(() => {
|
|
8
|
+
setLoaded(true);
|
|
9
|
+
});
|
|
10
|
+
}, []);
|
|
11
|
+
return loaded;
|
|
12
|
+
};
|
|
@@ -70,6 +70,7 @@ export class CustomComponentNode extends DecoratorBlockNode {
|
|
|
70
70
|
'x-cards': () => ({ conversion: convertCustomComponentElement, priority: 1 }),
|
|
71
71
|
'x-code-group': () => ({ conversion: convertCustomComponentElement, priority: 1 }),
|
|
72
72
|
'x-steps': () => ({ conversion: convertCustomComponentElement, priority: 1 }),
|
|
73
|
+
'x-field': () => ({ conversion: convertCustomComponentElement, priority: 1 }),
|
|
73
74
|
};
|
|
74
75
|
}
|
|
75
76
|
static importJSON(serializedNode) {
|
|
@@ -358,7 +358,7 @@ function CodeHeader({ title, icon, actions }) {
|
|
|
358
358
|
p: 1.5,
|
|
359
359
|
borderBottom: 1,
|
|
360
360
|
borderColor: 'divider',
|
|
361
|
-
bgcolor: '
|
|
361
|
+
bgcolor: 'grey.50',
|
|
362
362
|
borderRadius: '8px 8px 0 0',
|
|
363
363
|
}, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 1, flex: 1 }, children: [icon && (_jsx(Box, { component: Icon, icon: icon, sx: {
|
|
364
364
|
fontSize: '24px',
|
|
@@ -432,6 +432,7 @@ const XCode = styled('div')(({ theme }) => ({
|
|
|
432
432
|
pre: {
|
|
433
433
|
margin: 0,
|
|
434
434
|
borderRadius: 0,
|
|
435
|
+
background: 'transparent !important',
|
|
435
436
|
code: {
|
|
436
437
|
margin: 0,
|
|
437
438
|
border: 0,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface FieldProps {
|
|
2
|
+
name: string;
|
|
3
|
+
type: string;
|
|
4
|
+
default?: string;
|
|
5
|
+
required?: 'false' | 'true';
|
|
6
|
+
deprecated?: 'false' | 'true';
|
|
7
|
+
body?: string;
|
|
8
|
+
}
|
|
9
|
+
export default function Field({ name, type, default: defaultVal, required, deprecated, body }: FieldProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Stack, Box, styled, alpha } from '@mui/material';
|
|
3
|
+
import useMobile from '../../../main/hooks/use-mobile';
|
|
4
|
+
const Tag = styled(Box)(({ theme }) => ({
|
|
5
|
+
borderRadius: theme.shape.borderRadius * 0.75,
|
|
6
|
+
padding: theme.spacing(0.25, 1),
|
|
7
|
+
fontSize: '14px',
|
|
8
|
+
}));
|
|
9
|
+
const Bar = styled(Box)(({ theme }) => ({
|
|
10
|
+
display: 'flex',
|
|
11
|
+
alignItems: 'center',
|
|
12
|
+
lineHeight: '1.25em',
|
|
13
|
+
flexWrap: 'wrap',
|
|
14
|
+
gap: theme.spacing(1.25),
|
|
15
|
+
}));
|
|
16
|
+
export default function Field({ name, type, default: defaultVal, required, deprecated, body }) {
|
|
17
|
+
const isMobile = useMobile();
|
|
18
|
+
const isRequired = required === 'true';
|
|
19
|
+
const isDeprecated = deprecated === 'true';
|
|
20
|
+
const metaInfo = (_jsxs(_Fragment, { children: [_jsx(Tag, { sx: { backgroundColor: ({ palette }) => alpha(palette.grey[100], 0.6) }, children: type }), isRequired && (_jsx(Tag, { sx: { color: 'error.main', background: ({ palette }) => alpha(palette.error.main, 0.1), fontWeight: 500 }, children: "required" })), isDeprecated && (_jsx(Tag, { sx: {
|
|
21
|
+
color: 'warning.light',
|
|
22
|
+
background: ({ palette }) => alpha(palette.warning.light, 0.1),
|
|
23
|
+
fontWeight: 500,
|
|
24
|
+
}, children: "deprecated" })), defaultVal && (_jsxs(Tag, { sx: { backgroundColor: ({ palette }) => alpha(palette.grey[100], 0.6) }, children: [_jsx(Box, { component: "span", sx: { color: 'text.secondary', mr: 0.5 }, children: "default:" }), defaultVal] }))] }));
|
|
25
|
+
return (_jsxs(Stack, { className: "x-param-field", sx: {
|
|
26
|
+
borderBottom: '1px solid',
|
|
27
|
+
borderColor: 'divider',
|
|
28
|
+
pt: 1.25,
|
|
29
|
+
pb: 2.5,
|
|
30
|
+
my: 1.25,
|
|
31
|
+
}, children: [_jsxs(Bar, { children: [_jsx(Box, { sx: { color: 'primary.main', fontWeight: 500 }, children: name }), !isMobile && metaInfo] }), isMobile && _jsx(Bar, { sx: { mt: 1.25 }, children: metaInfo }), body && _jsx(Box, { sx: { color: 'text.secondary', mt: 2 }, children: body })] }));
|
|
32
|
+
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import Card from './Card';
|
|
2
2
|
import Cards from './Cards';
|
|
3
3
|
import Code from './Code';
|
|
4
|
+
import Field from './Field';
|
|
4
5
|
declare const components: {
|
|
5
6
|
code: typeof Code;
|
|
6
7
|
card: typeof Card;
|
|
7
8
|
cards: typeof Cards;
|
|
9
|
+
field: typeof Field;
|
|
8
10
|
};
|
|
9
11
|
export default components;
|
|
@@ -7,14 +7,14 @@ import { useEffect, useMemo, useState, lazy, Suspense } from 'react';
|
|
|
7
7
|
import SettingsOutlinedIcon from '@mui/icons-material/SettingsOutlined';
|
|
8
8
|
import SplitPane, { Pane } from 'split-pane-react';
|
|
9
9
|
import 'split-pane-react/esm/themes/default.css';
|
|
10
|
-
import {
|
|
11
|
-
// @ts-ignore
|
|
10
|
+
import { customComponentStates } from '@blocklet/pages-kit/components';
|
|
12
11
|
import { translations } from '@blocklet/pages-kit-runtime/locales';
|
|
13
12
|
import { LocaleProvider } from '@arcblock/ux/lib/Locale/context';
|
|
14
13
|
import mapValues from 'lodash/mapValues';
|
|
15
14
|
import { isBlockletRunning } from '../utils';
|
|
16
15
|
import { mode, getLocalizedValue } from './utils';
|
|
17
16
|
import { useContentLocale } from '../ContentLocale';
|
|
17
|
+
const CustomComponentRenderer = lazy(() => import('@blocklet/pages-kit/components').then((mod) => ({ default: mod.CustomComponentRenderer })));
|
|
18
18
|
const ParametersConfigLazy = lazy(() => import('@blocklet/pages-kit-runtime/components').then((mod) => ({
|
|
19
19
|
// @ts-ignore
|
|
20
20
|
default: mod.ParametersConfig,
|
package/lib/index.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import '@iconify/iconify';
|
|
2
|
-
import './main/index.css';
|
|
3
1
|
import BlockletEditor from './main';
|
|
4
2
|
export default BlockletEditor;
|
|
5
3
|
export type { BlockletEditorProps } from './main';
|
|
6
4
|
export * from './config';
|
|
7
5
|
export * from './main/markdown-to-lexical';
|
|
8
|
-
export type { EditorState } from 'lexical';
|
package/lib/index.js
CHANGED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Box, styled } from '@mui/material';
|
|
2
|
+
export const EditorRoot = styled(Box)(({ theme }) => {
|
|
3
|
+
const { palette } = theme;
|
|
4
|
+
return {
|
|
5
|
+
container: 'blocklet-editor / inline-size',
|
|
6
|
+
margin: '0 auto',
|
|
7
|
+
borderRadius: '4px',
|
|
8
|
+
position: 'relative',
|
|
9
|
+
lineHeight: '1.7',
|
|
10
|
+
fontWeight: '400',
|
|
11
|
+
textAlign: 'left',
|
|
12
|
+
// mui-*
|
|
13
|
+
'--mui-palette-grey-50': palette.grey[50],
|
|
14
|
+
'--mui-palette-grey-200': palette.grey[200],
|
|
15
|
+
'--mui-palette-background-paper': palette.background.paper,
|
|
16
|
+
'--mui-palette-divider': palette.divider,
|
|
17
|
+
'--mui-palette-primary-main': palette.primary.main,
|
|
18
|
+
'--mui-palette-primary-light': palette.primary.light,
|
|
19
|
+
'--mui-palette-text-primary': palette.text.primary,
|
|
20
|
+
'--mui-palette-text-secondary': palette.text.secondary,
|
|
21
|
+
// lexical-*
|
|
22
|
+
'--lexical-text-code': 'inherit',
|
|
23
|
+
// lexical-code-*
|
|
24
|
+
'--lexical-code-comment': '#1e8449',
|
|
25
|
+
'--lexical-code-punctuation': '#2c3e50',
|
|
26
|
+
'--lexical-code-property': '#e67e22',
|
|
27
|
+
'--lexical-code-selector': '#c0392b',
|
|
28
|
+
'--lexical-code-operator': '#8e44ad',
|
|
29
|
+
'--lexical-code-attr': '#2980b9',
|
|
30
|
+
'--lexical-code-variable': '#27ae60',
|
|
31
|
+
'--lexical-code-function': '#f39c12',
|
|
32
|
+
// dark mode
|
|
33
|
+
'&[data-mode="dark"]': {
|
|
34
|
+
'--lexical-text-code': palette.grey[800],
|
|
35
|
+
// lexical-code-*
|
|
36
|
+
'--lexical-code-comment': '#6a9955',
|
|
37
|
+
'--lexical-code-punctuation': '#d4d4d4',
|
|
38
|
+
'--lexical-code-property': '#9cdcfe',
|
|
39
|
+
'--lexical-code-selector': '#d7ba7d',
|
|
40
|
+
'--lexical-code-operator': '#d4d4d4',
|
|
41
|
+
'--lexical-code-attr': '#9cdcfe',
|
|
42
|
+
'--lexical-code-variable': '#9cdcfe',
|
|
43
|
+
'--lexical-code-function': '#dcdcaa',
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
});
|