@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
package/lib/index.d.cts
CHANGED
|
@@ -19509,11 +19509,46 @@ export declare class PortableTextEditor extends Component<
|
|
|
19509
19509
|
componentDidUpdate(prevProps: PortableTextEditorProps): void
|
|
19510
19510
|
setEditable: (editable: EditableAPI) => void
|
|
19511
19511
|
render(): JSX.Element
|
|
19512
|
+
/**
|
|
19513
|
+
* @deprecated
|
|
19514
|
+
* Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
|
|
19515
|
+
*
|
|
19516
|
+
* ```
|
|
19517
|
+
* import * as selectors from '@portabletext/editor/selectors'
|
|
19518
|
+
* const editor = useEditor()
|
|
19519
|
+
* const isActive = useEditorSelector(editor, selectors.getActiveAnnotations)
|
|
19520
|
+
* ```
|
|
19521
|
+
*/
|
|
19512
19522
|
static activeAnnotations: (editor: PortableTextEditor) => PortableTextObject[]
|
|
19523
|
+
/**
|
|
19524
|
+
* @deprecated
|
|
19525
|
+
* Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
|
|
19526
|
+
*
|
|
19527
|
+
* ```
|
|
19528
|
+
* import * as selectors from '@portabletext/editor/selectors'
|
|
19529
|
+
* const editor = useEditor()
|
|
19530
|
+
* const isActive = useEditorSelector(editor, selectors.isActiveAnnotation(...))
|
|
19531
|
+
* ```
|
|
19532
|
+
*/
|
|
19513
19533
|
static isAnnotationActive: (
|
|
19514
19534
|
editor: PortableTextEditor,
|
|
19515
19535
|
annotationType: PortableTextObject['_type'],
|
|
19516
19536
|
) => boolean
|
|
19537
|
+
/**
|
|
19538
|
+
* @deprecated
|
|
19539
|
+
* Use `editor.send(...)` instead
|
|
19540
|
+
*
|
|
19541
|
+
* ```
|
|
19542
|
+
* const editor = useEditor()
|
|
19543
|
+
* editor.send({
|
|
19544
|
+
* type: 'annotation.add',
|
|
19545
|
+
* annotation: {
|
|
19546
|
+
* name: '...',
|
|
19547
|
+
* value: {...},
|
|
19548
|
+
* }
|
|
19549
|
+
* })
|
|
19550
|
+
* ```
|
|
19551
|
+
*/
|
|
19517
19552
|
static addAnnotation: <
|
|
19518
19553
|
TSchemaType extends {
|
|
19519
19554
|
name: string
|
|
@@ -19525,6 +19560,17 @@ export declare class PortableTextEditor extends Component<
|
|
|
19525
19560
|
[prop: string]: unknown
|
|
19526
19561
|
},
|
|
19527
19562
|
) => AddedAnnotationPaths | undefined
|
|
19563
|
+
/**
|
|
19564
|
+
* @deprecated
|
|
19565
|
+
* Use `editor.send(...)` instead
|
|
19566
|
+
*
|
|
19567
|
+
* ```
|
|
19568
|
+
* const editor = useEditor()
|
|
19569
|
+
* editor.send({
|
|
19570
|
+
* type: 'blur',
|
|
19571
|
+
* })
|
|
19572
|
+
* ```
|
|
19573
|
+
*/
|
|
19528
19574
|
static blur: (editor: PortableTextEditor) => void
|
|
19529
19575
|
static delete: (
|
|
19530
19576
|
editor: PortableTextEditor,
|
|
@@ -19547,28 +19593,150 @@ export declare class PortableTextEditor extends Component<
|
|
|
19547
19593
|
),
|
|
19548
19594
|
Path | undefined,
|
|
19549
19595
|
]
|
|
19596
|
+
/**
|
|
19597
|
+
* @deprecated
|
|
19598
|
+
* Use `editor.send(...)` instead
|
|
19599
|
+
*
|
|
19600
|
+
* ```
|
|
19601
|
+
* const editor = useEditor()
|
|
19602
|
+
* editor.send({
|
|
19603
|
+
* type: 'focus',
|
|
19604
|
+
* })
|
|
19605
|
+
* ```
|
|
19606
|
+
*/
|
|
19550
19607
|
static focus: (editor: PortableTextEditor) => void
|
|
19608
|
+
/**
|
|
19609
|
+
* @deprecated
|
|
19610
|
+
* Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
|
|
19611
|
+
*
|
|
19612
|
+
* ```
|
|
19613
|
+
* import * as selectors from '@portabletext/editor/selectors'
|
|
19614
|
+
* const editor = useEditor()
|
|
19615
|
+
* const focusBlock = useEditorSelector(editor, selectors.getFocusBlock)
|
|
19616
|
+
* ```
|
|
19617
|
+
*/
|
|
19551
19618
|
static focusBlock: (
|
|
19552
19619
|
editor: PortableTextEditor,
|
|
19553
19620
|
) => PortableTextBlock | undefined
|
|
19621
|
+
/**
|
|
19622
|
+
* @deprecated
|
|
19623
|
+
* Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
|
|
19624
|
+
*
|
|
19625
|
+
* ```
|
|
19626
|
+
* import * as selectors from '@portabletext/editor/selectors'
|
|
19627
|
+
* const editor = useEditor()
|
|
19628
|
+
* const focusChild = useEditorSelector(editor, selectors.getFocusChild)
|
|
19629
|
+
* ```
|
|
19630
|
+
*/
|
|
19554
19631
|
static focusChild: (
|
|
19555
19632
|
editor: PortableTextEditor,
|
|
19556
19633
|
) => PortableTextChild | undefined
|
|
19634
|
+
/**
|
|
19635
|
+
* @deprecated
|
|
19636
|
+
* Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
|
|
19637
|
+
*
|
|
19638
|
+
* ```
|
|
19639
|
+
* import * as selectors from '@portabletext/editor/selectors'
|
|
19640
|
+
* const editor = useEditor()
|
|
19641
|
+
* const selection = useEditorSelector(editor, selectors.getSelection)
|
|
19642
|
+
* ```
|
|
19643
|
+
*/
|
|
19557
19644
|
static getSelection: (editor: PortableTextEditor) => EditorSelection
|
|
19645
|
+
/**
|
|
19646
|
+
* @deprecated
|
|
19647
|
+
* Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
|
|
19648
|
+
*
|
|
19649
|
+
* ```
|
|
19650
|
+
* import * as selectors from '@portabletext/editor/selectors'
|
|
19651
|
+
* const editor = useEditor()
|
|
19652
|
+
* const value = useEditorSelector(editor, selectors.getValue)
|
|
19653
|
+
* ```
|
|
19654
|
+
*/
|
|
19558
19655
|
static getValue: (
|
|
19559
19656
|
editor: PortableTextEditor,
|
|
19560
19657
|
) => PortableTextBlock[] | undefined
|
|
19658
|
+
/**
|
|
19659
|
+
* @deprecated
|
|
19660
|
+
* Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
|
|
19661
|
+
*
|
|
19662
|
+
* ```
|
|
19663
|
+
* import * as selectors from '@portabletext/editor/selectors'
|
|
19664
|
+
* const editor = useEditor()
|
|
19665
|
+
* const isActive = useEditorSelector(editor, selectors.isActiveStyle(...))
|
|
19666
|
+
* ```
|
|
19667
|
+
*/
|
|
19561
19668
|
static hasBlockStyle: (
|
|
19562
19669
|
editor: PortableTextEditor,
|
|
19563
19670
|
blockStyle: string,
|
|
19564
19671
|
) => boolean
|
|
19672
|
+
/**
|
|
19673
|
+
* @deprecated
|
|
19674
|
+
* Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
|
|
19675
|
+
*
|
|
19676
|
+
* ```
|
|
19677
|
+
* import * as selectors from '@portabletext/editor/selectors'
|
|
19678
|
+
* const editor = useEditor()
|
|
19679
|
+
* const isActive = useEditorSelector(editor, selectors.isActiveListItem(...))
|
|
19680
|
+
* ```
|
|
19681
|
+
*/
|
|
19565
19682
|
static hasListStyle: (
|
|
19566
19683
|
editor: PortableTextEditor,
|
|
19567
19684
|
listStyle: string,
|
|
19568
19685
|
) => boolean
|
|
19686
|
+
/**
|
|
19687
|
+
* @deprecated
|
|
19688
|
+
* Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
|
|
19689
|
+
*
|
|
19690
|
+
* ```
|
|
19691
|
+
* import * as selectors from '@portabletext/editor/selectors'
|
|
19692
|
+
* const editor = useEditor()
|
|
19693
|
+
* const isSelectionCollapsed = useEditorSelector(editor, selectors.isSelectionCollapsed)
|
|
19694
|
+
* ```
|
|
19695
|
+
*/
|
|
19569
19696
|
static isCollapsedSelection: (editor: PortableTextEditor) => boolean
|
|
19697
|
+
/**
|
|
19698
|
+
* @deprecated
|
|
19699
|
+
* Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
|
|
19700
|
+
*
|
|
19701
|
+
* ```
|
|
19702
|
+
* import * as selectors from '@portabletext/editor/selectors'
|
|
19703
|
+
* const editor = useEditor()
|
|
19704
|
+
* const isSelectionExpanded = useEditorSelector(editor, selectors.isSelectionExpanded)
|
|
19705
|
+
* ```
|
|
19706
|
+
*/
|
|
19570
19707
|
static isExpandedSelection: (editor: PortableTextEditor) => boolean
|
|
19708
|
+
/**
|
|
19709
|
+
* @deprecated
|
|
19710
|
+
* Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
|
|
19711
|
+
*
|
|
19712
|
+
* ```
|
|
19713
|
+
* import * as selectors from '@portabletext/editor/selectors'
|
|
19714
|
+
* const editor = useEditor()
|
|
19715
|
+
* const isActive = useEditorSelector(editor, selectors.isActiveDecorator(...))
|
|
19716
|
+
* ```
|
|
19717
|
+
*/
|
|
19571
19718
|
static isMarkActive: (editor: PortableTextEditor, mark: string) => boolean
|
|
19719
|
+
/**
|
|
19720
|
+
* @deprecated
|
|
19721
|
+
* Use `editor.send(...)` instead
|
|
19722
|
+
*
|
|
19723
|
+
* ```
|
|
19724
|
+
* const editor = useEditor()
|
|
19725
|
+
* editor.send({
|
|
19726
|
+
* type: 'insert.span',
|
|
19727
|
+
* text: '...',
|
|
19728
|
+
* annotations: [{name: '...', value: {...}}],
|
|
19729
|
+
* decorators: ['...'],
|
|
19730
|
+
* })
|
|
19731
|
+
* editor.send({
|
|
19732
|
+
* type: 'insert.inline object',
|
|
19733
|
+
* inlineObject: {
|
|
19734
|
+
* name: '...',
|
|
19735
|
+
* value: {...},
|
|
19736
|
+
* },
|
|
19737
|
+
* })
|
|
19738
|
+
* ```
|
|
19739
|
+
*/
|
|
19572
19740
|
static insertChild: <
|
|
19573
19741
|
TSchemaType extends {
|
|
19574
19742
|
name: string
|
|
@@ -19580,6 +19748,22 @@ export declare class PortableTextEditor extends Component<
|
|
|
19580
19748
|
[prop: string]: unknown
|
|
19581
19749
|
},
|
|
19582
19750
|
) => Path | undefined
|
|
19751
|
+
/**
|
|
19752
|
+
* @deprecated
|
|
19753
|
+
* Use `editor.send(...)` instead
|
|
19754
|
+
*
|
|
19755
|
+
* ```
|
|
19756
|
+
* const editor = useEditor()
|
|
19757
|
+
* editor.send({
|
|
19758
|
+
* type: 'insert.block object',
|
|
19759
|
+
* blockObject: {
|
|
19760
|
+
* name: '...',
|
|
19761
|
+
* value: {...},
|
|
19762
|
+
* },
|
|
19763
|
+
* placement: 'auto' | 'after' | 'before',
|
|
19764
|
+
* })
|
|
19765
|
+
* ```
|
|
19766
|
+
*/
|
|
19583
19767
|
static insertBlock: <
|
|
19584
19768
|
TSchemaType extends {
|
|
19585
19769
|
name: string
|
|
@@ -19591,6 +19775,17 @@ export declare class PortableTextEditor extends Component<
|
|
|
19591
19775
|
[prop: string]: unknown
|
|
19592
19776
|
},
|
|
19593
19777
|
) => Path | undefined
|
|
19778
|
+
/**
|
|
19779
|
+
* @deprecated
|
|
19780
|
+
* Use `editor.send(...)` instead
|
|
19781
|
+
*
|
|
19782
|
+
* ```
|
|
19783
|
+
* const editor = useEditor()
|
|
19784
|
+
* editor.send({
|
|
19785
|
+
* type: 'insert.break',
|
|
19786
|
+
* })
|
|
19787
|
+
* ```
|
|
19788
|
+
*/
|
|
19594
19789
|
static insertBreak: (editor: PortableTextEditor) => void
|
|
19595
19790
|
static isVoid: (
|
|
19596
19791
|
editor: PortableTextEditor,
|
|
@@ -19598,10 +19793,36 @@ export declare class PortableTextEditor extends Component<
|
|
|
19598
19793
|
) => boolean
|
|
19599
19794
|
static isObjectPath: (_editor: PortableTextEditor, path: Path) => boolean
|
|
19600
19795
|
static marks: (editor: PortableTextEditor) => string[]
|
|
19796
|
+
/**
|
|
19797
|
+
* @deprecated
|
|
19798
|
+
* Use `editor.send(...)` instead
|
|
19799
|
+
*
|
|
19800
|
+
* ```
|
|
19801
|
+
* const editor = useEditor()
|
|
19802
|
+
* editor.send({
|
|
19803
|
+
* type: 'select',
|
|
19804
|
+
* selection: {...},
|
|
19805
|
+
* })
|
|
19806
|
+
* ```
|
|
19807
|
+
*/
|
|
19601
19808
|
static select: (
|
|
19602
19809
|
editor: PortableTextEditor,
|
|
19603
19810
|
selection: EditorSelection | null,
|
|
19604
19811
|
) => void
|
|
19812
|
+
/**
|
|
19813
|
+
* @deprecated
|
|
19814
|
+
* Use `editor.send(...)` instead
|
|
19815
|
+
*
|
|
19816
|
+
* ```
|
|
19817
|
+
* const editor = useEditor()
|
|
19818
|
+
* editor.send({
|
|
19819
|
+
* type: 'annotation.remove',
|
|
19820
|
+
* annotation: {
|
|
19821
|
+
* name: '...',
|
|
19822
|
+
* },
|
|
19823
|
+
* })
|
|
19824
|
+
* ```
|
|
19825
|
+
*/
|
|
19605
19826
|
static removeAnnotation: <
|
|
19606
19827
|
TSchemaType extends {
|
|
19607
19828
|
name: string
|
|
@@ -19610,11 +19831,47 @@ export declare class PortableTextEditor extends Component<
|
|
|
19610
19831
|
editor: PortableTextEditor,
|
|
19611
19832
|
type: TSchemaType,
|
|
19612
19833
|
) => void
|
|
19834
|
+
/**
|
|
19835
|
+
* @deprecated
|
|
19836
|
+
* Use `editor.send(...)` instead
|
|
19837
|
+
*
|
|
19838
|
+
* ```
|
|
19839
|
+
* const editor = useEditor()
|
|
19840
|
+
* editor.send({
|
|
19841
|
+
* type: 'style.toggle',
|
|
19842
|
+
* style: '...',
|
|
19843
|
+
* })
|
|
19844
|
+
* ```
|
|
19845
|
+
*/
|
|
19613
19846
|
static toggleBlockStyle: (
|
|
19614
19847
|
editor: PortableTextEditor,
|
|
19615
19848
|
blockStyle: string,
|
|
19616
19849
|
) => void
|
|
19850
|
+
/**
|
|
19851
|
+
* @deprecated
|
|
19852
|
+
* Use `editor.send(...)` instead
|
|
19853
|
+
*
|
|
19854
|
+
* ```
|
|
19855
|
+
* const editor = useEditor()
|
|
19856
|
+
* editor.send({
|
|
19857
|
+
* type: 'list item.toggle',
|
|
19858
|
+
* listItem: '...',
|
|
19859
|
+
* })
|
|
19860
|
+
* ```
|
|
19861
|
+
*/
|
|
19617
19862
|
static toggleList: (editor: PortableTextEditor, listStyle: string) => void
|
|
19863
|
+
/**
|
|
19864
|
+
* @deprecated
|
|
19865
|
+
* Use `editor.send(...)` instead
|
|
19866
|
+
*
|
|
19867
|
+
* ```
|
|
19868
|
+
* const editor = useEditor()
|
|
19869
|
+
* editor.send({
|
|
19870
|
+
* type: 'decorator.toggle',
|
|
19871
|
+
* decorator: '...',
|
|
19872
|
+
* })
|
|
19873
|
+
* ```
|
|
19874
|
+
*/
|
|
19618
19875
|
static toggleMark: (editor: PortableTextEditor, mark: string) => void
|
|
19619
19876
|
static getFragment: (
|
|
19620
19877
|
editor: PortableTextEditor,
|
package/lib/index.d.ts
CHANGED
|
@@ -19509,11 +19509,46 @@ export declare class PortableTextEditor extends Component<
|
|
|
19509
19509
|
componentDidUpdate(prevProps: PortableTextEditorProps): void
|
|
19510
19510
|
setEditable: (editable: EditableAPI) => void
|
|
19511
19511
|
render(): JSX.Element
|
|
19512
|
+
/**
|
|
19513
|
+
* @deprecated
|
|
19514
|
+
* Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
|
|
19515
|
+
*
|
|
19516
|
+
* ```
|
|
19517
|
+
* import * as selectors from '@portabletext/editor/selectors'
|
|
19518
|
+
* const editor = useEditor()
|
|
19519
|
+
* const isActive = useEditorSelector(editor, selectors.getActiveAnnotations)
|
|
19520
|
+
* ```
|
|
19521
|
+
*/
|
|
19512
19522
|
static activeAnnotations: (editor: PortableTextEditor) => PortableTextObject[]
|
|
19523
|
+
/**
|
|
19524
|
+
* @deprecated
|
|
19525
|
+
* Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
|
|
19526
|
+
*
|
|
19527
|
+
* ```
|
|
19528
|
+
* import * as selectors from '@portabletext/editor/selectors'
|
|
19529
|
+
* const editor = useEditor()
|
|
19530
|
+
* const isActive = useEditorSelector(editor, selectors.isActiveAnnotation(...))
|
|
19531
|
+
* ```
|
|
19532
|
+
*/
|
|
19513
19533
|
static isAnnotationActive: (
|
|
19514
19534
|
editor: PortableTextEditor,
|
|
19515
19535
|
annotationType: PortableTextObject['_type'],
|
|
19516
19536
|
) => boolean
|
|
19537
|
+
/**
|
|
19538
|
+
* @deprecated
|
|
19539
|
+
* Use `editor.send(...)` instead
|
|
19540
|
+
*
|
|
19541
|
+
* ```
|
|
19542
|
+
* const editor = useEditor()
|
|
19543
|
+
* editor.send({
|
|
19544
|
+
* type: 'annotation.add',
|
|
19545
|
+
* annotation: {
|
|
19546
|
+
* name: '...',
|
|
19547
|
+
* value: {...},
|
|
19548
|
+
* }
|
|
19549
|
+
* })
|
|
19550
|
+
* ```
|
|
19551
|
+
*/
|
|
19517
19552
|
static addAnnotation: <
|
|
19518
19553
|
TSchemaType extends {
|
|
19519
19554
|
name: string
|
|
@@ -19525,6 +19560,17 @@ export declare class PortableTextEditor extends Component<
|
|
|
19525
19560
|
[prop: string]: unknown
|
|
19526
19561
|
},
|
|
19527
19562
|
) => AddedAnnotationPaths | undefined
|
|
19563
|
+
/**
|
|
19564
|
+
* @deprecated
|
|
19565
|
+
* Use `editor.send(...)` instead
|
|
19566
|
+
*
|
|
19567
|
+
* ```
|
|
19568
|
+
* const editor = useEditor()
|
|
19569
|
+
* editor.send({
|
|
19570
|
+
* type: 'blur',
|
|
19571
|
+
* })
|
|
19572
|
+
* ```
|
|
19573
|
+
*/
|
|
19528
19574
|
static blur: (editor: PortableTextEditor) => void
|
|
19529
19575
|
static delete: (
|
|
19530
19576
|
editor: PortableTextEditor,
|
|
@@ -19547,28 +19593,150 @@ export declare class PortableTextEditor extends Component<
|
|
|
19547
19593
|
),
|
|
19548
19594
|
Path | undefined,
|
|
19549
19595
|
]
|
|
19596
|
+
/**
|
|
19597
|
+
* @deprecated
|
|
19598
|
+
* Use `editor.send(...)` instead
|
|
19599
|
+
*
|
|
19600
|
+
* ```
|
|
19601
|
+
* const editor = useEditor()
|
|
19602
|
+
* editor.send({
|
|
19603
|
+
* type: 'focus',
|
|
19604
|
+
* })
|
|
19605
|
+
* ```
|
|
19606
|
+
*/
|
|
19550
19607
|
static focus: (editor: PortableTextEditor) => void
|
|
19608
|
+
/**
|
|
19609
|
+
* @deprecated
|
|
19610
|
+
* Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
|
|
19611
|
+
*
|
|
19612
|
+
* ```
|
|
19613
|
+
* import * as selectors from '@portabletext/editor/selectors'
|
|
19614
|
+
* const editor = useEditor()
|
|
19615
|
+
* const focusBlock = useEditorSelector(editor, selectors.getFocusBlock)
|
|
19616
|
+
* ```
|
|
19617
|
+
*/
|
|
19551
19618
|
static focusBlock: (
|
|
19552
19619
|
editor: PortableTextEditor,
|
|
19553
19620
|
) => PortableTextBlock | undefined
|
|
19621
|
+
/**
|
|
19622
|
+
* @deprecated
|
|
19623
|
+
* Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
|
|
19624
|
+
*
|
|
19625
|
+
* ```
|
|
19626
|
+
* import * as selectors from '@portabletext/editor/selectors'
|
|
19627
|
+
* const editor = useEditor()
|
|
19628
|
+
* const focusChild = useEditorSelector(editor, selectors.getFocusChild)
|
|
19629
|
+
* ```
|
|
19630
|
+
*/
|
|
19554
19631
|
static focusChild: (
|
|
19555
19632
|
editor: PortableTextEditor,
|
|
19556
19633
|
) => PortableTextChild | undefined
|
|
19634
|
+
/**
|
|
19635
|
+
* @deprecated
|
|
19636
|
+
* Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
|
|
19637
|
+
*
|
|
19638
|
+
* ```
|
|
19639
|
+
* import * as selectors from '@portabletext/editor/selectors'
|
|
19640
|
+
* const editor = useEditor()
|
|
19641
|
+
* const selection = useEditorSelector(editor, selectors.getSelection)
|
|
19642
|
+
* ```
|
|
19643
|
+
*/
|
|
19557
19644
|
static getSelection: (editor: PortableTextEditor) => EditorSelection
|
|
19645
|
+
/**
|
|
19646
|
+
* @deprecated
|
|
19647
|
+
* Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
|
|
19648
|
+
*
|
|
19649
|
+
* ```
|
|
19650
|
+
* import * as selectors from '@portabletext/editor/selectors'
|
|
19651
|
+
* const editor = useEditor()
|
|
19652
|
+
* const value = useEditorSelector(editor, selectors.getValue)
|
|
19653
|
+
* ```
|
|
19654
|
+
*/
|
|
19558
19655
|
static getValue: (
|
|
19559
19656
|
editor: PortableTextEditor,
|
|
19560
19657
|
) => PortableTextBlock[] | undefined
|
|
19658
|
+
/**
|
|
19659
|
+
* @deprecated
|
|
19660
|
+
* Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
|
|
19661
|
+
*
|
|
19662
|
+
* ```
|
|
19663
|
+
* import * as selectors from '@portabletext/editor/selectors'
|
|
19664
|
+
* const editor = useEditor()
|
|
19665
|
+
* const isActive = useEditorSelector(editor, selectors.isActiveStyle(...))
|
|
19666
|
+
* ```
|
|
19667
|
+
*/
|
|
19561
19668
|
static hasBlockStyle: (
|
|
19562
19669
|
editor: PortableTextEditor,
|
|
19563
19670
|
blockStyle: string,
|
|
19564
19671
|
) => boolean
|
|
19672
|
+
/**
|
|
19673
|
+
* @deprecated
|
|
19674
|
+
* Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
|
|
19675
|
+
*
|
|
19676
|
+
* ```
|
|
19677
|
+
* import * as selectors from '@portabletext/editor/selectors'
|
|
19678
|
+
* const editor = useEditor()
|
|
19679
|
+
* const isActive = useEditorSelector(editor, selectors.isActiveListItem(...))
|
|
19680
|
+
* ```
|
|
19681
|
+
*/
|
|
19565
19682
|
static hasListStyle: (
|
|
19566
19683
|
editor: PortableTextEditor,
|
|
19567
19684
|
listStyle: string,
|
|
19568
19685
|
) => boolean
|
|
19686
|
+
/**
|
|
19687
|
+
* @deprecated
|
|
19688
|
+
* Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
|
|
19689
|
+
*
|
|
19690
|
+
* ```
|
|
19691
|
+
* import * as selectors from '@portabletext/editor/selectors'
|
|
19692
|
+
* const editor = useEditor()
|
|
19693
|
+
* const isSelectionCollapsed = useEditorSelector(editor, selectors.isSelectionCollapsed)
|
|
19694
|
+
* ```
|
|
19695
|
+
*/
|
|
19569
19696
|
static isCollapsedSelection: (editor: PortableTextEditor) => boolean
|
|
19697
|
+
/**
|
|
19698
|
+
* @deprecated
|
|
19699
|
+
* Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
|
|
19700
|
+
*
|
|
19701
|
+
* ```
|
|
19702
|
+
* import * as selectors from '@portabletext/editor/selectors'
|
|
19703
|
+
* const editor = useEditor()
|
|
19704
|
+
* const isSelectionExpanded = useEditorSelector(editor, selectors.isSelectionExpanded)
|
|
19705
|
+
* ```
|
|
19706
|
+
*/
|
|
19570
19707
|
static isExpandedSelection: (editor: PortableTextEditor) => boolean
|
|
19708
|
+
/**
|
|
19709
|
+
* @deprecated
|
|
19710
|
+
* Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
|
|
19711
|
+
*
|
|
19712
|
+
* ```
|
|
19713
|
+
* import * as selectors from '@portabletext/editor/selectors'
|
|
19714
|
+
* const editor = useEditor()
|
|
19715
|
+
* const isActive = useEditorSelector(editor, selectors.isActiveDecorator(...))
|
|
19716
|
+
* ```
|
|
19717
|
+
*/
|
|
19571
19718
|
static isMarkActive: (editor: PortableTextEditor, mark: string) => boolean
|
|
19719
|
+
/**
|
|
19720
|
+
* @deprecated
|
|
19721
|
+
* Use `editor.send(...)` instead
|
|
19722
|
+
*
|
|
19723
|
+
* ```
|
|
19724
|
+
* const editor = useEditor()
|
|
19725
|
+
* editor.send({
|
|
19726
|
+
* type: 'insert.span',
|
|
19727
|
+
* text: '...',
|
|
19728
|
+
* annotations: [{name: '...', value: {...}}],
|
|
19729
|
+
* decorators: ['...'],
|
|
19730
|
+
* })
|
|
19731
|
+
* editor.send({
|
|
19732
|
+
* type: 'insert.inline object',
|
|
19733
|
+
* inlineObject: {
|
|
19734
|
+
* name: '...',
|
|
19735
|
+
* value: {...},
|
|
19736
|
+
* },
|
|
19737
|
+
* })
|
|
19738
|
+
* ```
|
|
19739
|
+
*/
|
|
19572
19740
|
static insertChild: <
|
|
19573
19741
|
TSchemaType extends {
|
|
19574
19742
|
name: string
|
|
@@ -19580,6 +19748,22 @@ export declare class PortableTextEditor extends Component<
|
|
|
19580
19748
|
[prop: string]: unknown
|
|
19581
19749
|
},
|
|
19582
19750
|
) => Path | undefined
|
|
19751
|
+
/**
|
|
19752
|
+
* @deprecated
|
|
19753
|
+
* Use `editor.send(...)` instead
|
|
19754
|
+
*
|
|
19755
|
+
* ```
|
|
19756
|
+
* const editor = useEditor()
|
|
19757
|
+
* editor.send({
|
|
19758
|
+
* type: 'insert.block object',
|
|
19759
|
+
* blockObject: {
|
|
19760
|
+
* name: '...',
|
|
19761
|
+
* value: {...},
|
|
19762
|
+
* },
|
|
19763
|
+
* placement: 'auto' | 'after' | 'before',
|
|
19764
|
+
* })
|
|
19765
|
+
* ```
|
|
19766
|
+
*/
|
|
19583
19767
|
static insertBlock: <
|
|
19584
19768
|
TSchemaType extends {
|
|
19585
19769
|
name: string
|
|
@@ -19591,6 +19775,17 @@ export declare class PortableTextEditor extends Component<
|
|
|
19591
19775
|
[prop: string]: unknown
|
|
19592
19776
|
},
|
|
19593
19777
|
) => Path | undefined
|
|
19778
|
+
/**
|
|
19779
|
+
* @deprecated
|
|
19780
|
+
* Use `editor.send(...)` instead
|
|
19781
|
+
*
|
|
19782
|
+
* ```
|
|
19783
|
+
* const editor = useEditor()
|
|
19784
|
+
* editor.send({
|
|
19785
|
+
* type: 'insert.break',
|
|
19786
|
+
* })
|
|
19787
|
+
* ```
|
|
19788
|
+
*/
|
|
19594
19789
|
static insertBreak: (editor: PortableTextEditor) => void
|
|
19595
19790
|
static isVoid: (
|
|
19596
19791
|
editor: PortableTextEditor,
|
|
@@ -19598,10 +19793,36 @@ export declare class PortableTextEditor extends Component<
|
|
|
19598
19793
|
) => boolean
|
|
19599
19794
|
static isObjectPath: (_editor: PortableTextEditor, path: Path) => boolean
|
|
19600
19795
|
static marks: (editor: PortableTextEditor) => string[]
|
|
19796
|
+
/**
|
|
19797
|
+
* @deprecated
|
|
19798
|
+
* Use `editor.send(...)` instead
|
|
19799
|
+
*
|
|
19800
|
+
* ```
|
|
19801
|
+
* const editor = useEditor()
|
|
19802
|
+
* editor.send({
|
|
19803
|
+
* type: 'select',
|
|
19804
|
+
* selection: {...},
|
|
19805
|
+
* })
|
|
19806
|
+
* ```
|
|
19807
|
+
*/
|
|
19601
19808
|
static select: (
|
|
19602
19809
|
editor: PortableTextEditor,
|
|
19603
19810
|
selection: EditorSelection | null,
|
|
19604
19811
|
) => void
|
|
19812
|
+
/**
|
|
19813
|
+
* @deprecated
|
|
19814
|
+
* Use `editor.send(...)` instead
|
|
19815
|
+
*
|
|
19816
|
+
* ```
|
|
19817
|
+
* const editor = useEditor()
|
|
19818
|
+
* editor.send({
|
|
19819
|
+
* type: 'annotation.remove',
|
|
19820
|
+
* annotation: {
|
|
19821
|
+
* name: '...',
|
|
19822
|
+
* },
|
|
19823
|
+
* })
|
|
19824
|
+
* ```
|
|
19825
|
+
*/
|
|
19605
19826
|
static removeAnnotation: <
|
|
19606
19827
|
TSchemaType extends {
|
|
19607
19828
|
name: string
|
|
@@ -19610,11 +19831,47 @@ export declare class PortableTextEditor extends Component<
|
|
|
19610
19831
|
editor: PortableTextEditor,
|
|
19611
19832
|
type: TSchemaType,
|
|
19612
19833
|
) => void
|
|
19834
|
+
/**
|
|
19835
|
+
* @deprecated
|
|
19836
|
+
* Use `editor.send(...)` instead
|
|
19837
|
+
*
|
|
19838
|
+
* ```
|
|
19839
|
+
* const editor = useEditor()
|
|
19840
|
+
* editor.send({
|
|
19841
|
+
* type: 'style.toggle',
|
|
19842
|
+
* style: '...',
|
|
19843
|
+
* })
|
|
19844
|
+
* ```
|
|
19845
|
+
*/
|
|
19613
19846
|
static toggleBlockStyle: (
|
|
19614
19847
|
editor: PortableTextEditor,
|
|
19615
19848
|
blockStyle: string,
|
|
19616
19849
|
) => void
|
|
19850
|
+
/**
|
|
19851
|
+
* @deprecated
|
|
19852
|
+
* Use `editor.send(...)` instead
|
|
19853
|
+
*
|
|
19854
|
+
* ```
|
|
19855
|
+
* const editor = useEditor()
|
|
19856
|
+
* editor.send({
|
|
19857
|
+
* type: 'list item.toggle',
|
|
19858
|
+
* listItem: '...',
|
|
19859
|
+
* })
|
|
19860
|
+
* ```
|
|
19861
|
+
*/
|
|
19617
19862
|
static toggleList: (editor: PortableTextEditor, listStyle: string) => void
|
|
19863
|
+
/**
|
|
19864
|
+
* @deprecated
|
|
19865
|
+
* Use `editor.send(...)` instead
|
|
19866
|
+
*
|
|
19867
|
+
* ```
|
|
19868
|
+
* const editor = useEditor()
|
|
19869
|
+
* editor.send({
|
|
19870
|
+
* type: 'decorator.toggle',
|
|
19871
|
+
* decorator: '...',
|
|
19872
|
+
* })
|
|
19873
|
+
* ```
|
|
19874
|
+
*/
|
|
19618
19875
|
static toggleMark: (editor: PortableTextEditor, mark: string) => void
|
|
19619
19876
|
static getFragment: (
|
|
19620
19877
|
editor: PortableTextEditor,
|