@portabletext/editor 1.36.0 → 1.36.2
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 +25 -13
- package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.is-at-the-start-of-block.cjs.map +1 -1
- package/lib/_chunks-cjs/util.block-offsets-to-selection.cjs.map +1 -1
- package/lib/_chunks-cjs/util.slice-blocks.cjs.map +1 -1
- package/lib/_chunks-es/editor-provider.js +25 -13
- package/lib/_chunks-es/editor-provider.js.map +1 -1
- package/lib/_chunks-es/selector.is-at-the-start-of-block.js.map +1 -1
- package/lib/_chunks-es/util.block-offsets-to-selection.js.map +1 -1
- package/lib/_chunks-es/util.slice-blocks.js.map +1 -1
- package/lib/behaviors/index.d.cts +7 -10
- package/lib/behaviors/index.d.ts +7 -10
- package/lib/index.cjs +140 -104
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +13 -26
- package/lib/index.d.ts +13 -26
- package/lib/index.js +142 -106
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.cjs.map +1 -1
- package/lib/plugins/index.d.cts +2 -7
- package/lib/plugins/index.d.ts +2 -7
- package/lib/plugins/index.js.map +1 -1
- package/lib/selectors/index.cjs.map +1 -1
- package/lib/selectors/index.d.cts +8 -13
- package/lib/selectors/index.d.ts +8 -13
- package/lib/selectors/index.js.map +1 -1
- package/lib/utils/index.cjs.map +1 -1
- package/lib/utils/index.d.cts +3 -6
- package/lib/utils/index.d.ts +3 -6
- package/lib/utils/index.js.map +1 -1
- package/package.json +14 -13
- package/src/behavior-actions/behavior.actions.ts +2 -2
- package/src/behaviors/behavior.decorator-pair.ts +2 -1
- package/src/behaviors/index.ts +0 -8
- package/src/converters/converter.text-html.deserialize.test.ts +1 -1
- package/src/converters/converter.text-html.serialize.test.ts +1 -1
- package/src/converters/converter.text-html.ts +8 -0
- package/src/converters/converter.text-plain.test.ts +1 -1
- package/src/converters/converter.text-plain.ts +8 -0
- package/src/editor/Editable.tsx +1 -1
- package/src/editor/__tests__/PortableTextEditor.test.tsx +16 -20
- package/src/editor/components/Element.tsx +26 -18
- package/src/editor/components/drop-indicator.tsx +14 -0
- package/src/editor/components/{DraggableBlock.tsx → use-draggable.ts} +42 -163
- package/src/editor/components/use-droppable.ts +135 -0
- package/src/editor/create-slate-editor.tsx +0 -3
- package/src/editor/sync-machine.ts +1 -0
- package/src/index.ts +48 -12
- package/src/internal-utils/create-test-snapshot.ts +1 -1
- package/src/plugins/plugin.decorator-shortcut.ts +1 -1
- package/src/plugins/plugin.markdown.tsx +1 -0
- package/src/selectors/index.ts +0 -8
- package/src/selectors/selector.get-active-annotations.test.ts +1 -1
- package/src/selectors/selector.get-caret-word-selection.test.ts +1 -1
- package/src/selectors/selector.get-selected-spans.test.ts +2 -1
- package/src/selectors/selector.get-selection-end-point.ts +1 -1
- package/src/selectors/selector.get-selection-start-point.ts +1 -1
- package/src/selectors/selector.get-selection-text.test.ts +1 -1
- package/src/selectors/selector.get-selection.ts +2 -1
- package/src/selectors/selector.get-value.ts +1 -1
- package/src/selectors/selector.is-active-decorator.test.ts +1 -1
- package/src/types/editor.ts +6 -16
- package/src/types/slate.ts +1 -1
- package/src/utils/index.ts +0 -1
- package/src/utils/util.block-offsets-to-selection.ts +1 -1
- package/src/utils/util.is-span.ts +1 -1
- package/src/utils/util.is-text-block.ts +1 -1
- package/src/utils/util.merge-text-blocks.ts +1 -1
- package/src/utils/util.slice-blocks.ts +1 -1
- package/src/utils/util.split-text-block.ts +4 -2
|
@@ -2007,6 +2007,7 @@ const debug$c = debugWithName("sync machine"), syncValueCallback = ({
|
|
|
2007
2007
|
"done syncing": [{
|
|
2008
2008
|
guard: "value changed while syncing",
|
|
2009
2009
|
actions: ["assign previous value", "assign initial value synced"],
|
|
2010
|
+
target: "syncing",
|
|
2010
2011
|
reenter: !0
|
|
2011
2012
|
}, {
|
|
2012
2013
|
target: "idle",
|
|
@@ -2492,14 +2493,21 @@ const converterJson = {
|
|
|
2492
2493
|
deserialize: ({
|
|
2493
2494
|
snapshot,
|
|
2494
2495
|
event
|
|
2495
|
-
}) =>
|
|
2496
|
-
|
|
2497
|
-
data: blockTools.htmlToBlocks(event.data, snapshot.context.schema.portableText, {
|
|
2496
|
+
}) => {
|
|
2497
|
+
const blocks = blockTools.htmlToBlocks(event.data, snapshot.context.schema.portableText, {
|
|
2498
2498
|
keyGenerator: snapshot.context.keyGenerator,
|
|
2499
2499
|
unstable_whitespaceOnPasteMode: snapshot.context.schema.block.options.unstable_whitespaceOnPasteMode
|
|
2500
|
-
})
|
|
2501
|
-
|
|
2502
|
-
|
|
2500
|
+
});
|
|
2501
|
+
return blocks.length === 0 ? {
|
|
2502
|
+
type: "deserialization.failure",
|
|
2503
|
+
mimeType: "text/html",
|
|
2504
|
+
reason: "No blocks deserialized"
|
|
2505
|
+
} : {
|
|
2506
|
+
type: "deserialization.success",
|
|
2507
|
+
data: blocks,
|
|
2508
|
+
mimeType: "text/html"
|
|
2509
|
+
};
|
|
2510
|
+
}
|
|
2503
2511
|
}, converterTextPlain = {
|
|
2504
2512
|
mimeType: "text/plain",
|
|
2505
2513
|
serialize: ({
|
|
@@ -2525,12 +2533,16 @@ const converterJson = {
|
|
|
2525
2533
|
snapshot,
|
|
2526
2534
|
event
|
|
2527
2535
|
}) => {
|
|
2528
|
-
const textToHtml = `<html><body>${escapeHtml(event.data).split(/\n{2,}/).map((line) => line ? `<p>${line.replace(/(?:\r\n|\r|\n)/g, "<br/>")}</p>` : "<p></p>").join("")}</body></html
|
|
2529
|
-
|
|
2536
|
+
const textToHtml = `<html><body>${escapeHtml(event.data).split(/\n{2,}/).map((line) => line ? `<p>${line.replace(/(?:\r\n|\r|\n)/g, "<br/>")}</p>` : "<p></p>").join("")}</body></html>`, blocks = blockTools.htmlToBlocks(textToHtml, snapshot.context.schema.portableText, {
|
|
2537
|
+
keyGenerator: snapshot.context.keyGenerator
|
|
2538
|
+
});
|
|
2539
|
+
return blocks.length === 0 ? {
|
|
2540
|
+
type: "deserialization.failure",
|
|
2541
|
+
mimeType: "text/plain",
|
|
2542
|
+
reason: "No blocks deserialized"
|
|
2543
|
+
} : {
|
|
2530
2544
|
type: "deserialization.success",
|
|
2531
|
-
data:
|
|
2532
|
-
keyGenerator: snapshot.context.keyGenerator
|
|
2533
|
-
}),
|
|
2545
|
+
data: blocks,
|
|
2534
2546
|
mimeType: "text/plain"
|
|
2535
2547
|
};
|
|
2536
2548
|
}
|
|
@@ -4449,7 +4461,7 @@ const blockSetBehaviorActionImplementation = ({
|
|
|
4449
4461
|
"deserialization.failure": ({
|
|
4450
4462
|
action
|
|
4451
4463
|
}) => {
|
|
4452
|
-
console.warn(`Deserialization of ${action.mimeType} failed with reason ${action.reason}`);
|
|
4464
|
+
console.warn(`Deserialization of ${action.mimeType} failed with reason "${action.reason}"`);
|
|
4453
4465
|
},
|
|
4454
4466
|
"deserialization.success": ({
|
|
4455
4467
|
context,
|
|
@@ -4582,7 +4594,7 @@ const blockSetBehaviorActionImplementation = ({
|
|
|
4582
4594
|
"serialization.failure": ({
|
|
4583
4595
|
action
|
|
4584
4596
|
}) => {
|
|
4585
|
-
console.warn(`Serialization of ${action.mimeType} failed with reason ${action.reason}`);
|
|
4597
|
+
console.warn(`Serialization of ${action.mimeType} failed with reason "${action.reason}"`);
|
|
4586
4598
|
},
|
|
4587
4599
|
"serialization.success": ({
|
|
4588
4600
|
context,
|