Skip to content

Commit 24972aa

Browse files
committed
fix: find result error
drl990114/MarkFlowy#680
1 parent 05a1995 commit 24972aa

File tree

16 files changed

+799
-240
lines changed

16 files changed

+799
-240
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rme",
3-
"version": "0.0.61",
3+
"version": "0.0.65",
44
"type": "module",
55
"scripts": {
66
"build": "yarn clear && yarn build-esbuild && yarn types",
@@ -177,6 +177,6 @@
177177
"svgmoji": "^3.2.0",
178178
"void-elements": "^3.1.0",
179179
"yjs": "^13.6.14",
180-
"zens": "^0.0.25"
180+
"zens": "^0.0.26"
181181
}
182182
}

src/editor/components/Editor.tsx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,10 @@ import {
1111
} from '../..'
1212
import { useContextMounted } from './useContextMounted'
1313
import type { Extension, RemirrorEventListenerProps } from 'remirror'
14-
import 'prosemirror-flat-list/dist/style.css'
1514

1615
export const Editor = memo(
1716
forwardRef<EditorRef, EditorProps>((props, ref) => {
18-
const {
19-
initialType = 'wysiwyg',
20-
hooks = [],
21-
onContextMounted,
22-
...otherProps
23-
} = props
17+
const { initialType = 'wysiwyg', hooks = [], onContextMounted, ...otherProps } = props
2418
const [type, setType] = useState<EditorViewType>(initialType)
2519

2620
useImperativeHandle(ref, () => ({
@@ -54,9 +48,24 @@ export type EditorRef = {
5448
getType: () => EditorViewType
5549
}
5650

51+
export const defaultStyleToken = {
52+
rootFontSize: '15px',
53+
rootLineHeight: '1.6'
54+
}
55+
5756
export interface EditorProps {
5857
initialType?: EditorViewType
5958
delegate?: EditorDelegate
59+
styleToken?: {
60+
/**
61+
* @default 15px
62+
*/
63+
rootFontSize?: string
64+
/**
65+
* @default 1.6
66+
*/
67+
rootLineHeight?: string
68+
}
6069
content: string
6170
isTesting?: boolean
6271
editable?: boolean

src/editor/components/SourceEditor/index.tsx

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { EditorDelegate } from '../../types'
66
import { ProsemirrorDevTools } from '@remirror/dev'
77
import { createSourceCodeDelegate } from './delegate'
88
import ErrorBoundary from '../ErrorBoundary'
9-
import type { EditorProps } from '../Editor'
9+
import { defaultStyleToken, type EditorProps } from '../Editor'
1010
import type { Extension, RemirrorEventListener } from 'remirror'
1111
import { SourceCodeThemeWrapper } from '../../theme'
1212

@@ -25,8 +25,12 @@ const [SourceEditorProvider, useSourceCodeEditor] = createContextState<Context,
2525
)
2626

2727
const SourceCodeEditorCore = memo(
28-
(props: { markdownToolBar?: React.ReactNode[]; onChange: RemirrorEventListener<Extension> }) => {
29-
const { markdownToolBar } = props
28+
(props: {
29+
styleToken?: EditorProps['styleToken']
30+
markdownToolBar?: React.ReactNode[]
31+
onChange: RemirrorEventListener<Extension>
32+
}) => {
33+
const { markdownToolBar, styleToken } = props
3034
const { content, markText, hooks, isTesting, editable } = useSourceCodeEditor()
3135

3236
let initialCntent
@@ -39,7 +43,7 @@ const SourceCodeEditorCore = memo(
3943

4044
return (
4145
<ErrorBoundary>
42-
<SourceCodeThemeWrapper>
46+
<SourceCodeThemeWrapper {...styleToken}>
4347
<Remirror
4448
manager={markText.manager}
4549
initialContent={initialCntent}
@@ -61,7 +65,14 @@ const SourceCodeEditorCore = memo(
6165
* The editor which is used to create the annotation. Supports formatting.
6266
*/
6367
const SourceEditor: React.FC<EditorProps> = (props) => {
64-
const { content, delegate, isTesting, hooks, markdownToolBar } = props
68+
const {
69+
content,
70+
delegate,
71+
isTesting,
72+
hooks,
73+
markdownToolBar,
74+
styleToken = defaultStyleToken,
75+
} = props
6576

6677
const editorDelegate = useMemo(() => delegate ?? createSourceCodeDelegate(), [delegate])
6778

@@ -84,7 +95,11 @@ const SourceEditor: React.FC<EditorProps> = (props) => {
8495
markText={editorDelegate}
8596
hooks={hooks}
8697
>
87-
<SourceCodeEditorCore markdownToolBar={markdownToolBar} onChange={handleChange} />
98+
<SourceCodeEditorCore
99+
styleToken={styleToken}
100+
markdownToolBar={markdownToolBar}
101+
onChange={handleChange}
102+
/>
88103
</SourceEditorProvider>
89104
)
90105
}

src/editor/components/WysiwygEditor/index.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import TableToolbar from '../../toolbar/TableToolbar'
77
import { ProsemirrorDevTools } from '@remirror/dev'
88
import ErrorBoundary from '../ErrorBoundary'
99
import type { Extension, RemirrorEventListener } from '@remirror/core'
10-
import type { EditorProps } from '../Editor'
10+
import { defaultStyleToken, type EditorProps } from '../Editor'
1111
import { SlashMenu } from '../../toolbar/SlashMenu'
1212
import type { DocToString, StringToDoc } from '../../types'
1313

@@ -17,7 +17,15 @@ export const wysiwygTransformer: {
1717
} = { stringToDoc: null, docToString: null }
1818

1919
const WysiwygEditor: FC<EditorProps> = (props) => {
20-
const { content, hooks, delegate, wysiwygToolBar, isTesting, editable } = props
20+
const {
21+
content,
22+
hooks,
23+
delegate,
24+
wysiwygToolBar,
25+
isTesting,
26+
editable = true,
27+
styleToken = defaultStyleToken,
28+
} = props
2129

2230
const editorDelegate = useMemo(() => delegate ?? createWysiwygDelegate(), [delegate])
2331

@@ -47,7 +55,7 @@ const WysiwygEditor: FC<EditorProps> = (props) => {
4755

4856
return (
4957
<ErrorBoundary>
50-
<WysiwygThemeWrapper>
58+
<WysiwygThemeWrapper {...styleToken}>
5159
<Remirror
5260
manager={editorDelegate.manager}
5361
initialContent={initialContent}
@@ -66,9 +74,5 @@ const WysiwygEditor: FC<EditorProps> = (props) => {
6674
)
6775
}
6876

69-
WysiwygEditor.defaultProps = {
70-
editable: true,
71-
}
72-
7377
export default memo(WysiwygEditor)
7478
export * from './delegate'

0 commit comments

Comments
 (0)