From f4544249f34a5e933f59c508c6d18401b27845cd Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Tue, 16 Jan 2024 20:53:26 +0000 Subject: [PATCH] [4.x] Fix Bard sets being inserted too early (#9216) --- .../js/components/fieldtypes/bard/BardFieldtype.vue | 9 ++++++++- src/Facades/Endpoint/Pattern.php | 2 +- src/Modifiers/CoreModifiers.php | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/resources/js/components/fieldtypes/bard/BardFieldtype.vue b/resources/js/components/fieldtypes/bard/BardFieldtype.vue index 7727b2486b..ad4e7a416a 100644 --- a/resources/js/components/fieldtypes/bard/BardFieldtype.vue +++ b/resources/js/components/fieldtypes/bard/BardFieldtype.vue @@ -434,9 +434,16 @@ export default { this.updateSetMeta(id, this.meta.new[handle]); + const { $head } = this.editor.view.state.selection; + const { nodeBefore } = $head; + // Perform this in nextTick because the meta data won't be ready until then. this.$nextTick(() => { - this.editor.commands.set({ id, values }); + if (nodeBefore) { + this.editor.commands.setAt({ attrs: { id, values }, pos: $head.pos }); + } else { + this.editor.commands.set({ id, values }); + } }); }, diff --git a/src/Facades/Endpoint/Pattern.php b/src/Facades/Endpoint/Pattern.php index 3697c67fb6..94994c51ae 100644 --- a/src/Facades/Endpoint/Pattern.php +++ b/src/Facades/Endpoint/Pattern.php @@ -122,7 +122,7 @@ public function sqlLikeQuote(string $like): string /** * Converts SQL LIKE syntax to a regular expression. * - * @return string The regular expression without delimiters. + * @return string The regular expression without delimiters. */ public function sqlLikeToRegex(string $like): string { diff --git a/src/Modifiers/CoreModifiers.php b/src/Modifiers/CoreModifiers.php index b4910d4f8c..1bdf818646 100644 --- a/src/Modifiers/CoreModifiers.php +++ b/src/Modifiers/CoreModifiers.php @@ -1006,7 +1006,7 @@ public function joinplode($value, $params) /** * Check if an item exists in an array using "dot" notation. * - * @param $value + * @param $value * @return bool */ public function inArray($haystack, $params, $context) @@ -1493,7 +1493,7 @@ public function merge($value, $params, $context) /** * Generate an md5 hash of a value. * - * @param $params + * @param $params * @return string */ public function md5($value)