From a6b2f3d686924d7660359a19648f0e87ef1c45d9 Mon Sep 17 00:00:00 2001 From: ulferts Date: Mon, 18 Mar 2024 16:35:23 +0100 Subject: [PATCH] hack support for macros on statusExplanation and description --- app/forms/custom_fields/inputs/text.rb | 3 ++- app/views/custom_fields/_form.html.erb | 1 + .../formattable-control/formattable-control.component.ts | 5 ++++- spec/features/projects/project_status_administration_spec.rb | 2 +- spec/support/components/wysiwyg/wysiwyg_editor.rb | 4 ++-- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/forms/custom_fields/inputs/text.rb b/app/forms/custom_fields/inputs/text.rb index 4a6ffe3ec853..adb224761a39 100644 --- a/app/forms/custom_fields/inputs/text.rb +++ b/app/forms/custom_fields/inputs/text.rb @@ -33,7 +33,8 @@ class CustomFields::Inputs::Text < CustomFields::Inputs::Base::Input def rich_text_options { - resource: nil + resource: nil, + macros: "none" } end end diff --git a/app/views/custom_fields/_form.html.erb b/app/views/custom_fields/_form.html.erb index 16dc232c5ac9..f1b0039a02bf 100644 --- a/app/views/custom_fields/_form.html.erb +++ b/app/views/custom_fields/_form.html.erb @@ -151,6 +151,7 @@ See COPYRIGHT and LICENSE files for more details. cols: 100, rows: 20, class: 'wiki-edit', + macros: "none", with_text_formatting: true %> <% end %> diff --git a/frontend/src/app/shared/components/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/components/formattable-control/formattable-control.component.ts b/frontend/src/app/shared/components/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/components/formattable-control/formattable-control.component.ts index f7045f98d6b8..3b94dd32bea0 100644 --- a/frontend/src/app/shared/components/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/components/formattable-control/formattable-control.component.ts +++ b/frontend/src/app/shared/components/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/components/formattable-control/formattable-control.component.ts @@ -45,7 +45,10 @@ export class FormattableControlComponent implements ControlValueAccessor, OnInit public get ckEditorContext():ICKEditorContext { return { type: this.templateOptions.editorType, - macros: 'none', + // This is a very project resource specific hack to allow macros on description and statusExplanation but + // disable it for custom fields. As the formly based approach is currently limited to projects, and that is to be removed, + // such a "pragmatic" approach should be ok. + macros: (this.templateOptions.property as string).startsWith('customField') ? 'none' : 'resource', options: { rtl: this.templateOptions?.rtl }, }; } diff --git a/spec/features/projects/project_status_administration_spec.rb b/spec/features/projects/project_status_administration_spec.rb index e32d04a5f46e..a6a2b3ab1b46 100644 --- a/spec/features/projects/project_status_administration_spec.rb +++ b/spec/features/projects/project_status_administration_spec.rb @@ -66,7 +66,7 @@ status_field.select_option "On track" status_description.set_markdown "Everything is fine at the start" - status_description.expect_supports_no_macros + status_description.expect_supports_macros click_button "Save" diff --git a/spec/support/components/wysiwyg/wysiwyg_editor.rb b/spec/support/components/wysiwyg/wysiwyg_editor.rb index afee2036c5bf..1000027e86fd 100644 --- a/spec/support/components/wysiwyg/wysiwyg_editor.rb +++ b/spec/support/components/wysiwyg/wysiwyg_editor.rb @@ -59,9 +59,9 @@ def expect_value(value) expect(editor_element.text).to eq(value) end - def expect_supports_no_macros + def expect_supports_macros expect(container) - .to have_no_css(".ck-button", visible: :all, text: "Macros") + .to have_css(".ck-button", visible: :all, text: "Macros") end def within_enabled_preview