-
Notifications
You must be signed in to change notification settings - Fork 2
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
5 changed files
with
234 additions
and
241 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import { Editable } from '@dslate/component'; | ||
import { ConfigProvider, DSlateCore } from '@dslate/core'; | ||
|
||
import DefaultPlugin from '@dslate/plugin'; | ||
import React, { useState } from 'react'; | ||
import type { Descendant } from 'slate'; | ||
import styled from 'styled-components'; | ||
|
||
const ResetStyleBox = styled.div` | ||
.dslate-editable { | ||
min-height: 400px !important; | ||
h1 { | ||
font-size: xx-large !important; | ||
} | ||
h2 { | ||
font-size: x-large !important; | ||
} | ||
h3 { | ||
font-size: large !important; | ||
} | ||
h4 { | ||
font-size: medium !important; | ||
} | ||
h5 { | ||
font-size: small !important; | ||
} | ||
h6 { | ||
font-size: x-small !important; | ||
} | ||
* { | ||
margin: 0; | ||
&::selection { | ||
color: inherit; | ||
background-color: rgba(var(--semi-blue-5), 0.15); | ||
} | ||
} | ||
} | ||
`; | ||
export default () => { | ||
const [value, setValue] = useState<Descendant[]>([ | ||
{ | ||
type: 'paragraph', | ||
children: [ | ||
{ | ||
text: 'hi! ', | ||
}, | ||
], | ||
paragraphType: 'h1', | ||
'line-height': 1.5, | ||
}, | ||
{ | ||
type: 'paragraph', | ||
children: [ | ||
{ | ||
text: 'this is ', | ||
}, | ||
{ | ||
text: 'display mode', | ||
underline: true, | ||
color: '#ff6900', | ||
}, | ||
{ | ||
text: '!', | ||
}, | ||
], | ||
paragraphType: 'h3', | ||
'line-height': 1.5, | ||
}, | ||
]); | ||
|
||
return ( | ||
<ResetStyleBox> | ||
<ConfigProvider | ||
value={{ | ||
plugins: Object.values(DefaultPlugin), | ||
locale: '', | ||
locales: [], | ||
}} | ||
> | ||
<DSlateCore | ||
value={value} | ||
onChange={function (value: Descendant[]): void { | ||
// do nothing... | ||
}} | ||
> | ||
<Editable disabled /> | ||
</DSlateCore> | ||
</ConfigProvider> | ||
</ResetStyleBox> | ||
); | ||
}; |
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,13 @@ | ||
--- | ||
title: 只读展示模式 | ||
order: 8 | ||
nav: 文档 | ||
--- | ||
|
||
# 只读展示模式/Display Mode | ||
|
||
直接使用 json 数据进行展示,该模式下不依赖任何 UI 框架,并且不可对内容进行编辑 | ||
|
||
## Demo | ||
|
||
<code src="../demos/display-mode.tsx"></code> |
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
Oops, something went wrong.