mirror of
https://github.com/discourse/discourse.git
synced 2026-08-10 04:58:31 -05:00
FIX: supports description for post events in rich editor (#34873)
Prior to this fix events with a description wouldn't show in the composer when they contain a description. This was particularly problematic as saving the post in this state would remove the event.
This commit is contained in:
+9
-4
@@ -25,6 +25,7 @@ const extension = {
|
||||
event: {
|
||||
attrs: EVENT_ATTRIBUTES,
|
||||
group: "block",
|
||||
content: "block*",
|
||||
defining: true,
|
||||
isolating: true,
|
||||
draggable: true,
|
||||
@@ -81,17 +82,21 @@ const extension = {
|
||||
|
||||
serializeNode: {
|
||||
event(state, node) {
|
||||
let bbcode = "[event";
|
||||
state.write("[event");
|
||||
|
||||
Object.entries(node.attrs).forEach(([key, value]) => {
|
||||
if (value !== null) {
|
||||
bbcode += ` ${key}="${value}"`;
|
||||
state.write(` ${key}="${value}"`);
|
||||
}
|
||||
});
|
||||
|
||||
bbcode += "]\n[/event]\n";
|
||||
state.write("]\n");
|
||||
|
||||
state.write(bbcode);
|
||||
if (node.content.size > 0) {
|
||||
state.renderContent(node);
|
||||
}
|
||||
|
||||
state.write("[/event]\n");
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
+8
-1
@@ -9,7 +9,7 @@ module("Integration | Component | rich-editor-extension", function (hooks) {
|
||||
"event alone": [
|
||||
[
|
||||
`[event start="2025-03-21 15:41" status="public" timezone="Europe/Paris"]\n[/event]\n`,
|
||||
`<div class="discourse-post-event discourse-post-event-preview ProseMirror-selectednode" data-start="2025-03-21 15:41" data-status="public" data-timezone="Europe/Paris" contenteditable="false" draggable="true"><div class="event-preview-status">Public</div><div class="event-preview-dates"><span class="start">March 21, 2025 2:41 PM</span></div></div>`,
|
||||
`<div class="discourse-post-event discourse-post-event-preview" data-start="2025-03-21 15:41" data-status="public" data-timezone="Europe/Paris" contenteditable="false" draggable="true"><div class="event-preview-status">Public</div><div class="event-preview-dates"><span class="start">March 21, 2025 2:41 PM</span></div></div>`,
|
||||
`[event start="2025-03-21 15:41" status="public" timezone="Europe/Paris"]\n[/event]\n`,
|
||||
],
|
||||
],
|
||||
@@ -20,6 +20,13 @@ module("Integration | Component | rich-editor-extension", function (hooks) {
|
||||
`Hello world\n\n[event start="2025-03-21 15:41" status="public" timezone="Europe/Paris"]\n[/event]\nGoodbye world`,
|
||||
],
|
||||
],
|
||||
"event with content inside": [
|
||||
[
|
||||
`[event start="2025-03-21 15:41" status="public" timezone="Europe/Paris"]\ntest\n[/event]\n`,
|
||||
`<div class="discourse-post-event discourse-post-event-preview" data-start="2025-03-21 15:41" data-status="public" data-timezone="Europe/Paris" contenteditable="false" draggable="true"><div class="event-preview-status">Public</div><div class="event-preview-dates"><span class="start">March 21, 2025 2:41 PM</span></div></div>`,
|
||||
`[event start="2025-03-21 15:41" status="public" timezone="Europe/Paris"]\ntest\n\n[/event]\n`,
|
||||
],
|
||||
],
|
||||
};
|
||||
|
||||
Object.entries(testCases).forEach(([name, tests]) => {
|
||||
|
||||
Reference in New Issue
Block a user