@portabletext/editor 1.41.3 → 1.41.4

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.
Files changed (48) hide show
  1. package/lib/_chunks-cjs/behavior.core.cjs +52 -28
  2. package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
  3. package/lib/_chunks-cjs/behavior.markdown.cjs +11 -11
  4. package/lib/_chunks-cjs/behavior.markdown.cjs.map +1 -1
  5. package/lib/_chunks-cjs/editor-provider.cjs +24 -21
  6. package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
  7. package/lib/_chunks-cjs/selector.get-focus-inline-object.cjs +2 -2
  8. package/lib/_chunks-cjs/selector.get-focus-inline-object.cjs.map +1 -1
  9. package/lib/_chunks-cjs/selector.get-text-before.cjs +2 -2
  10. package/lib/_chunks-cjs/selector.get-text-before.cjs.map +1 -1
  11. package/lib/_chunks-cjs/selector.is-active-style.cjs +240 -0
  12. package/lib/_chunks-cjs/selector.is-active-style.cjs.map +1 -0
  13. package/lib/_chunks-cjs/selector.is-overlapping-selection.cjs +300 -218
  14. package/lib/_chunks-cjs/selector.is-overlapping-selection.cjs.map +1 -1
  15. package/lib/_chunks-es/behavior.core.js +27 -3
  16. package/lib/_chunks-es/behavior.core.js.map +1 -1
  17. package/lib/_chunks-es/behavior.markdown.js +1 -1
  18. package/lib/_chunks-es/editor-provider.js +5 -2
  19. package/lib/_chunks-es/editor-provider.js.map +1 -1
  20. package/lib/_chunks-es/selector.get-focus-inline-object.js +1 -1
  21. package/lib/_chunks-es/selector.get-text-before.js +1 -1
  22. package/lib/_chunks-es/selector.is-active-style.js +243 -0
  23. package/lib/_chunks-es/selector.is-active-style.js.map +1 -0
  24. package/lib/_chunks-es/selector.is-overlapping-selection.js +298 -217
  25. package/lib/_chunks-es/selector.is-overlapping-selection.js.map +1 -1
  26. package/lib/behaviors/index.cjs +9 -9
  27. package/lib/behaviors/index.cjs.map +1 -1
  28. package/lib/behaviors/index.js +1 -1
  29. package/lib/index.cjs +75 -102
  30. package/lib/index.cjs.map +1 -1
  31. package/lib/index.js +66 -93
  32. package/lib/index.js.map +1 -1
  33. package/lib/plugins/index.cjs +6 -6
  34. package/lib/plugins/index.cjs.map +1 -1
  35. package/lib/plugins/index.js +1 -1
  36. package/lib/selectors/index.cjs +36 -36
  37. package/lib/selectors/index.cjs.map +1 -1
  38. package/lib/selectors/index.js +4 -4
  39. package/package.json +1 -1
  40. package/src/behaviors/behavior.core.dnd.ts +27 -0
  41. package/src/behaviors/behavior.core.ts +2 -0
  42. package/src/behaviors/behavior.default.ts +4 -0
  43. package/src/editor/Editable.tsx +22 -40
  44. package/lib/_chunks-cjs/selector.is-at-the-start-of-block.cjs +0 -322
  45. package/lib/_chunks-cjs/selector.is-at-the-start-of-block.cjs.map +0 -1
  46. package/lib/_chunks-es/selector.is-at-the-start-of-block.js +0 -324
  47. package/lib/_chunks-es/selector.is-at-the-start-of-block.js.map +0 -1
  48. package/src/internal-utils/dragging-on-drag-origin.ts +0 -22
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
- var types = require("@sanity/types"), selector_isAtTheStartOfBlock = require("./selector.is-at-the-start-of-block.cjs");
2
+ var types = require("@sanity/types"), selector_isOverlappingSelection = require("./selector.is-overlapping-selection.cjs");
3
3
  const getFocusInlineObject = (snapshot) => {
4
- const focusChild = selector_isAtTheStartOfBlock.getFocusChild(snapshot);
4
+ const focusChild = selector_isOverlappingSelection.getFocusChild(snapshot);
5
5
  return focusChild && !types.isPortableTextSpan(focusChild.node) ? {
6
6
  node: focusChild.node,
7
7
  path: focusChild.path
@@ -1 +1 @@
1
- {"version":3,"file":"selector.get-focus-inline-object.cjs","sources":["../../src/selectors/selector.get-focus-inline-object.ts"],"sourcesContent":["import {\n isPortableTextSpan,\n type KeyedSegment,\n type PortableTextObject,\n} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getFocusChild} from './selectors'\n\n/**\n * @public\n */\nexport const getFocusInlineObject: EditorSelector<\n | {node: PortableTextObject; path: [KeyedSegment, 'children', KeyedSegment]}\n | undefined\n> = (snapshot) => {\n const focusChild = getFocusChild(snapshot)\n\n return focusChild && !isPortableTextSpan(focusChild.node)\n ? {node: focusChild.node, path: focusChild.path}\n : undefined\n}\n"],"names":["getFocusInlineObject","snapshot","focusChild","getFocusChild","isPortableTextSpan","node","path","undefined"],"mappings":";;AAWO,MAAMA,uBAGRC,CAAa,aAAA;AACVC,QAAAA,aAAaC,2CAAcF,QAAQ;AAEzC,SAAOC,cAAc,CAACE,MAAAA,mBAAmBF,WAAWG,IAAI,IACpD;AAAA,IAACA,MAAMH,WAAWG;AAAAA,IAAMC,MAAMJ,WAAWI;AAAAA,EAAAA,IACzCC;AACN;;"}
1
+ {"version":3,"file":"selector.get-focus-inline-object.cjs","sources":["../../src/selectors/selector.get-focus-inline-object.ts"],"sourcesContent":["import {\n isPortableTextSpan,\n type KeyedSegment,\n type PortableTextObject,\n} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getFocusChild} from './selectors'\n\n/**\n * @public\n */\nexport const getFocusInlineObject: EditorSelector<\n | {node: PortableTextObject; path: [KeyedSegment, 'children', KeyedSegment]}\n | undefined\n> = (snapshot) => {\n const focusChild = getFocusChild(snapshot)\n\n return focusChild && !isPortableTextSpan(focusChild.node)\n ? {node: focusChild.node, path: focusChild.path}\n : undefined\n}\n"],"names":["getFocusInlineObject","snapshot","focusChild","getFocusChild","isPortableTextSpan","node","path","undefined"],"mappings":";;AAWO,MAAMA,uBAGRC,CAAa,aAAA;AACVC,QAAAA,aAAaC,8CAAcF,QAAQ;AAEzC,SAAOC,cAAc,CAACE,MAAAA,mBAAmBF,WAAWG,IAAI,IACpD;AAAA,IAACA,MAAMH,WAAWG;AAAAA,IAAMC,MAAMJ,WAAWI;AAAAA,EAAAA,IACzCC;AACN;;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- var util_sliceBlocks = require("./util.slice-blocks.cjs"), selector_isAtTheStartOfBlock = require("./selector.is-at-the-start-of-block.cjs");
2
+ var util_sliceBlocks = require("./util.slice-blocks.cjs"), selector_isOverlappingSelection = require("./selector.is-overlapping-selection.cjs");
3
3
  const getBlockTextBefore = (snapshot) => {
4
4
  if (!snapshot.context.selection)
5
5
  return "";
@@ -12,7 +12,7 @@ const getBlockTextBefore = (snapshot) => {
12
12
  _key: block._key
13
13
  }]
14
14
  });
15
- return selector_isAtTheStartOfBlock.getSelectionText({
15
+ return selector_isOverlappingSelection.getSelectionText({
16
16
  context: {
17
17
  ...snapshot.context,
18
18
  selection: {
@@ -1 +1 @@
1
- {"version":3,"file":"selector.get-text-before.cjs","sources":["../../src/selectors/selector.get-text-before.ts"],"sourcesContent":["import type {EditorSelector} from '../editor/editor-selector'\nimport {getBlockStartPoint} from '../utils/util.get-block-start-point'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\nimport {reverseSelection} from '../utils/util.reverse-selection'\nimport {getSelectionText} from './selector.get-selection-text'\n\n/**\n * @public\n */\nexport const getBlockTextBefore: EditorSelector<string> = (snapshot) => {\n if (!snapshot.context.selection) {\n return ''\n }\n\n const selection = snapshot.context.selection.backward\n ? reverseSelection(snapshot.context.selection)\n : snapshot.context.selection\n const point = selection.anchor\n const key = isKeyedSegment(point.path[0]) ? point.path[0]._key : undefined\n\n const block = key\n ? snapshot.context.value.find((block) => block._key === key)\n : undefined\n\n if (!block) {\n return ''\n }\n\n const startOfBlock = getBlockStartPoint({\n node: block,\n path: [{_key: block._key}],\n })\n\n return getSelectionText({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: startOfBlock,\n focus: point,\n },\n },\n })\n}\n"],"names":["getBlockTextBefore","snapshot","context","selection","point","backward","reverseSelection","anchor","key","isKeyedSegment","path","_key","undefined","block","value","find","startOfBlock","getBlockStartPoint","node","getSelectionText","focus"],"mappings":";;AASO,MAAMA,qBAA8CC,CAAa,aAAA;AAClE,MAAA,CAACA,SAASC,QAAQC;AACb,WAAA;AAMT,QAAMC,SAHYH,SAASC,QAAQC,UAAUE,WACzCC,kCAAiBL,SAASC,QAAQC,SAAS,IAC3CF,SAASC,QAAQC,WACGI,QAClBC,MAAMC,iBAAAA,eAAeL,MAAMM,KAAK,CAAC,CAAC,IAAIN,MAAMM,KAAK,CAAC,EAAEC,OAAOC,QAE3DC,QAAQL,MACVP,SAASC,QAAQY,MAAMC,KAAMF,CAAAA,WAAUA,OAAMF,SAASH,GAAG,IACzDI;AAEJ,MAAI,CAACC;AACI,WAAA;AAGT,QAAMG,eAAeC,iBAAAA,mBAAmB;AAAA,IACtCC,MAAML;AAAAA,IACNH,MAAM,CAAC;AAAA,MAACC,MAAME,MAAMF;AAAAA,IAAK,CAAA;AAAA,EAAA,CAC1B;AAED,SAAOQ,8CAAiB;AAAA,IAEtBjB,SAAS;AAAA,MACP,GAAGD,SAASC;AAAAA,MACZC,WAAW;AAAA,QACTI,QAAQS;AAAAA,QACRI,OAAOhB;AAAAA,MAAAA;AAAAA,IACT;AAAA,EACF,CACD;AACH;;"}
1
+ {"version":3,"file":"selector.get-text-before.cjs","sources":["../../src/selectors/selector.get-text-before.ts"],"sourcesContent":["import type {EditorSelector} from '../editor/editor-selector'\nimport {getBlockStartPoint} from '../utils/util.get-block-start-point'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\nimport {reverseSelection} from '../utils/util.reverse-selection'\nimport {getSelectionText} from './selector.get-selection-text'\n\n/**\n * @public\n */\nexport const getBlockTextBefore: EditorSelector<string> = (snapshot) => {\n if (!snapshot.context.selection) {\n return ''\n }\n\n const selection = snapshot.context.selection.backward\n ? reverseSelection(snapshot.context.selection)\n : snapshot.context.selection\n const point = selection.anchor\n const key = isKeyedSegment(point.path[0]) ? point.path[0]._key : undefined\n\n const block = key\n ? snapshot.context.value.find((block) => block._key === key)\n : undefined\n\n if (!block) {\n return ''\n }\n\n const startOfBlock = getBlockStartPoint({\n node: block,\n path: [{_key: block._key}],\n })\n\n return getSelectionText({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: startOfBlock,\n focus: point,\n },\n },\n })\n}\n"],"names":["getBlockTextBefore","snapshot","context","selection","point","backward","reverseSelection","anchor","key","isKeyedSegment","path","_key","undefined","block","value","find","startOfBlock","getBlockStartPoint","node","getSelectionText","focus"],"mappings":";;AASO,MAAMA,qBAA8CC,CAAa,aAAA;AAClE,MAAA,CAACA,SAASC,QAAQC;AACb,WAAA;AAMT,QAAMC,SAHYH,SAASC,QAAQC,UAAUE,WACzCC,kCAAiBL,SAASC,QAAQC,SAAS,IAC3CF,SAASC,QAAQC,WACGI,QAClBC,MAAMC,iBAAAA,eAAeL,MAAMM,KAAK,CAAC,CAAC,IAAIN,MAAMM,KAAK,CAAC,EAAEC,OAAOC,QAE3DC,QAAQL,MACVP,SAASC,QAAQY,MAAMC,KAAMF,CAAAA,WAAUA,OAAMF,SAASH,GAAG,IACzDI;AAEJ,MAAI,CAACC;AACI,WAAA;AAGT,QAAMG,eAAeC,iBAAAA,mBAAmB;AAAA,IACtCC,MAAML;AAAAA,IACNH,MAAM,CAAC;AAAA,MAACC,MAAME,MAAMF;AAAAA,IAAK,CAAA;AAAA,EAAA,CAC1B;AAED,SAAOQ,iDAAiB;AAAA,IAEtBjB,SAAS;AAAA,MACP,GAAGD,SAASC;AAAAA,MACZC,WAAW;AAAA,QACTI,QAAQS;AAAAA,QACRI,OAAOhB;AAAAA,MAAAA;AAAAA,IACT;AAAA,EACF,CACD;AACH;;"}
@@ -0,0 +1,240 @@
1
+ "use strict";
2
+ var util_sliceBlocks = require("./util.slice-blocks.cjs"), selector_isOverlappingSelection = require("./selector.is-overlapping-selection.cjs"), types = require("@sanity/types");
3
+ const isSelectingEntireBlocks = (snapshot) => {
4
+ if (!snapshot.context.selection)
5
+ return !1;
6
+ const startPoint = snapshot.context.selection.backward ? snapshot.context.selection.focus : snapshot.context.selection.anchor, endPoint = snapshot.context.selection.backward ? snapshot.context.selection.anchor : snapshot.context.selection.focus, startBlock = selector_isOverlappingSelection.getSelectionStartBlock(snapshot), endBlock = selector_isOverlappingSelection.getSelectionEndBlock(snapshot);
7
+ if (!startBlock || !endBlock)
8
+ return !1;
9
+ const startBlockStartPoint = util_sliceBlocks.getBlockStartPoint(startBlock), endBlockEndPoint = util_sliceBlocks.getBlockEndPoint(endBlock);
10
+ return util_sliceBlocks.isEqualSelectionPoints(startBlockStartPoint, startPoint) && util_sliceBlocks.isEqualSelectionPoints(endBlockEndPoint, endPoint);
11
+ }, getSelectedSpans = (snapshot) => {
12
+ if (!snapshot.context.selection)
13
+ return [];
14
+ const selectedSpans = [], startPoint = snapshot.context.selection.backward ? snapshot.context.selection.focus : snapshot.context.selection.anchor, endPoint = snapshot.context.selection.backward ? snapshot.context.selection.anchor : snapshot.context.selection.focus, startBlockKey = types.isKeySegment(startPoint.path[0]) ? startPoint.path[0]._key : void 0, endBlockKey = types.isKeySegment(endPoint.path[0]) ? endPoint.path[0]._key : void 0;
15
+ if (!startBlockKey || !endBlockKey)
16
+ return selectedSpans;
17
+ const startSpanKey = types.isKeySegment(startPoint.path[2]) ? startPoint.path[2]._key : void 0, endSpanKey = types.isKeySegment(endPoint.path[2]) ? endPoint.path[2]._key : void 0;
18
+ let startBlockFound = !1;
19
+ for (const block of snapshot.context.value)
20
+ if (block._key === startBlockKey && (startBlockFound = !0), !!types.isPortableTextTextBlock(block)) {
21
+ if (block._key === startBlockKey) {
22
+ for (const child of block.children)
23
+ if (types.isPortableTextSpan(child)) {
24
+ if (startSpanKey && child._key === startSpanKey) {
25
+ if (startPoint.offset < child.text.length && selectedSpans.push({
26
+ node: child,
27
+ path: [{
28
+ _key: block._key
29
+ }, "children", {
30
+ _key: child._key
31
+ }]
32
+ }), startSpanKey === endSpanKey)
33
+ break;
34
+ continue;
35
+ }
36
+ if (endSpanKey && child._key === endSpanKey) {
37
+ endPoint.offset > 0 && selectedSpans.push({
38
+ node: child,
39
+ path: [{
40
+ _key: block._key
41
+ }, "children", {
42
+ _key: child._key
43
+ }]
44
+ });
45
+ break;
46
+ }
47
+ selectedSpans.length > 0 && selectedSpans.push({
48
+ node: child,
49
+ path: [{
50
+ _key: block._key
51
+ }, "children", {
52
+ _key: child._key
53
+ }]
54
+ });
55
+ }
56
+ if (startBlockKey === endBlockKey)
57
+ break;
58
+ continue;
59
+ }
60
+ if (block._key === endBlockKey) {
61
+ for (const child of block.children)
62
+ if (types.isPortableTextSpan(child)) {
63
+ if (endSpanKey && child._key === endSpanKey) {
64
+ endPoint.offset > 0 && selectedSpans.push({
65
+ node: child,
66
+ path: [{
67
+ _key: block._key
68
+ }, "children", {
69
+ _key: child._key
70
+ }]
71
+ });
72
+ break;
73
+ }
74
+ selectedSpans.push({
75
+ node: child,
76
+ path: [{
77
+ _key: block._key
78
+ }, "children", {
79
+ _key: child._key
80
+ }]
81
+ });
82
+ }
83
+ break;
84
+ }
85
+ if (startBlockFound)
86
+ for (const child of block.children)
87
+ types.isPortableTextSpan(child) && selectedSpans.push({
88
+ node: child,
89
+ path: [{
90
+ _key: block._key
91
+ }, "children", {
92
+ _key: child._key
93
+ }]
94
+ });
95
+ }
96
+ return selectedSpans;
97
+ }, getActiveListItem = (snapshot) => {
98
+ if (!snapshot.context.selection)
99
+ return;
100
+ const guards = selector_isOverlappingSelection.createGuards(snapshot.context), selectedTextBlocks = selector_isOverlappingSelection.getSelectedBlocks(snapshot).map((block) => block.node).filter(guards.isTextBlock), firstTextBlock = selectedTextBlocks.at(0);
101
+ if (!firstTextBlock)
102
+ return;
103
+ const firstListItem = firstTextBlock.listItem;
104
+ if (firstListItem && selectedTextBlocks.every((block) => block.listItem === firstListItem))
105
+ return firstListItem;
106
+ }, getActiveStyle = (snapshot) => {
107
+ if (!snapshot.context.selection)
108
+ return;
109
+ const guards = selector_isOverlappingSelection.createGuards(snapshot.context), selectedTextBlocks = selector_isOverlappingSelection.getSelectedBlocks(snapshot).map((block) => block.node).filter(guards.isTextBlock), firstTextBlock = selectedTextBlocks.at(0);
110
+ if (!firstTextBlock)
111
+ return;
112
+ const firstStyle = firstTextBlock.style;
113
+ if (firstStyle && selectedTextBlocks.every((block) => block.style === firstStyle))
114
+ return firstStyle;
115
+ }, getTrimmedSelection = (snapshot) => {
116
+ if (!snapshot.context.selection)
117
+ return snapshot.context.selection;
118
+ const startPoint = selector_isOverlappingSelection.getSelectionStartPoint(snapshot), endPoint = selector_isOverlappingSelection.getSelectionEndPoint(snapshot);
119
+ if (!startPoint || !endPoint)
120
+ return snapshot.context.selection;
121
+ const startBlockKey = util_sliceBlocks.isKeyedSegment(startPoint.path[0]) ? startPoint.path[0]._key : null, startChildKey = util_sliceBlocks.isKeyedSegment(startPoint.path[2]) ? startPoint.path[2]._key : null, endBlockKey = util_sliceBlocks.isKeyedSegment(endPoint.path[0]) ? endPoint.path[0]._key : null, endChildKey = util_sliceBlocks.isKeyedSegment(endPoint.path[2]) ? endPoint.path[2]._key : null;
122
+ if (!startBlockKey || !endBlockKey)
123
+ return snapshot.context.selection;
124
+ let startBlockFound = !1, adjustedStartPoint, trimStartPoint = !1, adjustedEndPoint, trimEndPoint = !1, previousPotentialEndpoint;
125
+ for (const block of snapshot.context.value)
126
+ if (!(block._key === startBlockKey && (startBlockFound = !0, types.isPortableTextTextBlock(block) && util_sliceBlocks.isEmptyTextBlock(block))) && startBlockFound && types.isPortableTextTextBlock(block)) {
127
+ if (block._key === endBlockKey && util_sliceBlocks.isEmptyTextBlock(block))
128
+ break;
129
+ for (const child of block.children) {
130
+ if (child._key === endChildKey && (!types.isPortableTextSpan(child) || endPoint.offset === 0)) {
131
+ adjustedEndPoint = previousPotentialEndpoint ? {
132
+ path: [{
133
+ _key: previousPotentialEndpoint.blockKey
134
+ }, "children", {
135
+ _key: previousPotentialEndpoint.span._key
136
+ }],
137
+ offset: previousPotentialEndpoint.span.text.length
138
+ } : void 0, trimEndPoint = !0;
139
+ break;
140
+ }
141
+ if (trimStartPoint) {
142
+ const lonelySpan = types.isPortableTextSpan(child) && block.children.length === 1;
143
+ (types.isPortableTextSpan(child) && child.text.length > 0 || lonelySpan) && (adjustedStartPoint = {
144
+ path: [{
145
+ _key: block._key
146
+ }, "children", {
147
+ _key: child._key
148
+ }],
149
+ offset: 0
150
+ }, previousPotentialEndpoint = {
151
+ blockKey: block._key,
152
+ span: child
153
+ }, trimStartPoint = !1);
154
+ continue;
155
+ }
156
+ if (child._key === startChildKey) {
157
+ if (!types.isPortableTextSpan(child)) {
158
+ trimStartPoint = !0;
159
+ continue;
160
+ }
161
+ if (startPoint.offset === child.text.length) {
162
+ trimStartPoint = !0, previousPotentialEndpoint = child.text.length > 0 ? {
163
+ blockKey: block._key,
164
+ span: child
165
+ } : previousPotentialEndpoint;
166
+ continue;
167
+ }
168
+ }
169
+ previousPotentialEndpoint = types.isPortableTextSpan(child) && child.text.length > 0 ? {
170
+ blockKey: block._key,
171
+ span: child
172
+ } : previousPotentialEndpoint;
173
+ }
174
+ if (block._key === endBlockKey)
175
+ break;
176
+ }
177
+ const trimmedSelection = snapshot.context.selection.backward ? {
178
+ anchor: trimEndPoint && adjustedEndPoint ? adjustedEndPoint : endPoint,
179
+ focus: adjustedStartPoint ?? startPoint,
180
+ backward: !0
181
+ } : {
182
+ anchor: adjustedStartPoint ?? startPoint,
183
+ focus: trimEndPoint && adjustedEndPoint ? adjustedEndPoint : endPoint
184
+ };
185
+ if (selector_isOverlappingSelection.isSelectionCollapsed({
186
+ context: {
187
+ ...snapshot.context,
188
+ selection: trimmedSelection
189
+ }
190
+ })) {
191
+ const focusTextBlock = selector_isOverlappingSelection.getFocusTextBlock({
192
+ context: {
193
+ ...snapshot.context,
194
+ selection: trimmedSelection
195
+ }
196
+ });
197
+ if (focusTextBlock && !util_sliceBlocks.isEmptyTextBlock(focusTextBlock.node))
198
+ return null;
199
+ }
200
+ return trimmedSelection;
201
+ };
202
+ function isActiveAnnotation(annotation) {
203
+ return (snapshot) => {
204
+ if (!snapshot.context.selection)
205
+ return !1;
206
+ const selectedBlocks = selector_isOverlappingSelection.getSelectedBlocks(snapshot), focusSpan = selector_isOverlappingSelection.getFocusSpan(snapshot), selectedSpans = selector_isOverlappingSelection.isSelectionExpanded(snapshot) ? getSelectedSpans(snapshot) : focusSpan ? [focusSpan] : [];
207
+ if (selectedSpans.length === 0 || selectedSpans.some((span) => !span.node.marks || span.node.marks?.length === 0))
208
+ return !1;
209
+ const selectionMarkDefs = selectedBlocks.flatMap((block) => types.isPortableTextTextBlock(block.node) ? block.node.markDefs ?? [] : []);
210
+ return selectedSpans.every((span) => (span.node.marks?.flatMap((mark) => {
211
+ const markDef = selectionMarkDefs.find((markDef2) => markDef2._key === mark);
212
+ return markDef ? [markDef._type] : [];
213
+ }) ?? []).includes(annotation));
214
+ };
215
+ }
216
+ function isActiveDecorator(decorator) {
217
+ return (snapshot) => {
218
+ if (selector_isOverlappingSelection.isSelectionExpanded(snapshot)) {
219
+ const selectedSpans = getSelectedSpans(snapshot);
220
+ return selectedSpans.length > 0 && selectedSpans.every((span) => span.node.marks?.includes(decorator));
221
+ }
222
+ return snapshot.context.activeDecorators.includes(decorator);
223
+ };
224
+ }
225
+ function isActiveListItem(listItem) {
226
+ return (snapshot) => getActiveListItem(snapshot) === listItem;
227
+ }
228
+ function isActiveStyle(style) {
229
+ return (snapshot) => getActiveStyle(snapshot) === style;
230
+ }
231
+ exports.getActiveListItem = getActiveListItem;
232
+ exports.getActiveStyle = getActiveStyle;
233
+ exports.getSelectedSpans = getSelectedSpans;
234
+ exports.getTrimmedSelection = getTrimmedSelection;
235
+ exports.isActiveAnnotation = isActiveAnnotation;
236
+ exports.isActiveDecorator = isActiveDecorator;
237
+ exports.isActiveListItem = isActiveListItem;
238
+ exports.isActiveStyle = isActiveStyle;
239
+ exports.isSelectingEntireBlocks = isSelectingEntireBlocks;
240
+ //# sourceMappingURL=selector.is-active-style.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selector.is-active-style.cjs","sources":["../../src/selectors/selector.is-selecting-entire-blocks.ts","../../src/selectors/selector.get-selected-spans.ts","../../src/selectors/selector.get-active-list-item.ts","../../src/selectors/selector.get-active-style.ts","../../src/selectors/selector.get-trimmed-selection.ts","../../src/selectors/selector.is-active-annotation.ts","../../src/selectors/selector.is-active-decorator.ts","../../src/selectors/selector.is-active-list-item.ts","../../src/selectors/selector.is-active-style.ts"],"sourcesContent":["import type {EditorSelector} from '../editor/editor-selector'\nimport * as utils from '../utils'\nimport {getSelectionEndBlock, getSelectionStartBlock} from './selectors'\n\n/**\n * @public\n */\nexport const isSelectingEntireBlocks: EditorSelector<boolean> = (snapshot) => {\n if (!snapshot.context.selection) {\n return false\n }\n\n const startPoint = snapshot.context.selection.backward\n ? snapshot.context.selection.focus\n : snapshot.context.selection.anchor\n const endPoint = snapshot.context.selection.backward\n ? snapshot.context.selection.anchor\n : snapshot.context.selection.focus\n\n const startBlock = getSelectionStartBlock(snapshot)\n const endBlock = getSelectionEndBlock(snapshot)\n\n if (!startBlock || !endBlock) {\n return false\n }\n\n const startBlockStartPoint = utils.getBlockStartPoint(startBlock)\n const endBlockEndPoint = utils.getBlockEndPoint(endBlock)\n\n return (\n utils.isEqualSelectionPoints(startBlockStartPoint, startPoint) &&\n utils.isEqualSelectionPoints(endBlockEndPoint, endPoint)\n )\n}\n","import {\n isKeySegment,\n isPortableTextSpan,\n isPortableTextTextBlock,\n type KeyedSegment,\n type PortableTextSpan,\n} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\n\n/**\n * @public\n */\nexport const getSelectedSpans: EditorSelector<\n Array<{\n node: PortableTextSpan\n path: [KeyedSegment, 'children', KeyedSegment]\n }>\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return []\n }\n\n const selectedSpans: Array<{\n node: PortableTextSpan\n path: [KeyedSegment, 'children', KeyedSegment]\n }> = []\n\n const startPoint = snapshot.context.selection.backward\n ? snapshot.context.selection.focus\n : snapshot.context.selection.anchor\n const endPoint = snapshot.context.selection.backward\n ? snapshot.context.selection.anchor\n : snapshot.context.selection.focus\n\n const startBlockKey = isKeySegment(startPoint.path[0])\n ? startPoint.path[0]._key\n : undefined\n const endBlockKey = isKeySegment(endPoint.path[0])\n ? endPoint.path[0]._key\n : undefined\n\n if (!startBlockKey || !endBlockKey) {\n return selectedSpans\n }\n\n const startSpanKey = isKeySegment(startPoint.path[2])\n ? startPoint.path[2]._key\n : undefined\n const endSpanKey = isKeySegment(endPoint.path[2])\n ? endPoint.path[2]._key\n : undefined\n\n let startBlockFound = false\n\n for (const block of snapshot.context.value) {\n if (block._key === startBlockKey) {\n startBlockFound = true\n }\n\n if (!isPortableTextTextBlock(block)) {\n continue\n }\n\n if (block._key === startBlockKey) {\n for (const child of block.children) {\n if (!isPortableTextSpan(child)) {\n continue\n }\n\n if (startSpanKey && child._key === startSpanKey) {\n if (startPoint.offset < child.text.length) {\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n\n if (startSpanKey === endSpanKey) {\n break\n }\n\n continue\n }\n\n if (endSpanKey && child._key === endSpanKey) {\n if (endPoint.offset > 0) {\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n break\n }\n\n if (selectedSpans.length > 0) {\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n }\n\n if (startBlockKey === endBlockKey) {\n break\n }\n\n continue\n }\n\n if (block._key === endBlockKey) {\n for (const child of block.children) {\n if (!isPortableTextSpan(child)) {\n continue\n }\n\n if (endSpanKey && child._key === endSpanKey) {\n if (endPoint.offset > 0) {\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n break\n }\n\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n\n break\n }\n\n if (startBlockFound) {\n for (const child of block.children) {\n if (!isPortableTextSpan(child)) {\n continue\n }\n\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n }\n }\n\n return selectedSpans\n}\n","import type {PortableTextListBlock} from '@sanity/types'\nimport {createGuards} from '../behavior-actions/behavior.guards'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getSelectedBlocks} from './selectors'\n\n/**\n * @public\n */\nexport const getActiveListItem: EditorSelector<\n PortableTextListBlock['listItem'] | undefined\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n const guards = createGuards(snapshot.context)\n const selectedBlocks = getSelectedBlocks(snapshot).map((block) => block.node)\n const selectedTextBlocks = selectedBlocks.filter(guards.isTextBlock)\n\n const firstTextBlock = selectedTextBlocks.at(0)\n\n if (!firstTextBlock) {\n return undefined\n }\n\n const firstListItem = firstTextBlock.listItem\n\n if (!firstListItem) {\n return undefined\n }\n\n if (selectedTextBlocks.every((block) => block.listItem === firstListItem)) {\n return firstListItem\n }\n\n return undefined\n}\n","import type {PortableTextTextBlock} from '@sanity/types'\nimport {createGuards} from '../behavior-actions/behavior.guards'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getSelectedBlocks} from './selectors'\n\n/**\n * @public\n */\nexport const getActiveStyle: EditorSelector<PortableTextTextBlock['style']> = (\n snapshot,\n) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n const guards = createGuards(snapshot.context)\n const selectedBlocks = getSelectedBlocks(snapshot).map((block) => block.node)\n const selectedTextBlocks = selectedBlocks.filter(guards.isTextBlock)\n\n const firstTextBlock = selectedTextBlocks.at(0)\n\n if (!firstTextBlock) {\n return undefined\n }\n\n const firstStyle = firstTextBlock.style\n\n if (!firstStyle) {\n return undefined\n }\n\n if (selectedTextBlocks.every((block) => block.style === firstStyle)) {\n return firstStyle\n }\n\n return undefined\n}\n","import {\n isPortableTextSpan,\n isPortableTextTextBlock,\n type PortableTextSpan,\n} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {EditorSelection, EditorSelectionPoint} from '../types/editor'\nimport {isEmptyTextBlock, isKeyedSegment} from '../utils'\nimport {getSelectionEndPoint} from './selector.get-selection-end-point'\nimport {getSelectionStartPoint} from './selector.get-selection-start-point'\nimport {isSelectionCollapsed} from './selector.is-selection-collapsed'\nimport {getFocusTextBlock} from './selectors'\n\n/**\n * @public\n */\nexport const getTrimmedSelection: EditorSelector<EditorSelection> = (\n snapshot,\n) => {\n if (!snapshot.context.selection) {\n return snapshot.context.selection\n }\n\n const startPoint = getSelectionStartPoint(snapshot)\n const endPoint = getSelectionEndPoint(snapshot)\n\n if (!startPoint || !endPoint) {\n return snapshot.context.selection\n }\n\n const startBlockKey = isKeyedSegment(startPoint.path[0])\n ? startPoint.path[0]._key\n : null\n const startChildKey = isKeyedSegment(startPoint.path[2])\n ? startPoint.path[2]._key\n : null\n const endBlockKey = isKeyedSegment(endPoint.path[0])\n ? endPoint.path[0]._key\n : null\n const endChildKey = isKeyedSegment(endPoint.path[2])\n ? endPoint.path[2]._key\n : null\n\n if (!startBlockKey || !endBlockKey) {\n return snapshot.context.selection\n }\n\n let startBlockFound = false\n let adjustedStartPoint: EditorSelectionPoint | undefined\n let trimStartPoint = false\n let adjustedEndPoint: EditorSelectionPoint | undefined\n let trimEndPoint = false\n let previousPotentialEndpoint:\n | {blockKey: string; span: PortableTextSpan}\n | undefined\n\n for (const block of snapshot.context.value) {\n if (block._key === startBlockKey) {\n startBlockFound = true\n\n if (isPortableTextTextBlock(block) && isEmptyTextBlock(block)) {\n continue\n }\n }\n\n if (!startBlockFound) {\n continue\n }\n\n if (!isPortableTextTextBlock(block)) {\n continue\n }\n\n if (block._key === endBlockKey && isEmptyTextBlock(block)) {\n break\n }\n\n for (const child of block.children) {\n if (child._key === endChildKey) {\n if (!isPortableTextSpan(child) || endPoint.offset === 0) {\n adjustedEndPoint = previousPotentialEndpoint\n ? {\n path: [\n {_key: previousPotentialEndpoint.blockKey},\n 'children',\n {_key: previousPotentialEndpoint.span._key},\n ],\n offset: previousPotentialEndpoint.span.text.length,\n }\n : undefined\n\n trimEndPoint = true\n break\n }\n }\n\n if (trimStartPoint) {\n const lonelySpan =\n isPortableTextSpan(child) && block.children.length === 1\n\n if (\n (isPortableTextSpan(child) && child.text.length > 0) ||\n lonelySpan\n ) {\n adjustedStartPoint = {\n path: [{_key: block._key}, 'children', {_key: child._key}],\n offset: 0,\n }\n previousPotentialEndpoint = {blockKey: block._key, span: child}\n trimStartPoint = false\n }\n\n continue\n }\n\n if (child._key === startChildKey) {\n if (!isPortableTextSpan(child)) {\n trimStartPoint = true\n continue\n }\n\n if (startPoint.offset === child.text.length) {\n trimStartPoint = true\n previousPotentialEndpoint =\n child.text.length > 0\n ? {blockKey: block._key, span: child}\n : previousPotentialEndpoint\n continue\n }\n }\n\n previousPotentialEndpoint =\n isPortableTextSpan(child) && child.text.length > 0\n ? {blockKey: block._key, span: child}\n : previousPotentialEndpoint\n }\n\n if (block._key === endBlockKey) {\n break\n }\n }\n\n const trimmedSelection = snapshot.context.selection.backward\n ? {\n anchor: trimEndPoint && adjustedEndPoint ? adjustedEndPoint : endPoint,\n focus: adjustedStartPoint ?? startPoint,\n backward: true,\n }\n : {\n anchor: adjustedStartPoint ?? startPoint,\n focus: trimEndPoint && adjustedEndPoint ? adjustedEndPoint : endPoint,\n }\n\n if (\n isSelectionCollapsed({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: trimmedSelection,\n },\n })\n ) {\n const focusTextBlock = getFocusTextBlock({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: trimmedSelection,\n },\n })\n\n if (focusTextBlock && !isEmptyTextBlock(focusTextBlock.node)) {\n return null\n }\n }\n\n return trimmedSelection\n}\n","import {isPortableTextTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getSelectedSpans} from './selector.get-selected-spans'\nimport {isSelectionExpanded} from './selector.is-selection-expanded'\nimport {getFocusSpan, getSelectedBlocks} from './selectors'\n\n/**\n * @public\n */\nexport function isActiveAnnotation(\n annotation: string,\n): EditorSelector<boolean> {\n return (snapshot) => {\n if (!snapshot.context.selection) {\n return false\n }\n\n const selectedBlocks = getSelectedBlocks(snapshot)\n const focusSpan = getFocusSpan(snapshot)\n\n const selectedSpans = isSelectionExpanded(snapshot)\n ? getSelectedSpans(snapshot)\n : focusSpan\n ? [focusSpan]\n : []\n\n if (selectedSpans.length === 0) {\n return false\n }\n\n if (\n selectedSpans.some(\n (span) => !span.node.marks || span.node.marks?.length === 0,\n )\n ) {\n return false\n }\n\n const selectionMarkDefs = selectedBlocks.flatMap((block) =>\n isPortableTextTextBlock(block.node) ? (block.node.markDefs ?? []) : [],\n )\n\n return selectedSpans.every((span) => {\n const spanMarkDefs =\n span.node.marks?.flatMap((mark) => {\n const markDef = selectionMarkDefs.find(\n (markDef) => markDef._key === mark,\n )\n\n return markDef ? [markDef._type] : []\n }) ?? []\n\n return spanMarkDefs.includes(annotation)\n })\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getSelectedSpans} from './selector.get-selected-spans'\nimport {isSelectionExpanded} from './selector.is-selection-expanded'\n\n/**\n * @public\n */\nexport function isActiveDecorator(decorator: string): EditorSelector<boolean> {\n return (snapshot) => {\n if (isSelectionExpanded(snapshot)) {\n const selectedSpans = getSelectedSpans(snapshot)\n\n return (\n selectedSpans.length > 0 &&\n selectedSpans.every((span) => span.node.marks?.includes(decorator))\n )\n }\n\n return snapshot.context.activeDecorators.includes(decorator)\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getActiveListItem} from './selector.get-active-list-item'\n\n/**\n * @public\n */\nexport function isActiveListItem(listItem: string): EditorSelector<boolean> {\n return (snapshot) => {\n const activeListItem = getActiveListItem(snapshot)\n\n return activeListItem === listItem\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getActiveStyle} from './selector.get-active-style'\n\n/**\n * @public\n */\nexport function isActiveStyle(style: string): EditorSelector<boolean> {\n return (snapshot) => {\n const activeStyle = getActiveStyle(snapshot)\n\n return activeStyle === style\n }\n}\n"],"names":["isSelectingEntireBlocks","snapshot","context","selection","startPoint","backward","focus","anchor","endPoint","startBlock","getSelectionStartBlock","endBlock","getSelectionEndBlock","startBlockStartPoint","utils","endBlockEndPoint","isEqualSelectionPoints","getSelectedSpans","selectedSpans","startBlockKey","isKeySegment","path","_key","undefined","endBlockKey","startSpanKey","endSpanKey","startBlockFound","block","value","isPortableTextTextBlock","child","children","isPortableTextSpan","offset","text","length","push","node","getActiveListItem","guards","createGuards","selectedTextBlocks","getSelectedBlocks","map","filter","isTextBlock","firstTextBlock","at","firstListItem","listItem","every","getActiveStyle","firstStyle","style","getTrimmedSelection","getSelectionStartPoint","getSelectionEndPoint","isKeyedSegment","startChildKey","endChildKey","adjustedStartPoint","trimStartPoint","adjustedEndPoint","trimEndPoint","previousPotentialEndpoint","isEmptyTextBlock","blockKey","span","lonelySpan","trimmedSelection","isSelectionCollapsed","focusTextBlock","getFocusTextBlock","isActiveAnnotation","annotation","selectedBlocks","focusSpan","getFocusSpan","isSelectionExpanded","some","marks","selectionMarkDefs","flatMap","markDefs","mark","markDef","find","_type","includes","isActiveDecorator","decorator","activeDecorators","isActiveListItem","isActiveStyle"],"mappings":";;AAOO,MAAMA,0BAAoDC,CAAa,aAAA;AACxE,MAAA,CAACA,SAASC,QAAQC;AACb,WAAA;AAGT,QAAMC,aAAaH,SAASC,QAAQC,UAAUE,WAC1CJ,SAASC,QAAQC,UAAUG,QAC3BL,SAASC,QAAQC,UAAUI,QACzBC,WAAWP,SAASC,QAAQC,UAAUE,WACxCJ,SAASC,QAAQC,UAAUI,SAC3BN,SAASC,QAAQC,UAAUG,OAEzBG,aAAaC,uDAAuBT,QAAQ,GAC5CU,WAAWC,qDAAqBX,QAAQ;AAE1C,MAAA,CAACQ,cAAc,CAACE;AACX,WAAA;AAGHE,QAAAA,uBAAuBC,iBAAAA,mBAAyBL,UAAU,GAC1DM,mBAAmBD,kCAAuBH,QAAQ;AAGtDG,SAAAA,iBAAAA,uBAA6BD,sBAAsBT,UAAU,KAC7DU,iBAAME,uBAAuBD,k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