Skip to content

Commit 17fdb5a

Browse files
committed
feat: support pasted wysiwyg editor content
Closes: #214
1 parent 22f9831 commit 17fdb5a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

classes/local/form/elements/wysiwyg_editor_element.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,22 @@ public function render_to(render_context $context): void {
132132
return;
133133
}
134134

135-
$text = $mydata['text'];
135+
$text =& $mydata['text'];
136136
$format = $mydata['format'];
137137

138138
if (!$this->fileuploads) {
139139
// Uploads are disabled.
140140
$filemetas = [];
141141
} else {
142+
global $USER;
143+
144+
// When links are pasted from another editor, they still point to that editor's draft area.
145+
// File_merge_draft_areas copies the referenced files and rewrites the links.
146+
$text = file_merge_draft_areas($draftitemid, context_user::instance($USER->id)->id, $text);
147+
142148
// Remove all draft files that aren't referenced in the markup.
143149
file_remove_editor_orphaned_files($mydata);
144150

145-
global $USER;
146151
$ofs = di::get(options_file_service::class);
147152
/** @var file_metadata[] $filemetas */
148153
$filemetas = $ofs->get_qpy_files_metadata_from_draftitem($USER->id, $draftitemid);

0 commit comments

Comments
 (0)