@portabletext/editor 1.48.10 → 1.48.11
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/lib/_chunks-cjs/editor-provider.cjs +776 -122
- package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.get-focus-inline-object.cjs +2 -2
- package/lib/_chunks-cjs/selector.get-focus-inline-object.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.get-text-before.cjs +2 -2
- package/lib/_chunks-cjs/selector.get-text-before.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs +464 -19
- package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs.map +1 -1
- package/lib/_chunks-cjs/util.selection-point-to-block-offset.cjs +9 -1
- package/lib/_chunks-cjs/util.selection-point-to-block-offset.cjs.map +1 -1
- package/lib/_chunks-cjs/util.slice-blocks.cjs +2 -2
- package/lib/_chunks-es/editor-provider.js +670 -18
- package/lib/_chunks-es/editor-provider.js.map +1 -1
- package/lib/_chunks-es/selector.get-focus-inline-object.js +1 -1
- package/lib/_chunks-es/selector.get-text-before.js +1 -1
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js +448 -3
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js.map +1 -1
- package/lib/_chunks-es/util.selection-point-to-block-offset.js +9 -1
- package/lib/_chunks-es/util.selection-point-to-block-offset.js.map +1 -1
- package/lib/_chunks-es/util.slice-blocks.js +2 -2
- package/lib/behaviors/index.cjs +27 -377
- package/lib/behaviors/index.cjs.map +1 -1
- package/lib/behaviors/index.d.cts +2863 -13243
- package/lib/behaviors/index.d.ts +2863 -13243
- package/lib/behaviors/index.js +22 -377
- package/lib/behaviors/index.js.map +1 -1
- package/lib/index.cjs +17 -17
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +2563 -110
- package/lib/index.d.ts +2563 -110
- package/lib/index.js +4 -5
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.cjs +347 -30
- package/lib/plugins/index.cjs.map +1 -1
- package/lib/plugins/index.d.cts +2563 -111
- package/lib/plugins/index.d.ts +2563 -111
- package/lib/plugins/index.js +324 -8
- package/lib/plugins/index.js.map +1 -1
- package/lib/selectors/index.cjs +29 -29
- package/lib/selectors/index.cjs.map +1 -1
- package/lib/selectors/index.d.cts +2562 -103
- package/lib/selectors/index.d.ts +2562 -103
- package/lib/selectors/index.js +2 -3
- package/lib/selectors/index.js.map +1 -1
- package/lib/utils/index.cjs +5 -5
- package/lib/utils/index.cjs.map +1 -1
- package/lib/utils/index.d.cts +2563 -105
- package/lib/utils/index.d.ts +2563 -105
- package/lib/utils/index.js +2 -3
- package/lib/utils/index.js.map +1 -1
- package/package.json +3 -3
- package/src/behaviors/behavior.emoji-picker.ts +0 -6
- package/src/behaviors/behavior.markdown.ts +0 -48
- package/src/behaviors/index.ts +0 -15
- package/src/editor/create-editor.ts +0 -3
- package/src/editor/editor-machine.ts +1 -13
- package/src/internal-utils/__tests__/operationToPatches.test.ts +0 -2
- package/src/internal-utils/__tests__/patchToOperations.test.ts +0 -2
- package/src/plugins/plugin.core.tsx +1 -1
- package/lib/_chunks-cjs/behavior.core.cjs +0 -700
- package/lib/_chunks-cjs/behavior.core.cjs.map +0 -1
- package/lib/_chunks-cjs/behavior.markdown.cjs +0 -321
- package/lib/_chunks-cjs/behavior.markdown.cjs.map +0 -1
- package/lib/_chunks-cjs/selector.is-overlapping-selection.cjs +0 -449
- package/lib/_chunks-cjs/selector.is-overlapping-selection.cjs.map +0 -1
- package/lib/_chunks-cjs/util.get-selection-start-point.cjs +0 -10
- package/lib/_chunks-cjs/util.get-selection-start-point.cjs.map +0 -1
- package/lib/_chunks-es/behavior.core.js +0 -703
- package/lib/_chunks-es/behavior.core.js.map +0 -1
- package/lib/_chunks-es/behavior.markdown.js +0 -325
- package/lib/_chunks-es/behavior.markdown.js.map +0 -1
- package/lib/_chunks-es/selector.is-overlapping-selection.js +0 -451
- package/lib/_chunks-es/selector.is-overlapping-selection.js.map +0 -1
- package/lib/_chunks-es/util.get-selection-start-point.js +0 -11
- package/lib/_chunks-es/util.get-selection-start-point.js.map +0 -1
- package/src/behaviors/behavior.code-editor.ts +0 -77
- package/src/behaviors/behavior.links.ts +0 -84
- package/src/internal-utils/looks-like-url.test.ts +0 -19
- package/src/internal-utils/looks-like-url.ts +0 -15
package/lib/utils/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { isEqualSelectionPoints, sliceBlocks, isSpan
|
|
1
|
+
import { isEqualSelectionPoints, sliceBlocks, isSpan } from "../_chunks-es/util.slice-blocks.js";
|
|
2
2
|
import { blockOffsetToSpanSelectionPoint, getBlockEndPoint, getBlockStartPoint, getTextBlockText, isEmptyTextBlock, isKeyedSegment, reverseSelection, spanSelectionPointToBlockOffset } from "../_chunks-es/util.slice-blocks.js";
|
|
3
|
-
import { blockOffsetToBlockSelectionPoint, blockOffsetToSelectionPoint, blockOffsetsToSelection, childSelectionPointToBlockOffset, selectionPointToBlockOffset } from "../_chunks-es/util.selection-point-to-block-offset.js";
|
|
4
|
-
import { getSelectionEndPoint, getSelectionStartPoint } from "../_chunks-es/util.get-selection-start-point.js";
|
|
3
|
+
import { blockOffsetToBlockSelectionPoint, blockOffsetToSelectionPoint, blockOffsetsToSelection, childSelectionPointToBlockOffset, getSelectionEndPoint, getSelectionStartPoint, selectionPointToBlockOffset } from "../_chunks-es/util.selection-point-to-block-offset.js";
|
|
5
4
|
import { isSelectionCollapsed } from "../_chunks-es/util.is-selection-collapsed.js";
|
|
6
5
|
import { isTextBlock } from "../_chunks-es/util.merge-text-blocks.js";
|
|
7
6
|
import { mergeTextBlocks } from "../_chunks-es/util.merge-text-blocks.js";
|
package/lib/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/utils/util.is-equal-selections.ts","../../src/utils/util.split-text-block.ts"],"sourcesContent":["import type {EditorSelection} from '../types/editor'\nimport {isEqualSelectionPoints} from './util.is-equal-selection-points'\n\n/**\n * @public\n */\nexport function isEqualSelections(a: EditorSelection, b: EditorSelection) {\n if (!a && !b) {\n return true\n }\n\n if (!a || !b) {\n return false\n }\n\n return (\n isEqualSelectionPoints(a.anchor, b.anchor) &&\n isEqualSelectionPoints(a.focus, b.focus)\n )\n}\n","import type {PortableTextTextBlock} from '@sanity/types'\nimport type {EditorSelectionPoint} from '..'\nimport type {EditorContext} from '../editor/editor-snapshot'\nimport {isSpan} from './util.is-span'\nimport {isTextBlock} from './util.is-text-block'\nimport {sliceBlocks} from './util.slice-blocks'\n\n/**\n * @beta\n */\nexport function splitTextBlock({\n context,\n block,\n point,\n}: {\n context: Pick<EditorContext, 'schema'>\n block: PortableTextTextBlock\n point: EditorSelectionPoint\n}): {before: PortableTextTextBlock; after: PortableTextTextBlock} | undefined {\n const firstChild = block.children.at(0)\n const lastChild = block.children.at(block.children.length - 1)\n\n if (!firstChild || !lastChild) {\n return undefined\n }\n\n const before = sliceBlocks({\n context: {\n schema: context.schema,\n selection: {\n anchor: {\n path: [{_key: block._key}, 'children', {_key: firstChild._key}],\n offset: 0,\n },\n focus: point,\n },\n },\n blocks: [block],\n }).at(0)\n const after = sliceBlocks({\n context: {\n schema: context.schema,\n selection: {\n anchor: point,\n focus: {\n path: [{_key: block._key}, 'children', {_key: lastChild._key}],\n offset: isSpan(context, lastChild) ? lastChild.text.length : 0,\n },\n },\n },\n blocks: [block],\n }).at(0)\n\n if (!before || !after) {\n return undefined\n }\n\n if (!isTextBlock(context, before) || !isTextBlock(context, after)) {\n return undefined\n }\n\n return {before, after}\n}\n"],"names":["isEqualSelections","a","b","isEqualSelectionPoints","anchor","focus","splitTextBlock","context","block","point","firstChild","children","at","lastChild","length","before","sliceBlocks","schema","selection","path","_key","offset","blocks","after","isSpan","text","isTextBlock"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/utils/util.is-equal-selections.ts","../../src/utils/util.split-text-block.ts"],"sourcesContent":["import type {EditorSelection} from '../types/editor'\nimport {isEqualSelectionPoints} from './util.is-equal-selection-points'\n\n/**\n * @public\n */\nexport function isEqualSelections(a: EditorSelection, b: EditorSelection) {\n if (!a && !b) {\n return true\n }\n\n if (!a || !b) {\n return false\n }\n\n return (\n isEqualSelectionPoints(a.anchor, b.anchor) &&\n isEqualSelectionPoints(a.focus, b.focus)\n )\n}\n","import type {PortableTextTextBlock} from '@sanity/types'\nimport type {EditorSelectionPoint} from '..'\nimport type {EditorContext} from '../editor/editor-snapshot'\nimport {isSpan} from './util.is-span'\nimport {isTextBlock} from './util.is-text-block'\nimport {sliceBlocks} from './util.slice-blocks'\n\n/**\n * @beta\n */\nexport function splitTextBlock({\n context,\n block,\n point,\n}: {\n context: Pick<EditorContext, 'schema'>\n block: PortableTextTextBlock\n point: EditorSelectionPoint\n}): {before: PortableTextTextBlock; after: PortableTextTextBlock} | undefined {\n const firstChild = block.children.at(0)\n const lastChild = block.children.at(block.children.length - 1)\n\n if (!firstChild || !lastChild) {\n return undefined\n }\n\n const before = sliceBlocks({\n context: {\n schema: context.schema,\n selection: {\n anchor: {\n path: [{_key: block._key}, 'children', {_key: firstChild._key}],\n offset: 0,\n },\n focus: point,\n },\n },\n blocks: [block],\n }).at(0)\n const after = sliceBlocks({\n context: {\n schema: context.schema,\n selection: {\n anchor: point,\n focus: {\n path: [{_key: block._key}, 'children', {_key: lastChild._key}],\n offset: isSpan(context, lastChild) ? lastChild.text.length : 0,\n },\n },\n },\n blocks: [block],\n }).at(0)\n\n if (!before || !after) {\n return undefined\n }\n\n if (!isTextBlock(context, before) || !isTextBlock(context, after)) {\n return undefined\n }\n\n return {before, after}\n}\n"],"names":["isEqualSelections","a","b","isEqualSelectionPoints","anchor","focus","splitTextBlock","context","block","point","firstChild","children","at","lastChild","length","before","sliceBlocks","schema","selection","path","_key","offset","blocks","after","isSpan","text","isTextBlock"],"mappings":";;;;;;AAMgBA,SAAAA,kBAAkBC,GAAoBC,GAAoB;AACpE,SAAA,CAACD,KAAK,CAACC,IACF,KAGL,CAACD,KAAK,CAACC,IACF,KAIPC,uBAAuBF,EAAEG,QAAQF,EAAEE,MAAM,KACzCD,uBAAuBF,EAAEI,OAAOH,EAAEG,KAAK;AAE3C;ACTO,SAASC,eAAe;AAAA,EAC7BC;AAAAA,EACAC;AAAAA,EACAC;AAKF,GAA8E;AAC5E,QAAMC,aAAaF,MAAMG,SAASC,GAAG,CAAC,GAChCC,YAAYL,MAAMG,SAASC,GAAGJ,MAAMG,SAASG,SAAS,CAAC;AAEzD,MAAA,CAACJ,cAAc,CAACG;AAClB;AAGF,QAAME,SAASC,YAAY;AAAA,IACzBT,SAAS;AAAA,MACPU,QAAQV,QAAQU;AAAAA,MAChBC,WAAW;AAAA,QACTd,QAAQ;AAAA,UACNe,MAAM,CAAC;AAAA,YAACC,MAAMZ,MAAMY;AAAAA,aAAO,YAAY;AAAA,YAACA,MAAMV,WAAWU;AAAAA,UAAAA,CAAK;AAAA,UAC9DC,QAAQ;AAAA,QACV;AAAA,QACAhB,OAAOI;AAAAA,MAAAA;AAAAA,IAEX;AAAA,IACAa,QAAQ,CAACd,KAAK;AAAA,EACf,CAAA,EAAEI,GAAG,CAAC,GACDW,QAAQP,YAAY;AAAA,IACxBT,SAAS;AAAA,MACPU,QAAQV,QAAQU;AAAAA,MAChBC,WAAW;AAAA,QACTd,QAAQK;AAAAA,QACRJ,OAAO;AAAA,UACLc,MAAM,CAAC;AAAA,YAACC,MAAMZ,MAAMY;AAAAA,aAAO,YAAY;AAAA,YAACA,MAAMP,UAAUO;AAAAA,UAAAA,CAAK;AAAA,UAC7DC,QAAQG,OAAOjB,SAASM,SAAS,IAAIA,UAAUY,KAAKX,SAAS;AAAA,QAAA;AAAA,MAC/D;AAAA,IAEJ;AAAA,IACAQ,QAAQ,CAACd,KAAK;AAAA,EAAA,CACf,EAAEI,GAAG,CAAC;AAEP,MAAI,EAACG,CAAAA,UAAU,CAACQ,UAIZ,EAACG,CAAAA,YAAYnB,SAASQ,MAAM,KAAK,CAACW,YAAYnB,SAASgB,KAAK;AAIzD,WAAA;AAAA,MAACR;AAAAA,MAAQQ;AAAAA,IAAK;AACvB;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@portabletext/editor",
|
|
3
|
-
"version": "1.48.
|
|
3
|
+
"version": "1.48.11",
|
|
4
4
|
"description": "Portable Text Editor made in React",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -79,8 +79,8 @@
|
|
|
79
79
|
"slate-react": "0.114.2",
|
|
80
80
|
"use-effect-event": "^1.0.2",
|
|
81
81
|
"xstate": "^5.19.2",
|
|
82
|
-
"@portabletext/
|
|
83
|
-
"@portabletext/
|
|
82
|
+
"@portabletext/block-tools": "1.1.22",
|
|
83
|
+
"@portabletext/patches": "1.1.3"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
86
|
"@portabletext/toolkit": "^2.0.17",
|
|
@@ -8,9 +8,6 @@ const emojiCharRegEx = /^[a-zA-Z-_0-9]{1}$/
|
|
|
8
8
|
const incompleteEmojiRegEx = /:([a-zA-Z-_0-9]+)$/
|
|
9
9
|
const emojiRegEx = /:([a-zA-Z-_0-9]+):$/
|
|
10
10
|
|
|
11
|
-
/**
|
|
12
|
-
* @beta
|
|
13
|
-
*/
|
|
14
11
|
export type EmojiPickerBehaviorsConfig<TEmojiMatch> = {
|
|
15
12
|
/**
|
|
16
13
|
* Match emojis by keyword.
|
|
@@ -24,9 +21,6 @@ export type EmojiPickerBehaviorsConfig<TEmojiMatch> = {
|
|
|
24
21
|
parseMatch: ({match}: {match: TEmojiMatch}) => string | undefined
|
|
25
22
|
}
|
|
26
23
|
|
|
27
|
-
/**
|
|
28
|
-
* @beta
|
|
29
|
-
*/
|
|
30
24
|
export function createEmojiPickerBehaviors<TEmojiMatch>(
|
|
31
25
|
config: EmojiPickerBehaviorsConfig<TEmojiMatch>,
|
|
32
26
|
) {
|
|
@@ -6,9 +6,6 @@ import {getTextBlockText} from '../utils/util.get-text-block-text'
|
|
|
6
6
|
import {execute} from './behavior.types.action'
|
|
7
7
|
import {defineBehavior} from './behavior.types.behavior'
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* @beta
|
|
11
|
-
*/
|
|
12
9
|
export type MarkdownBehaviorsConfig = {
|
|
13
10
|
horizontalRuleObject?: (context: {
|
|
14
11
|
schema: EditorSchema
|
|
@@ -23,51 +20,6 @@ export type MarkdownBehaviorsConfig = {
|
|
|
23
20
|
orderedListStyle?: (context: {schema: EditorSchema}) => string | undefined
|
|
24
21
|
}
|
|
25
22
|
|
|
26
|
-
/**
|
|
27
|
-
* @beta
|
|
28
|
-
* Create markdown behaviors for common markdown actions such as converting ### to headings, --- to HRs, and more.
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* Configure the bundled markdown behaviors
|
|
32
|
-
* ```ts
|
|
33
|
-
* import {EditorProvider} from '@portabletext/editor'
|
|
34
|
-
* import {createMarkdownBehaviors, coreBehaviors} from '@portabletext/editor/behaviors'
|
|
35
|
-
*
|
|
36
|
-
* function App() {
|
|
37
|
-
* return (
|
|
38
|
-
* <EditorProvider
|
|
39
|
-
* initialConfig={{
|
|
40
|
-
* behaviors: [
|
|
41
|
-
* ...coreBehaviors,
|
|
42
|
-
* ...createMarkdownBehaviors({
|
|
43
|
-
* horizontalRuleObject: ({schema}) => {
|
|
44
|
-
* const name = schema.blockObjects.find(
|
|
45
|
-
* (object) => object.name === 'break',
|
|
46
|
-
* )?.name
|
|
47
|
-
* return name ? {name} : undefined
|
|
48
|
-
* },
|
|
49
|
-
* defaultStyle: ({schema}) => schema.styles[0].value,
|
|
50
|
-
* headingStyle: ({schema, level}) =>
|
|
51
|
-
* schema.styles.find((style) => style.value === `h${level}`)
|
|
52
|
-
* ?.value,
|
|
53
|
-
* blockquoteStyle: ({schema}) =>
|
|
54
|
-
* schema.styles.find((style) => style.value === 'blockquote')
|
|
55
|
-
* ?.value,
|
|
56
|
-
* unorderedListStyle: ({schema}) =>
|
|
57
|
-
* schema.lists.find((list) => list.value === 'bullet')?.value,
|
|
58
|
-
* orderedListStyle: ({schema}) =>
|
|
59
|
-
* schema.lists.find((list) => list.value === 'number')?.value,
|
|
60
|
-
* }),
|
|
61
|
-
* ]
|
|
62
|
-
* }}
|
|
63
|
-
* >
|
|
64
|
-
* {...}
|
|
65
|
-
* </EditorProvider>
|
|
66
|
-
* )
|
|
67
|
-
* }
|
|
68
|
-
* ```
|
|
69
|
-
*
|
|
70
|
-
*/
|
|
71
23
|
export function createMarkdownBehaviors(config: MarkdownBehaviorsConfig) {
|
|
72
24
|
const automaticBlockquoteOnSpace = defineBehavior({
|
|
73
25
|
on: 'insert.text',
|
package/src/behaviors/index.ts
CHANGED
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
createCodeEditorBehaviors,
|
|
3
|
-
type CodeEditorBehaviorsConfig,
|
|
4
|
-
} from './behavior.code-editor'
|
|
5
|
-
export {coreBehaviors} from './behavior.core'
|
|
6
|
-
export {
|
|
7
|
-
createEmojiPickerBehaviors,
|
|
8
|
-
type EmojiPickerBehaviorsConfig,
|
|
9
|
-
} from './behavior.emoji-picker'
|
|
10
|
-
export {createLinkBehaviors, type LinkBehaviorsConfig} from './behavior.links'
|
|
11
|
-
export {
|
|
12
|
-
createMarkdownBehaviors,
|
|
13
|
-
type MarkdownBehaviorsConfig,
|
|
14
|
-
} from './behavior.markdown'
|
|
15
|
-
|
|
16
1
|
export {
|
|
17
2
|
execute,
|
|
18
3
|
forward,
|
|
@@ -33,7 +33,6 @@ export type EditorConfig = {
|
|
|
33
33
|
/**
|
|
34
34
|
* @beta
|
|
35
35
|
*/
|
|
36
|
-
behaviors?: Array<Behavior>
|
|
37
36
|
keyGenerator?: () => string
|
|
38
37
|
/**
|
|
39
38
|
* @deprecated Will be removed in the next major version
|
|
@@ -98,7 +97,6 @@ export function editorConfigToMachineInput(config: EditorConfig) {
|
|
|
98
97
|
const {legacySchema, schema} = compileSchemasFromEditorConfig(config)
|
|
99
98
|
|
|
100
99
|
return {
|
|
101
|
-
behaviors: config.behaviors,
|
|
102
100
|
converters: createCoreConverters(legacySchema),
|
|
103
101
|
getLegacySchema: () => legacySchema,
|
|
104
102
|
keyGenerator: config.keyGenerator ?? defaultKeyGenerator,
|
|
@@ -136,7 +134,6 @@ export function createInternalEditor(editorActor: EditorActor): InternalEditor {
|
|
|
136
134
|
switch (event.type) {
|
|
137
135
|
case 'add behavior':
|
|
138
136
|
case 'remove behavior':
|
|
139
|
-
case 'update behaviors':
|
|
140
137
|
case 'update key generator':
|
|
141
138
|
case 'update readOnly':
|
|
142
139
|
case 'patches':
|
|
@@ -71,10 +71,6 @@ export type ExternalEditorEvent =
|
|
|
71
71
|
type: 'update schema'
|
|
72
72
|
schema: EditorSchema
|
|
73
73
|
}
|
|
74
|
-
| {
|
|
75
|
-
type: 'update behaviors'
|
|
76
|
-
behaviors: Array<Behavior>
|
|
77
|
-
}
|
|
78
74
|
| {
|
|
79
75
|
type: 'update key generator'
|
|
80
76
|
keyGenerator: () => string
|
|
@@ -237,7 +233,6 @@ export const editorMachine = setup({
|
|
|
237
233
|
events: {} as InternalEditorEvent,
|
|
238
234
|
emitted: {} as InternalEditorEmittedEvent,
|
|
239
235
|
input: {} as {
|
|
240
|
-
behaviors?: Array<Behavior>
|
|
241
236
|
converters?: Array<Converter>
|
|
242
237
|
getLegacySchema: () => PortableTextMemberSchemaTypes
|
|
243
238
|
keyGenerator: () => string
|
|
@@ -265,12 +260,6 @@ export const editorMachine = setup({
|
|
|
265
260
|
return new Set([...context.behaviors])
|
|
266
261
|
},
|
|
267
262
|
}),
|
|
268
|
-
'assign behaviors': assign({
|
|
269
|
-
behaviors: ({event}) => {
|
|
270
|
-
assertEvent(event, 'update behaviors')
|
|
271
|
-
return new Set([...event.behaviors])
|
|
272
|
-
},
|
|
273
|
-
}),
|
|
274
263
|
'assign schema': assign({
|
|
275
264
|
schema: ({event}) => {
|
|
276
265
|
assertEvent(event, 'update schema')
|
|
@@ -386,7 +375,7 @@ export const editorMachine = setup({
|
|
|
386
375
|
}).createMachine({
|
|
387
376
|
id: 'editor',
|
|
388
377
|
context: ({input}) => ({
|
|
389
|
-
behaviors: new Set([...
|
|
378
|
+
behaviors: new Set([...coreBehaviors]),
|
|
390
379
|
converters: new Set(input.converters ?? []),
|
|
391
380
|
getLegacySchema: input.getLegacySchema,
|
|
392
381
|
keyGenerator: input.keyGenerator,
|
|
@@ -424,7 +413,6 @@ export const editorMachine = setup({
|
|
|
424
413
|
|
|
425
414
|
'add behavior': {actions: 'add behavior to context'},
|
|
426
415
|
'remove behavior': {actions: 'remove behavior from context'},
|
|
427
|
-
'update behaviors': {actions: 'assign behaviors'},
|
|
428
416
|
'update key generator': {
|
|
429
417
|
actions: assign({keyGenerator: ({event}) => event.keyGenerator}),
|
|
430
418
|
},
|
|
@@ -2,7 +2,6 @@ import type {PortableTextTextBlock} from '@sanity/types'
|
|
|
2
2
|
import {createEditor, type Descendant} from 'slate'
|
|
3
3
|
import {beforeEach, describe, expect, it} from 'vitest'
|
|
4
4
|
import {createActor} from 'xstate'
|
|
5
|
-
import {coreBehaviors} from '../../behaviors/behavior.core'
|
|
6
5
|
import {schemaType} from '../../editor/__tests__/PortableTextEditorTester'
|
|
7
6
|
import {editorMachine} from '../../editor/editor-machine'
|
|
8
7
|
import {legacySchemaToEditorSchema} from '../../editor/editor-schema'
|
|
@@ -15,7 +14,6 @@ const legacySchema = createLegacySchema(schemaType)
|
|
|
15
14
|
const schemaTypes = legacySchemaToEditorSchema(legacySchema)
|
|
16
15
|
const editorActor = createActor(editorMachine, {
|
|
17
16
|
input: {
|
|
18
|
-
behaviors: coreBehaviors,
|
|
19
17
|
schema: schemaTypes,
|
|
20
18
|
keyGenerator: defaultKeyGenerator,
|
|
21
19
|
getLegacySchema: () => legacySchema,
|
|
@@ -2,7 +2,6 @@ import type {Patch} from '@portabletext/patches'
|
|
|
2
2
|
import {createEditor, type Descendant} from 'slate'
|
|
3
3
|
import {beforeEach, describe, expect, it} from 'vitest'
|
|
4
4
|
import {createActor} from 'xstate'
|
|
5
|
-
import {coreBehaviors} from '../../behaviors/behavior.core'
|
|
6
5
|
import {schemaType} from '../../editor/__tests__/PortableTextEditorTester'
|
|
7
6
|
import {editorMachine} from '../../editor/editor-machine'
|
|
8
7
|
import {legacySchemaToEditorSchema} from '../../editor/editor-schema'
|
|
@@ -20,7 +19,6 @@ const patchToOperations = createApplyPatch(schemaTypes)
|
|
|
20
19
|
const editor = withPlugins(createEditor(), {
|
|
21
20
|
editorActor: createActor(editorMachine, {
|
|
22
21
|
input: {
|
|
23
|
-
behaviors: coreBehaviors,
|
|
24
22
|
schema: schemaTypes,
|
|
25
23
|
keyGenerator: defaultKeyGenerator,
|
|
26
24
|
getLegacySchema: () => legacySchema,
|