@portabletext/editor 1.36.1 → 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 +24 -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 +24 -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 +9 -8
- 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/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
|
@@ -2493,14 +2493,21 @@ const converterJson = {
|
|
|
2493
2493
|
deserialize: ({
|
|
2494
2494
|
snapshot,
|
|
2495
2495
|
event
|
|
2496
|
-
}) =>
|
|
2497
|
-
|
|
2498
|
-
data: blockTools.htmlToBlocks(event.data, snapshot.context.schema.portableText, {
|
|
2496
|
+
}) => {
|
|
2497
|
+
const blocks = blockTools.htmlToBlocks(event.data, snapshot.context.schema.portableText, {
|
|
2499
2498
|
keyGenerator: snapshot.context.keyGenerator,
|
|
2500
2499
|
unstable_whitespaceOnPasteMode: snapshot.context.schema.block.options.unstable_whitespaceOnPasteMode
|
|
2501
|
-
})
|
|
2502
|
-
|
|
2503
|
-
|
|
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
|
+
}
|
|
2504
2511
|
}, converterTextPlain = {
|
|
2505
2512
|
mimeType: "text/plain",
|
|
2506
2513
|
serialize: ({
|
|
@@ -2526,12 +2533,16 @@ const converterJson = {
|
|
|
2526
2533
|
snapshot,
|
|
2527
2534
|
event
|
|
2528
2535
|
}) => {
|
|
2529
|
-
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
|
|
2530
|
-
|
|
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
|
+
} : {
|
|
2531
2544
|
type: "deserialization.success",
|
|
2532
|
-
data:
|
|
2533
|
-
keyGenerator: snapshot.context.keyGenerator
|
|
2534
|
-
}),
|
|
2545
|
+
data: blocks,
|
|
2535
2546
|
mimeType: "text/plain"
|
|
2536
2547
|
};
|
|
2537
2548
|
}
|
|
@@ -4450,7 +4461,7 @@ const blockSetBehaviorActionImplementation = ({
|
|
|
4450
4461
|
"deserialization.failure": ({
|
|
4451
4462
|
action
|
|
4452
4463
|
}) => {
|
|
4453
|
-
console.warn(`Deserialization of ${action.mimeType} failed with reason ${action.reason}`);
|
|
4464
|
+
console.warn(`Deserialization of ${action.mimeType} failed with reason "${action.reason}"`);
|
|
4454
4465
|
},
|
|
4455
4466
|
"deserialization.success": ({
|
|
4456
4467
|
context,
|
|
@@ -4583,7 +4594,7 @@ const blockSetBehaviorActionImplementation = ({
|
|
|
4583
4594
|
"serialization.failure": ({
|
|
4584
4595
|
action
|
|
4585
4596
|
}) => {
|
|
4586
|
-
console.warn(`Serialization of ${action.mimeType} failed with reason ${action.reason}`);
|
|
4597
|
+
console.warn(`Serialization of ${action.mimeType} failed with reason "${action.reason}"`);
|
|
4587
4598
|
},
|
|
4588
4599
|
"serialization.success": ({
|
|
4589
4600
|
context,
|