A platform for community discussion. Free, open, simple.
FIX: clear stored mark on rich editor mark input rule conversion (#35360)
Renato Atilio8ebca1f0d0ee
diff --git a/app/assets/javascripts/discourse/app/static/prosemirror/lib/plugin-utils.js b/app/assets/javascripts/discourse/app/static/prosemirror/lib/plugin-utils.jsindex 60d7eb125d5..404e94d5dc8 100644--- a/app/assets/javascripts/discourse/app/static/prosemirror/lib/plugin-utils.js+++ b/app/assets/javascripts/discourse/app/static/prosemirror/lib/plugin-utils.js@@ -23,8 +23,8 @@ export function markInputRule(regexp, markType, getAttrs) {start += attrsStart ?? 0;if (match[1]) {- let textStart = start + match[0].indexOf(match[1]);- let textEnd = textStart + match[1].length;+ const textStart = start + match[0].indexOf(match[1]);+ const textEnd = textStart + match[1].length;if (textEnd < end) {tr.delete(textEnd, end);}@@ -33,7 +33,7 @@ export function markInputRule(regexp, markType, getAttrs) {}tr.addMark(start, start + match[1].length, markType.create(markAttrs));- tr.removeStoredMark(markType);+ tr.setStoredMarks(tr.doc.resolve(start + match[1].length + 1).marks());} else {tr.delete(start, end);tr.insertText(" ");diff --git a/spec/system/composer/prosemirror_editor_spec.rb b/spec/system/composer/prosemirror_editor_spec.rbindex 76261eae0a8..d558f0d548f 100644--- a/spec/system/composer/prosemirror_editor_spec.rb+++ b/spec/system/composer/prosemirror_editor_spec.rb@@ -1124,6 +1124,17 @@ describe "Composer - ProseMirror editor", type: :system doexpect(rich).to have_css("a", text: "lin")end+ it "clears closed marks from stored marks when using markInputRule" do+ open_composer++ composer.type_content("[`something`](link) word")++ expect(rich).to have_css("a", text: "something")+ expect(rich).to have_css("a code", text: "something")+ expect(rich).to have_content("word")+ expect(rich).to have_no_css("code", text: "word")+ end+it "parses html inline tags from pasted HTML" docdp.allow_clipboardopen_composer