-
Notifications
You must be signed in to change notification settings - Fork 784
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix * Create stupid-readers-fetch.md * Create popular-months-obey.md * fix * fix
- Loading branch information
Showing
40 changed files
with
215 additions
and
128 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
"@udecode/plate-ui-alignment": minor | ||
"@udecode/plate-ui-code-block": minor | ||
"@udecode/plate-ui-font": minor | ||
"@udecode/plate-ui-image": minor | ||
"@udecode/plate-ui-line-height": minor | ||
--- | ||
|
||
new prop: editor `id` |
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,11 @@ | ||
--- | ||
"@udecode/plate-core": minor | ||
--- | ||
|
||
Fix a critical issue when using multiple editors #1352 | ||
- `withHOC`: 3rd parameter can be used to add props to HOC. | ||
- `usePlateId` now just gets plate id atom value and no longer gets event editor id as fallback. | ||
- `useEventEditorId`: Get last event editor id: focus, blur or last. | ||
- `useEventPlateId`: Get provider plate id or event editor id. | ||
- `PlateEventProvider`: `PlateProvider` where id is the event editor id (used for toolbar buttons). | ||
- `withPlateEventProvider` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React, { FC } from 'react'; | ||
import { withHOC } from '../common/hoc/withHOC'; | ||
import { useEventPlateId } from '../stores/event-editor/selectors/useEventPlateId'; | ||
import { PlateProvider } from './PlateProvider'; | ||
|
||
export const PlateEventProvider = ({ | ||
id, | ||
children, | ||
}: { | ||
id?: string; | ||
children: any; | ||
}) => { | ||
id = useEventPlateId(id); | ||
|
||
return <PlateProvider id={id}>{children}</PlateProvider>; | ||
}; | ||
|
||
export const withPlateEventProvider = <T,>(Component: FC<T>, hocProps?: T) => | ||
withHOC<T>(PlateEventProvider, Component, hocProps); |
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 |
---|---|---|
@@ -1,27 +1,23 @@ | ||
import React, { FC } from 'react'; | ||
import { castArray } from 'lodash'; | ||
import { withHOC } from '../common/hoc/withHOC'; | ||
import { usePlatesStoreEffect } from '../hooks/usePlatesStoreEffect'; | ||
import { usePlatesSelectors } from '../stores/plate/platesStore'; | ||
|
||
export const PlateProvider = ({ | ||
id: _ids = 'main', | ||
id = 'main', | ||
children, | ||
}: { | ||
id?: string | string[]; | ||
id?: string; | ||
children: any; | ||
}) => { | ||
const ids = castArray<string>(_ids) ?? ['main']; | ||
const id = ids[0]; | ||
const hasId = usePlatesSelectors.has(id); | ||
|
||
const hasId = usePlatesSelectors.has(ids); | ||
|
||
usePlatesStoreEffect(_ids); | ||
usePlatesStoreEffect(id); | ||
|
||
if (!hasId) return null; | ||
|
||
return <React.Fragment key={id}>{children}</React.Fragment>; | ||
}; | ||
|
||
export const withPlateProvider = <T,>(Component: FC<T>) => | ||
withHOC<T>(PlateProvider, Component); | ||
export const withPlateProvider = <T,>(Component: FC<T>, hocProps?: T) => | ||
withHOC<T>(PlateProvider, Component, hocProps); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,16 @@ | ||
import { useEffect } from 'react'; | ||
import { castArray } from 'lodash'; | ||
import { PlateProps } from '../components/Plate'; | ||
import { platesActions, platesSelectors } from '../stores/plate/platesStore'; | ||
import { usePlateId } from '../stores/plate/selectors/getPlateId'; | ||
|
||
/** | ||
* On mount: create plate store and set it to the plates store. | ||
* If id is not defined, event id is used. | ||
*/ | ||
export const usePlatesStoreEffect = ( | ||
_ids?: string | string[], | ||
props?: PlateProps | ||
) => { | ||
const __ids = castArray<string>(_ids); | ||
const id = usePlateId(__ids[0]); | ||
|
||
export const usePlatesStoreEffect = (id?: string, props?: PlateProps) => { | ||
useEffect(() => { | ||
// Set multiple plate stores | ||
if (Array.isArray(_ids)) { | ||
const ids = castArray<string>(_ids); | ||
|
||
ids.forEach((_id) => { | ||
if (!platesSelectors.has(_id)) { | ||
platesActions.set(_id, props); | ||
} | ||
}); | ||
} else if (!platesSelectors.has(id)) { | ||
platesActions.set(id, props); | ||
if (!platesSelectors.has(id)) { | ||
platesActions.set(id!, props); | ||
} | ||
|
||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [_ids, id]); | ||
}, [id]); | ||
}; |
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 |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
*/ | ||
|
||
export * from './event-editor.store'; | ||
export * from './selectors/index'; |
13 changes: 13 additions & 0 deletions
13
packages/core/src/stores/event-editor/selectors/getEventEditorId.ts
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 @@ | ||
import { eventEditorSelectors } from '../event-editor.store'; | ||
|
||
export const getEventEditorId = (id?: string) => { | ||
if (id) return id; | ||
|
||
const focus = eventEditorSelectors.focus(); | ||
if (focus) return focus; | ||
|
||
const blur = eventEditorSelectors.blur(); | ||
if (blur) return blur; | ||
|
||
return eventEditorSelectors.last() ?? 'main'; | ||
}; |
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,7 @@ | ||
/** | ||
* @file Automatically generated by barrelsby. | ||
*/ | ||
|
||
export * from './getEventEditorId'; | ||
export * from './useEventEditorId'; | ||
export * from './useEventPlateId'; |
14 changes: 14 additions & 0 deletions
14
packages/core/src/stores/event-editor/selectors/useEventEditorId.ts
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,14 @@ | ||
import { useEventEditorSelectors } from '../event-editor.store'; | ||
|
||
/** | ||
* Get last event editor id: focus, blur or last. | ||
*/ | ||
export const useEventEditorId = () => { | ||
const focus = useEventEditorSelectors.focus(); | ||
const blur = useEventEditorSelectors.blur(); | ||
const last = useEventEditorSelectors.last(); | ||
|
||
if (focus) return focus; | ||
if (blur) return blur; | ||
return last; | ||
}; |
9 changes: 9 additions & 0 deletions
9
packages/core/src/stores/event-editor/selectors/useEventPlateId.ts
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,9 @@ | ||
import { usePlateId } from '../../plate/selectors/usePlateId'; | ||
import { useEventEditorId } from './useEventEditorId'; | ||
|
||
export const useEventPlateId = (id?: string) => { | ||
const plateId = usePlateId(); | ||
const eventEditorId = useEventEditorId(); | ||
|
||
return id ?? plateId ?? eventEditorId ?? 'main'; | ||
}; |
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 was deleted.
Oops, something went wrong.
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,11 @@ | ||
import { useAtom } from 'jotai'; | ||
import { plateIdAtom } from '../../plateIdAtom'; | ||
|
||
/** | ||
* Get plate editor id provided by PlateProvider. | ||
*/ | ||
export const usePlateId = () => { | ||
const [plateId] = useAtom(plateIdAtom); | ||
|
||
return plateId; | ||
}; |
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
File renamed without changes.
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 |
---|---|---|
@@ -1,3 +1,7 @@ | ||
/** | ||
* @file Automatically generated by barrelsby. | ||
*/ | ||
|
||
export * from './KeyboardEventHandler'; | ||
export * from './mentionOnKeyDownHandler'; | ||
export * from './moveSelectionByOffset'; |
2 changes: 1 addition & 1 deletion
2
packages/nodes/mention/src/handlers/mentionOnKeyDownHandler.spec.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
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
Oops, something went wrong.
289c8e7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: