PluginProbe
Extendify / trunk
Extendify vtrunk
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
← All changes | src/QuickEdit/components/BlockTextEditor.jsx +5 -30 3.1.2 → trunk View file →
@@ -697,41 +697,23 @@
697 697 document.addEventListener('keydown', onKey, true);
698 698 return () => document.removeEventListener('keydown', onKey, true);
699 699 }, [clearSelected, host]);
700 700
701 - // `alsoClear` lets cross-block click trigger save without racing the
702 - // new block's `setSelected(B)` — save runs to completion against A's
703 - // snapshotted data, but doesn't try to nullify the slot at the end.
704 - const handleSave = async ({ alsoClear = true } = {}) => {
701 + const handleSave = async () => {
705 702 if (saving) return;
706 703 if (!blocks) {
707 - if (alsoClear) clearSelected();
704 + clearSelected();
708 705 return;
709 706 }
710 707 // Move focus off the Save button before it disables so focus isn't
711 708 // stranded on a disabled control; the status node then announces
712 - // "Saving…" politely. Cross-block saves leave focus on the new block.
713 - if (alsoClear) statusRef.current?.focus({ preventScroll: true });
709 + // "Saving…" politely.
710 + statusRef.current?.focus({ preventScroll: true });
714 711 setSaving(true);
715 712 setSaveError(null);
716 713 const snap = selected;
717 714 const beforeRawBlock = beforeRawBlockRef.current;
718 - // Capture before the optimistic write below mutates snap.el's text.
719 715 const fingerprint = textFingerprint(snap.el);
720 - // Cross-block click unmounts the canvas before save's splice lands,
721 - // so the live element's pre-edit text briefly flashes back into view.
722 - // Pre-write the canvas editable's content into the live element so
723 - // the unmount reveal already shows the edits. Snapshot the original
724 - // so we can revert if save fails. Only text-content optimism — tag /
725 - // wrapper changes still rely on splice (see plan).
726 - let preEditInnerHtml = null;
727 - if (!alsoClear && host && snap.el) {
728 - const editable = host.querySelector('.block-editor-rich-text__editable');
729 - if (editable) {
730 - preEditInnerHtml = snap.el.innerHTML;
731 - snap.el.innerHTML = editable.innerHTML;
732 - }
733 - }
734 716 try {
735 717 const rawBlock = serialize(blocks);
736 718 const res = await save({
737 719 source: snap.source,
@@ -753,17 +735,10 @@
753 735 rawBlock: beforeRawBlock,
754 736 });
755 737 }
756 738 track('save', { kind: 'block', blockType: snap.blockType });
757 - if (alsoClear) {
758 - clearSelected();
759 - } else {
760 - setSaving(false);
761 - }
739 + clearSelected();
762 740 } catch (err) {
763 - if (preEditInnerHtml !== null && snap.el) {
764 - snap.el.innerHTML = preEditInnerHtml;
765 - }
766 741 track('save_failed', {
767 742 kind: 'block',
768 743 blockType: snap.blockType,
769 744 reason: err?.status || err?.message,