@portabletext/editor 2.6.3 → 2.6.5
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/selector.is-selecting-entire-blocks.cjs +29 -29
- package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.is-selection-expanded.cjs +5 -5
- package/lib/_chunks-cjs/selector.is-selection-expanded.cjs.map +1 -1
- package/lib/_chunks-cjs/util.child-selection-point-to-block-offset.cjs +3 -3
- package/lib/_chunks-cjs/util.child-selection-point-to-block-offset.cjs.map +1 -1
- package/lib/_chunks-cjs/util.is-selection-collapsed.cjs +5 -5
- package/lib/_chunks-cjs/util.is-selection-collapsed.cjs.map +1 -1
- package/lib/_chunks-cjs/util.merge-text-blocks.cjs +2 -6
- package/lib/_chunks-cjs/util.merge-text-blocks.cjs.map +1 -1
- package/lib/_chunks-cjs/util.slice-blocks.cjs +106 -117
- package/lib/_chunks-cjs/util.slice-blocks.cjs.map +1 -1
- package/lib/_chunks-cjs/util.slice-text-block.cjs +3 -3
- package/lib/_chunks-cjs/util.slice-text-block.cjs.map +1 -1
- package/lib/_chunks-dts/behavior.types.action.d.ts +115 -115
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js +3 -2
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js.map +1 -1
- package/lib/_chunks-es/selector.is-selection-expanded.js +3 -2
- package/lib/_chunks-es/selector.is-selection-expanded.js.map +1 -1
- package/lib/_chunks-es/util.child-selection-point-to-block-offset.js +2 -1
- package/lib/_chunks-es/util.child-selection-point-to-block-offset.js.map +1 -1
- package/lib/_chunks-es/util.is-selection-collapsed.js +2 -1
- package/lib/_chunks-es/util.is-selection-collapsed.js.map +1 -1
- package/lib/_chunks-es/util.merge-text-blocks.js +2 -5
- package/lib/_chunks-es/util.merge-text-blocks.js.map +1 -1
- package/lib/_chunks-es/util.slice-blocks.js +101 -112
- package/lib/_chunks-es/util.slice-blocks.js.map +1 -1
- package/lib/_chunks-es/util.slice-text-block.js +2 -1
- package/lib/_chunks-es/util.slice-text-block.js.map +1 -1
- package/lib/index.cjs +133 -96
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +43 -6
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.cjs +5 -5
- package/lib/plugins/index.cjs.map +1 -1
- package/lib/plugins/index.d.cts +3 -3
- package/lib/plugins/index.d.ts +3 -3
- package/lib/plugins/index.js +6 -5
- package/lib/plugins/index.js.map +1 -1
- package/lib/selectors/index.cjs +3 -3
- package/lib/selectors/index.cjs.map +1 -1
- package/lib/selectors/index.js +2 -1
- package/lib/selectors/index.js.map +1 -1
- package/lib/utils/index.cjs +14 -4
- package/lib/utils/index.cjs.map +1 -1
- package/lib/utils/index.d.cts +2 -9
- package/lib/utils/index.d.ts +4 -11
- package/lib/utils/index.js +4 -3
- package/lib/utils/index.js.map +1 -1
- package/package.json +14 -13
- package/src/behaviors/behavior.abstract.delete.ts +1 -1
- package/src/behaviors/behavior.abstract.deserialize.ts +1 -1
- package/src/behaviors/behavior.abstract.split.ts +2 -1
- package/src/behaviors/behavior.core.block-objects.ts +1 -1
- package/src/behaviors/behavior.core.lists.ts +2 -1
- package/src/behaviors/behavior.markdown.ts +1 -1
- package/src/converters/converter.text-plain.ts +2 -1
- package/src/editor/__tests__/PortableTextEditor.test.tsx +1 -1
- package/src/editor/__tests__/RangeDecorations.test.tsx +1 -1
- package/src/editor/__tests__/self-solving.test.tsx +1 -1
- package/src/editor/components/render-element.tsx +1 -1
- package/src/editor/plugins/__tests__/withEditableAPIDelete.test.tsx +1 -1
- package/src/editor/plugins/__tests__/withEditableAPIGetFragment.test.tsx +2 -3
- package/src/editor/plugins/__tests__/withEditableAPIInsert.test.tsx +1 -1
- package/src/editor/plugins/__tests__/withEditableAPISelectionsOverlapping.test.tsx +1 -1
- package/src/editor/plugins/__tests__/withPortableTextLists.test.tsx +1 -1
- package/src/editor/plugins/__tests__/withPortableTextMarkModel.test.tsx +1 -1
- package/src/editor/plugins/__tests__/withPortableTextSelections.test.tsx +1 -1
- package/src/editor/plugins/__tests__/withUndoRedo.test.tsx +1 -1
- package/src/editor/plugins/createWithObjectKeys.ts +1 -1
- package/src/editor/plugins/createWithPortableTextMarkModel.ts +1 -1
- package/src/editor/plugins/createWithSchemaTypes.ts +2 -5
- package/src/internal-utils/__tests__/valueNormalization.test.tsx +1 -1
- package/src/internal-utils/apply-operation-to-portable-text.test.ts +1 -1
- package/src/internal-utils/build-index-maps.ts +1 -1
- package/src/internal-utils/create-test-snapshot.ts +1 -1
- package/src/internal-utils/drag-selection.test.ts +1 -1
- package/src/internal-utils/editor-selection.ts +1 -1
- package/src/internal-utils/operation-to-patches.ts +1 -1
- package/src/internal-utils/parse-blocks.test.ts +1 -1
- package/src/internal-utils/parse-blocks.ts +1 -38
- package/src/internal-utils/selection-focus-text.ts +1 -1
- package/src/internal-utils/selection-text.ts +1 -1
- package/src/internal-utils/test-editor.tsx +1 -1
- package/src/internal-utils/text-block-key.ts +1 -1
- package/src/internal-utils/text-marks.ts +1 -1
- package/src/internal-utils/text-selection.ts +1 -1
- package/src/internal-utils/to-slate-range.test.ts +1 -1
- package/src/internal-utils/to-slate-range.ts +1 -1
- package/src/internal-utils/validateValue.ts +1 -1
- package/src/internal-utils/value-annotations.ts +1 -1
- package/src/operations/behavior.operation.block.unset.ts +2 -1
- package/src/operations/behavior.operation.delete.ts +98 -2
- package/src/operations/behavior.operation.insert.block.ts +2 -1
- package/src/operations/behavior.operation.select.ts +5 -0
- package/src/plugins/plugin.behavior.tsx +3 -1
- package/src/plugins/plugin.internal.auto-close-brackets.test.tsx +1 -2
- package/src/plugins/plugin.markdown.test.tsx +1 -2
- package/src/selectors/selector.get-active-annotations.ts +1 -1
- package/src/selectors/selector.get-active-list-item.ts +1 -1
- package/src/selectors/selector.get-active-style.ts +1 -1
- package/src/selectors/selector.get-anchor-text-block.ts +1 -1
- package/src/selectors/selector.get-caret-word-selection.test.ts +1 -1
- package/src/selectors/selector.get-focus-block-object.ts +1 -1
- package/src/selectors/selector.get-focus-span.ts +1 -1
- package/src/selectors/selector.get-focus-text-block.ts +1 -1
- package/src/selectors/selector.get-list-state.ts +1 -1
- package/src/selectors/selector.get-next-span.ts +1 -1
- package/src/selectors/selector.get-previous-span.ts +1 -1
- package/src/selectors/selector.get-selected-spans.ts +1 -1
- package/src/selectors/selector.get-selected-text-blocks.ts +1 -1
- package/src/selectors/selector.get-selection-text.ts +1 -1
- package/src/selectors/selector.get-trimmed-selection.test.ts +1 -1
- package/src/selectors/selector.get-trimmed-selection.ts +1 -1
- package/src/selectors/selector.is-active-annotation.ts +1 -1
- package/src/selectors/selector.is-point-after-selection.ts +1 -1
- package/src/selectors/selector.is-point-before-selection.ts +1 -1
- package/src/utils/index.ts +1 -2
- package/src/utils/util.at-the-beginning-of-block.ts +1 -1
- package/src/utils/util.block-offset.ts +1 -1
- package/src/utils/util.child-selection-point-to-block-offset.ts +1 -1
- package/src/utils/util.get-block-end-point.ts +1 -1
- package/src/utils/util.get-block-start-point.ts +1 -1
- package/src/utils/util.is-empty-text-block.ts +1 -1
- package/src/utils/util.merge-text-blocks.ts +1 -1
- package/src/utils/util.slice-blocks.ts +2 -2
- package/src/utils/util.slice-text-block.ts +2 -2
- package/src/utils/util.split-text-block.ts +1 -1
- package/src/internal-utils/terse-pt.test.ts +0 -175
- package/src/internal-utils/terse-pt.ts +0 -150
- package/src/internal-utils/test-key-generator.ts +0 -9
- package/src/utils/util.is-span.ts +0 -12
- package/src/utils/util.is-text-block.ts +0 -13
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import {compileSchema, defineSchema} from '@portabletext/schema'
|
|
2
|
-
import {expect, test} from 'vitest'
|
|
3
|
-
import {createTestKeyGenerator} from '../internal-utils/test-key-generator'
|
|
4
|
-
import {getTersePt, parseTersePt, parseTersePtString} from './terse-pt'
|
|
5
|
-
|
|
6
|
-
const keyGenerator = createTestKeyGenerator()
|
|
7
|
-
|
|
8
|
-
test(getTersePt.name, () => {
|
|
9
|
-
const schema = compileSchema(defineSchema({}))
|
|
10
|
-
const fooBlock = {
|
|
11
|
-
_key: 'b1',
|
|
12
|
-
_type: 'block',
|
|
13
|
-
children: [{_key: 's1', _type: 'span', text: 'foo'}],
|
|
14
|
-
}
|
|
15
|
-
const emptyBlock = {
|
|
16
|
-
_key: 'b2',
|
|
17
|
-
_type: 'block',
|
|
18
|
-
children: [{_key: 's2', _type: 'span', text: ''}],
|
|
19
|
-
}
|
|
20
|
-
const barBlock = {
|
|
21
|
-
_key: 'b3',
|
|
22
|
-
_type: 'block',
|
|
23
|
-
children: [{_key: 's3', _type: 'span', text: 'bar'}],
|
|
24
|
-
}
|
|
25
|
-
const softReturnBlock = {
|
|
26
|
-
_key: 'b4',
|
|
27
|
-
_type: 'block',
|
|
28
|
-
children: [{_key: 's4', _type: 'span', text: 'foo\nbar'}],
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
expect(getTersePt({schema, value: [fooBlock, barBlock]})).toEqual([
|
|
32
|
-
'foo',
|
|
33
|
-
'bar',
|
|
34
|
-
])
|
|
35
|
-
expect(getTersePt({schema, value: [emptyBlock, barBlock]})).toEqual([
|
|
36
|
-
'',
|
|
37
|
-
'bar',
|
|
38
|
-
])
|
|
39
|
-
expect(getTersePt({schema, value: [fooBlock, emptyBlock, barBlock]})).toEqual(
|
|
40
|
-
['foo', '', 'bar'],
|
|
41
|
-
)
|
|
42
|
-
expect(getTersePt({schema, value: [fooBlock, softReturnBlock]})).toEqual([
|
|
43
|
-
'foo',
|
|
44
|
-
'foo\nbar',
|
|
45
|
-
])
|
|
46
|
-
|
|
47
|
-
expect(
|
|
48
|
-
getTersePt({
|
|
49
|
-
schema,
|
|
50
|
-
value: [
|
|
51
|
-
{
|
|
52
|
-
_key: keyGenerator(),
|
|
53
|
-
_type: 'block',
|
|
54
|
-
children: [{_key: keyGenerator(), _type: 'span', text: 'foo'}],
|
|
55
|
-
},
|
|
56
|
-
],
|
|
57
|
-
}),
|
|
58
|
-
).toEqual(['foo'])
|
|
59
|
-
expect(
|
|
60
|
-
getTersePt({
|
|
61
|
-
schema,
|
|
62
|
-
value: [
|
|
63
|
-
{
|
|
64
|
-
_key: keyGenerator(),
|
|
65
|
-
_type: 'block',
|
|
66
|
-
children: [{_key: keyGenerator(), _type: 'span', text: 'foo'}],
|
|
67
|
-
listItem: 'number',
|
|
68
|
-
},
|
|
69
|
-
],
|
|
70
|
-
}),
|
|
71
|
-
).toEqual(['#:foo'])
|
|
72
|
-
expect(
|
|
73
|
-
getTersePt({
|
|
74
|
-
schema,
|
|
75
|
-
value: [
|
|
76
|
-
{
|
|
77
|
-
_key: keyGenerator(),
|
|
78
|
-
_type: 'block',
|
|
79
|
-
children: [{_key: keyGenerator(), _type: 'span', text: 'foo'}],
|
|
80
|
-
listItem: 'number',
|
|
81
|
-
style: 'h3',
|
|
82
|
-
},
|
|
83
|
-
],
|
|
84
|
-
}),
|
|
85
|
-
).toEqual(['#h3:foo'])
|
|
86
|
-
expect(
|
|
87
|
-
getTersePt({
|
|
88
|
-
schema,
|
|
89
|
-
value: [
|
|
90
|
-
{
|
|
91
|
-
_key: keyGenerator(),
|
|
92
|
-
_type: 'block',
|
|
93
|
-
children: [{_key: keyGenerator(), _type: 'span', text: 'foo'}],
|
|
94
|
-
level: 2,
|
|
95
|
-
listItem: 'number',
|
|
96
|
-
style: 'h3',
|
|
97
|
-
},
|
|
98
|
-
],
|
|
99
|
-
}),
|
|
100
|
-
).toEqual(['>>#h3:foo'])
|
|
101
|
-
expect(
|
|
102
|
-
getTersePt({
|
|
103
|
-
schema,
|
|
104
|
-
value: [
|
|
105
|
-
{
|
|
106
|
-
_key: keyGenerator(),
|
|
107
|
-
_type: 'block',
|
|
108
|
-
children: [{_key: keyGenerator(), _type: 'span', text: 'foo'}],
|
|
109
|
-
style: 'h3',
|
|
110
|
-
},
|
|
111
|
-
],
|
|
112
|
-
}),
|
|
113
|
-
).toEqual(['h3:foo'])
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
test(parseTersePtString.name, () => {
|
|
117
|
-
expect(parseTersePtString('foo')).toEqual(['foo'])
|
|
118
|
-
expect(parseTersePtString('foo,bar')).toEqual(['foo,bar'])
|
|
119
|
-
expect(parseTersePtString('foo,bar|baz')).toEqual(['foo,bar', 'baz'])
|
|
120
|
-
expect(parseTersePtString('|foo')).toEqual(['', 'foo'])
|
|
121
|
-
expect(parseTersePtString('foo|')).toEqual(['foo', ''])
|
|
122
|
-
expect(parseTersePtString('foo|bar\nbaz')).toEqual(['foo', 'bar\nbaz'])
|
|
123
|
-
expect(parseTersePtString('f,oo||ba,r')).toEqual(['f,oo', '', 'ba,r'])
|
|
124
|
-
expect(parseTersePtString('|')).toEqual(['', ''])
|
|
125
|
-
expect(parseTersePtString('||')).toEqual(['', '', ''])
|
|
126
|
-
expect(parseTersePtString('>>#h3:foo')).toEqual(['>>#h3:foo'])
|
|
127
|
-
})
|
|
128
|
-
|
|
129
|
-
test(parseTersePt.name, () => {
|
|
130
|
-
expect(
|
|
131
|
-
parseTersePt(
|
|
132
|
-
{
|
|
133
|
-
schema: compileSchema(defineSchema({})),
|
|
134
|
-
keyGenerator: createTestKeyGenerator(),
|
|
135
|
-
},
|
|
136
|
-
parseTersePtString('{image}|foo|>>#h4:bar|-:baz,fizz|,{stock-ticker},'),
|
|
137
|
-
),
|
|
138
|
-
).toEqual([
|
|
139
|
-
{
|
|
140
|
-
_key: 'k0',
|
|
141
|
-
_type: 'image',
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
_key: 'k1',
|
|
145
|
-
_type: 'block',
|
|
146
|
-
children: [{_key: 'k2', _type: 'span', text: 'foo'}],
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
_key: 'k3',
|
|
150
|
-
_type: 'block',
|
|
151
|
-
children: [{_key: 'k4', _type: 'span', text: 'bar'}],
|
|
152
|
-
level: 2,
|
|
153
|
-
listItem: 'number',
|
|
154
|
-
style: 'h4',
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
_key: 'k5',
|
|
158
|
-
_type: 'block',
|
|
159
|
-
children: [
|
|
160
|
-
{_key: 'k6', _type: 'span', text: 'baz'},
|
|
161
|
-
{_key: 'k7', _type: 'span', text: 'fizz'},
|
|
162
|
-
],
|
|
163
|
-
listItem: 'bullet',
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
_key: 'k8',
|
|
167
|
-
_type: 'block',
|
|
168
|
-
children: [
|
|
169
|
-
{_key: 'k9', _type: 'span', text: ''},
|
|
170
|
-
{_key: 'k10', _type: 'stock-ticker'},
|
|
171
|
-
{_key: 'k11', _type: 'span', text: ''},
|
|
172
|
-
],
|
|
173
|
-
},
|
|
174
|
-
])
|
|
175
|
-
})
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import type {PortableTextBlock, PortableTextTextBlock} from '@sanity/types'
|
|
2
|
-
import type {EditorContext} from '../editor/editor-snapshot'
|
|
3
|
-
import {isSpan, isTextBlock} from './parse-blocks'
|
|
4
|
-
|
|
5
|
-
type TersePtConfig = {
|
|
6
|
-
style: (name?: string) => string
|
|
7
|
-
listItem: (name?: string) => string
|
|
8
|
-
level: (level?: number) => string
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const defaultConfig: TersePtConfig = {
|
|
12
|
-
style: (name) =>
|
|
13
|
-
name === undefined || name === 'normal'
|
|
14
|
-
? ''
|
|
15
|
-
: name === 'blockquote'
|
|
16
|
-
? 'q'
|
|
17
|
-
: `${name}`,
|
|
18
|
-
listItem: (name) => (name === undefined ? '' : name === 'number' ? '#' : '-'),
|
|
19
|
-
level: (level) => (level === undefined ? '' : '>'.repeat(level)),
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function getTersePt(
|
|
23
|
-
context: Pick<EditorContext, 'schema' | 'value'>,
|
|
24
|
-
): Array<string> {
|
|
25
|
-
const blocks: Array<string> = []
|
|
26
|
-
|
|
27
|
-
for (const block of context.value) {
|
|
28
|
-
let terseBlock = ''
|
|
29
|
-
|
|
30
|
-
if (isTextBlock(context, block)) {
|
|
31
|
-
const blockPrefix = `${defaultConfig.level(block.level)}${defaultConfig.listItem(block.listItem)}${defaultConfig.style(block.style)}`
|
|
32
|
-
|
|
33
|
-
if (blockPrefix) {
|
|
34
|
-
terseBlock = `${blockPrefix}:`
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
let index = -1
|
|
38
|
-
for (const child of block.children) {
|
|
39
|
-
index++
|
|
40
|
-
|
|
41
|
-
if (isSpan(context, child)) {
|
|
42
|
-
terseBlock = `${terseBlock}${index > 0 ? ',' : ''}${child.text}`
|
|
43
|
-
} else {
|
|
44
|
-
terseBlock = `${terseBlock}${index > 0 ? ',' : ''}{${child._type}}`
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
} else {
|
|
48
|
-
terseBlock = `{${block._type}}`
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
blocks.push(terseBlock)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return blocks
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function parseTersePt(
|
|
58
|
-
context: Pick<EditorContext, 'keyGenerator' | 'schema'>,
|
|
59
|
-
tersePt: Array<string>,
|
|
60
|
-
): Array<PortableTextBlock> {
|
|
61
|
-
const blocks: Array<PortableTextBlock> = []
|
|
62
|
-
|
|
63
|
-
for (const terseBlock of tersePt) {
|
|
64
|
-
if (terseBlock.startsWith('{')) {
|
|
65
|
-
blocks.push({
|
|
66
|
-
_type: terseBlock.slice(1, -1),
|
|
67
|
-
_key: context.keyGenerator(),
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
continue
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const block: PortableTextTextBlock = {
|
|
74
|
-
_key: context.keyGenerator(),
|
|
75
|
-
_type: context.schema.block.name,
|
|
76
|
-
children: [],
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (terseBlock.includes(':')) {
|
|
80
|
-
const [prefix, content] = terseBlock.split(':')
|
|
81
|
-
|
|
82
|
-
const listItem = prefix.includes('#')
|
|
83
|
-
? 'number'
|
|
84
|
-
: prefix.includes('-')
|
|
85
|
-
? 'bullet'
|
|
86
|
-
: undefined
|
|
87
|
-
|
|
88
|
-
if (listItem !== undefined) {
|
|
89
|
-
block.listItem = listItem
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const level = prefix.split('').filter((part) => part === '>').length
|
|
93
|
-
|
|
94
|
-
if (level > 0) {
|
|
95
|
-
block.level = level
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const style = prefix
|
|
99
|
-
.split('')
|
|
100
|
-
.filter((part) => !['#', '-', '>'].includes(part))
|
|
101
|
-
.join('')
|
|
102
|
-
|
|
103
|
-
if (style) {
|
|
104
|
-
block.style = style
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const textRuns = content.split(',')
|
|
108
|
-
|
|
109
|
-
for (const textRun of textRuns) {
|
|
110
|
-
if (textRun.startsWith('{')) {
|
|
111
|
-
block.children.push({
|
|
112
|
-
_key: context.keyGenerator(),
|
|
113
|
-
_type: textRun.slice(1, -1),
|
|
114
|
-
})
|
|
115
|
-
} else {
|
|
116
|
-
block.children.push({
|
|
117
|
-
_key: context.keyGenerator(),
|
|
118
|
-
_type: context.schema.span.name,
|
|
119
|
-
text: textRun,
|
|
120
|
-
})
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
} else {
|
|
124
|
-
const textRuns = terseBlock.split(',')
|
|
125
|
-
|
|
126
|
-
for (const textRun of textRuns) {
|
|
127
|
-
if (textRun.startsWith('{')) {
|
|
128
|
-
block.children.push({
|
|
129
|
-
_key: context.keyGenerator(),
|
|
130
|
-
_type: textRun.slice(1, -1),
|
|
131
|
-
})
|
|
132
|
-
} else {
|
|
133
|
-
block.children.push({
|
|
134
|
-
_key: context.keyGenerator(),
|
|
135
|
-
_type: context.schema.span.name,
|
|
136
|
-
text: textRun,
|
|
137
|
-
})
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
blocks.push(block)
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return blocks
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export function parseTersePtString(text: string) {
|
|
149
|
-
return text.split('|').map((span) => span.replace(/\\n/g, '\n'))
|
|
150
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type {PortableTextChild, PortableTextSpan} from '@sanity/types'
|
|
2
|
-
import type {EditorContext} from '..'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @public
|
|
6
|
-
*/
|
|
7
|
-
export function isSpan(
|
|
8
|
-
context: Pick<EditorContext, 'schema'>,
|
|
9
|
-
child: PortableTextChild,
|
|
10
|
-
): child is PortableTextSpan {
|
|
11
|
-
return child._type === context.schema.span.name
|
|
12
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type {PortableTextTextBlock} from '@sanity/types'
|
|
2
|
-
import type {EditorContext} from '..'
|
|
3
|
-
import {isTypedObject} from '../internal-utils/asserters'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
export function isTextBlock(
|
|
9
|
-
context: Pick<EditorContext, 'schema'>,
|
|
10
|
-
block: unknown,
|
|
11
|
-
): block is PortableTextTextBlock {
|
|
12
|
-
return isTypedObject(block) && block._type === context.schema.block.name
|
|
13
|
-
}
|