From 5f7976ce0ecc00a6402619a174a4c4181c1b118f Mon Sep 17 00:00:00 2001 From: Martin Artnik Date: Tue, 17 Jan 2023 14:32:25 +0100 Subject: [PATCH] Fix copying and pasting TinyMCE images [SCI-7774] --- app/models/tiny_mce_asset.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/models/tiny_mce_asset.rb b/app/models/tiny_mce_asset.rb index 5c81f8561..8cdf7a3d0 100644 --- a/app/models/tiny_mce_asset.rb +++ b/app/models/tiny_mce_asset.rb @@ -35,6 +35,10 @@ class TinyMceAsset < ApplicationRecord end images.each do |image| image_to_update = find_by(id: Base62.decode(image)) + + # if image was pasted from another object, create a copy + image_to_update = image_to_update.clone_tinymce_asset(object) if image_to_update.object != object + next if image_to_update.object || image_to_update.team_id != Team.search_by_object(object).id image_to_update&.update(object: object, saved: true)