@portabletext/editor 1.27.0 → 1.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/lib/_chunks-cjs/plugin.event-listener.cjs +302 -43
- package/lib/_chunks-cjs/plugin.event-listener.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.is-at-the-start-of-block.cjs +88 -88
- package/lib/_chunks-cjs/selector.is-at-the-start-of-block.cjs.map +1 -1
- package/lib/_chunks-es/plugin.event-listener.js +302 -43
- package/lib/_chunks-es/plugin.event-listener.js.map +1 -1
- package/lib/_chunks-es/selector.is-at-the-start-of-block.js +88 -88
- package/lib/_chunks-es/selector.is-at-the-start-of-block.js.map +1 -1
- package/lib/index.cjs +22 -21
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +257 -0
- package/lib/index.d.ts +257 -0
- package/lib/index.js +22 -21
- package/lib/index.js.map +1 -1
- package/lib/selectors/index.cjs +15 -3
- package/lib/selectors/index.cjs.map +1 -1
- package/lib/selectors/index.d.cts +18 -0
- package/lib/selectors/index.d.ts +18 -0
- package/lib/selectors/index.js +17 -4
- package/lib/selectors/index.js.map +1 -1
- package/package.json +3 -3
- package/src/behavior-actions/behavior.action.insert-break.ts +93 -83
- package/src/editor/PortableTextEditor.tsx +288 -1
- package/src/editor/components/DefaultObject.tsx +21 -0
- package/src/editor/components/Element.tsx +5 -5
- package/src/editor/components/Leaf.tsx +1 -6
- package/src/selectors/index.ts +4 -2
- package/src/selectors/selector.get-active-annotations.test.ts +122 -0
- package/src/selectors/selector.get-active-annotations.ts +30 -0
- package/src/selectors/selector.get-selection.ts +8 -0
- package/src/selectors/selector.get-value.ts +11 -0
- package/src/editor/nodes/DefaultAnnotation.tsx +0 -20
- package/src/editor/nodes/DefaultObject.tsx +0 -18
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type {PortableTextObject} from '@sanity/types'
|
|
2
|
-
import {useCallback, type ReactNode} from 'react'
|
|
3
|
-
|
|
4
|
-
type Props = {
|
|
5
|
-
annotation: PortableTextObject
|
|
6
|
-
children: ReactNode
|
|
7
|
-
}
|
|
8
|
-
export function DefaultAnnotation(props: Props) {
|
|
9
|
-
const handleClick = useCallback(
|
|
10
|
-
() => alert(JSON.stringify(props.annotation)),
|
|
11
|
-
[props.annotation],
|
|
12
|
-
)
|
|
13
|
-
return (
|
|
14
|
-
<span style={{color: 'blue'}} onClick={handleClick}>
|
|
15
|
-
{props.children}
|
|
16
|
-
</span>
|
|
17
|
-
)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
DefaultAnnotation.displayName = 'DefaultAnnotation'
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type {PortableTextBlock, PortableTextChild} from '@sanity/types'
|
|
2
|
-
import type {JSX} from 'react'
|
|
3
|
-
|
|
4
|
-
type Props = {
|
|
5
|
-
value: PortableTextBlock | PortableTextChild
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const DefaultObject = (props: Props): JSX.Element => {
|
|
9
|
-
return (
|
|
10
|
-
<div style={{userSelect: 'none'}}>
|
|
11
|
-
[{props.value._type}: {props.value._key}]
|
|
12
|
-
</div>
|
|
13
|
-
)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
DefaultObject.displayName = 'DefaultObject'
|
|
17
|
-
|
|
18
|
-
export default DefaultObject
|