Skip to content

Commit

Permalink
fix: 数据类型
Browse files Browse the repository at this point in the history
  • Loading branch information
yxh01132861 committed Dec 27, 2023
1 parent da973cf commit 9024aa6
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { PositionName } from '@antv/l7';
import type { WidgetRegisterForm } from '@antv/li-sdk';
import type { Delta } from 'quill-delta';
import type { RichTextEditingType } from '@antv/li-p2';

/**
* 属性面板生产的数据类型定义
*/
export type Properties = {
position?: PositionName;
width?: number;
content?: Delta;
content?: RichTextEditingType;
};

export default (): WidgetRegisterForm<Properties> => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { usePrefixCls } from '@formily/antd-v5/esm/__builtins__';
import { Button, Form, Input, Popover } from 'antd';
import cls from 'classnames';
import Quill from 'quill';
import type { Delta } from 'quill-delta';
import type { RichTextEditingType } from '../type';
import 'quill/dist/quill.snow.css';
import React, { useEffect, useRef, useState } from 'react';
import './index.css';
import useStyle from './style';

type EditorProps = {
value?: Delta;
onChange: (val: Delta) => void;
value?: RichTextEditingType;
onChange: (val: RichTextEditingType) => void;
};

// 字体大小
Expand Down
10 changes: 5 additions & 5 deletions packages/li-p2/src/components/Formily/RichTextEditing/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@ import React, { useState } from 'react';
import useStyle from './style';
import 'quill/dist/quill.snow.css';
import Editor from './Editor';
import type { Delta } from 'quill-delta';
import type { RichTextEditingType } from './type';

type InternalRichTextEditingProps = {
value?: Delta;
onChange: (val?: Delta) => void;
value?: RichTextEditingType;
onChange: (val?: RichTextEditingType) => void;
};

const InternalRichTextEditing: React.FC<InternalRichTextEditingProps> = (props) => {
const { onChange, value } = props;
const prefixCls = usePrefixCls('formily-rich-text-editing');
const [wrapSSR, hashId] = useStyle(prefixCls);
const [isModalOpen, setIsModalOpen] = useState(false);
const [content, setContent] = useState<Delta>();
const [content, setContent] = useState<RichTextEditingType>();

const handleOk = () => {
onChange(content);
setIsModalOpen(false);
};

const onSubmit = (val: Delta) => {
const onSubmit = (val: RichTextEditingType) => {
setContent(val);
};

Expand Down
8 changes: 8 additions & 0 deletions packages/li-p2/src/components/Formily/RichTextEditing/type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
type Op = {
insert?: string | Record<string, unknown>;
attributes?: string | Record<string, unknown>;
};

export type RichTextEditingType = {
ops?: Op[] | { ops: Op[] };
};
1 change: 1 addition & 0 deletions packages/li-p2/src/components/Formily/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ export { default as Slider } from './Slider';
export { default as SliderRange } from './SliderRange';
export { default as TimeGranularitySelect } from './TimeGranularitySelect';
export { default as RichTextEditing } from './RichTextEditing';
export type { RichTextEditingType } from './RichTextEditing/type';

0 comments on commit 9024aa6

Please sign in to comment.