-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
1,095 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
packages/client/src/schema-component/antd/rich-text/RichText.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { connect, mapReadPretty } from '@formily/react'; | ||
import React from 'react'; | ||
import ReactQuill from 'react-quill'; | ||
import { ReadPretty as InputReadPretty } from '../input'; | ||
import './style.less'; | ||
|
||
export const RichText = connect( | ||
(props) => { | ||
const modules = { | ||
toolbar: [ | ||
['bold', 'italic', 'underline', 'link'], | ||
[{ list: 'ordered' }, { list: 'bullet' }], | ||
['clean'], | ||
], | ||
}; | ||
const formats = [ | ||
'header', | ||
'bold', | ||
'italic', | ||
'underline', | ||
'strike', | ||
'blockquote', | ||
'list', | ||
'bullet', | ||
'indent', | ||
'link', | ||
'image', | ||
]; | ||
const { value, onChange } = props; | ||
return ( | ||
<ReactQuill | ||
modules={modules} | ||
formats={formats} | ||
value={typeof value === 'string' ? value : ''} | ||
onChange={onChange} | ||
/> | ||
); | ||
}, | ||
mapReadPretty((props) => { | ||
return <InputReadPretty.Html {...props} />; | ||
}), | ||
); |
39 changes: 39 additions & 0 deletions
39
packages/client/src/schema-component/antd/rich-text/demos/demo1.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { FormItem } from '@formily/antd'; | ||
import { RichText, SchemaComponent, SchemaComponentProvider } from '@nocobase/client'; | ||
import React from 'react'; | ||
import 'react-quill/dist/quill.snow.css'; // ES6 | ||
|
||
const schema = { | ||
type: 'object', | ||
properties: { | ||
input: { | ||
type: 'string', | ||
title: `Editable`, | ||
'x-decorator': 'FormItem', | ||
'x-component': 'RichText', | ||
'x-reactions': { | ||
target: 'read', | ||
fulfill: { | ||
state: { | ||
value: '{{$self.value}}', | ||
}, | ||
}, | ||
}, | ||
}, | ||
read: { | ||
type: 'string', | ||
title: `Read pretty`, | ||
'x-read-pretty': true, | ||
'x-decorator': 'FormItem', | ||
'x-component': 'RichText', | ||
}, | ||
}, | ||
}; | ||
|
||
export default () => { | ||
return ( | ||
<SchemaComponentProvider components={{ RichText, FormItem }}> | ||
<SchemaComponent schema={schema} /> | ||
</SchemaComponentProvider> | ||
); | ||
}; |
12 changes: 12 additions & 0 deletions
12
packages/client/src/schema-component/antd/rich-text/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
nav: | ||
path: /client | ||
group: | ||
path: /schema-components | ||
--- | ||
|
||
# Rich Text | ||
|
||
## Examples | ||
|
||
<code src="./demos/demo1.tsx" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './RichText'; |
Oops, something went wrong.