OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
disable macros in various ckeditors
ulferts28dddb6332fe
diff --git a/app/views/projects/form/attributes/_description.html.erb b/app/views/projects/form/attributes/_description.html.erbindex 3070a70f151..f624e0b7892 100644--- a/app/views/projects/form/attributes/_description.html.erb+++ b/app/views/projects/form/attributes/_description.html.erb@@ -31,7 +31,6 @@ See docs/COPYRIGHT.rdoc for more details.<%= form.text_area :description,id: :project_description,with_text_formatting: true,- rows: 5,- class: 'wiki-edit',+ macros: false,container_class: '-xxwide' %></div>diff --git a/app/views/projects/form/attributes/_status.html.erb b/app/views/projects/form/attributes/_status.html.erbindex 87c781c720f..b086d32959c 100644--- a/app/views/projects/form/attributes/_status.html.erb+++ b/app/views/projects/form/attributes/_status.html.erb@@ -42,6 +42,7 @@ See docs/COPYRIGHT.rdoc for more details.<div class="form--field"><%= status_form.text_area :explanation,with_text_formatting: true,+ macros: false,preview_context: project_preview_context(project.status, project),container_class: '-xxwide' %></div>diff --git a/frontend/src/app/ckeditor/ckeditor-augmented-textarea.component.ts b/frontend/src/app/ckeditor/ckeditor-augmented-textarea.component.tsindex a69823947e0..0f6e73a7724 100644--- a/frontend/src/app/ckeditor/ckeditor-augmented-textarea.component.ts+++ b/frontend/src/app/ckeditor/ckeditor-augmented-textarea.component.ts@@ -62,6 +62,7 @@ export class CkeditorAugmentedTextareaComponent implements OnInit, OnDestroy {public initialContent:string;public resource?:HalResource;public context:ICKEditorContext;+ public macros:boolean;// Reference to the actual ckeditor instance component@ViewChild(OpCkeditorComponent, { static: true }) private ckEditorInstance:OpCkeditorComponent;@@ -84,6 +85,7 @@ export class CkeditorAugmentedTextareaComponent implements OnInit, OnDestroy {// Parse the attribute explicitly since this is likely a bootstrapped elementthis.textareaSelector = this.$element.attr('textarea-selector')!;this.previewContext = this.$element.attr('preview-context')!;+ this.macros = this.$element.attr('macros') !== 'false';// Parse the resource if any existsconst source = this.$element.data('resource');@@ -98,6 +100,9 @@ export class CkeditorAugmentedTextareaComponent implements OnInit, OnDestroy {this.$attachmentsElement = this.formElement.find('#attachments_fields');this.context = { resource: this.resource, previewContext: this.previewContext };+ if (!this.macros) {+ this.context['macros'] = 'none';+ }}ngOnDestroy() {diff --git a/frontend/src/app/ckeditor/ckeditor-augmented-textarea.html b/frontend/src/app/ckeditor/ckeditor-augmented-textarea.htmlindex 8f3b68b4245..bebd9564bd0 100644--- a/frontend/src/app/ckeditor/ckeditor-augmented-textarea.html+++ b/frontend/src/app/ckeditor/ckeditor-augmented-textarea.html@@ -3,8 +3,7 @@<op-ckeditor [context]="context"[content]="initialContent"(onInitialized)="setup($event)"- (onContentChange)="markEdited()"- ckEditorType="full">+ (onContentChange)="markEdited()"></op-ckeditor></div>diff --git a/lib/custom_field_form_builder.rb b/lib/custom_field_form_builder.rbindex 00e6186fcad..1468c170dfe 100644--- a/lib/custom_field_form_builder.rb+++ b/lib/custom_field_form_builder.rb@@ -68,7 +68,7 @@ class CustomFieldFormBuilder < TabularFormBuilderinput_options[:class] = (input_options[:class] || '') << ' -augmented-datepicker'text_field(field, input_options)when 'text'- text_area(field, input_options.merge(rows: 3, with_text_formatting: true))+ text_area(field, input_options.merge(with_text_formatting: true, macros: false))when 'bool'formatter = field_format.formatter.new(object)check_box(field, input_options.merge(checked: formatter.checked?))diff --git a/lib/open_project/text_formatting/formats/markdown/helper.rb b/lib/open_project/text_formatting/formats/markdown/helper.rbindex fbcfb3ca625..8b60f30648b 100644--- a/lib/open_project/text_formatting/formats/markdown/helper.rb+++ b/lib/open_project/text_formatting/formats/markdown/helper.rb@@ -31,7 +31,6 @@module OpenProject::TextFormatting::Formatsmodule Markdownclass Helper-attr_reader :view_contextdef initialize(view_context)@@ -57,10 +56,11 @@ module OpenProject::TextFormatting::Formats# Pass an optional resource to the CKEditor instanceresource = context.fetch(:resource, {})helpers.content_tag 'ckeditor-augmented-textarea',- '',- 'textarea-selector': "##{field_id}",- 'preview-context': context[:preview_context],- 'data-resource': resource.to_json+ '',+ 'textarea-selector': "##{field_id}",+ 'preview-context': context[:preview_context],+ 'data-resource': resource.to_json,+ 'macros': context.fetch(:macros, true)endprotecteddiff --git a/spec/features/projects/project_status_administration_spec.rb b/spec/features/projects/project_status_administration_spec.rbindex a0c90d3b64d..ca61854cbfe 100644--- a/spec/features/projects/project_status_administration_spec.rb+++ b/spec/features/projects/project_status_administration_spec.rb@@ -61,6 +61,7 @@ describe 'Projects status administration', type: :feature, js: true dofill_in 'Name', with: 'New project'select 'On track', from: 'Status'create_status_description.set_markdown 'Everything is fine at the start'+ create_status_description.expect_supports_no_macrosclick_button 'Create'diff --git a/spec/lib/custom_field_form_builder_spec.rb b/spec/lib/custom_field_form_builder_spec.rbindex 4e226a272e4..21d27dfb856 100644--- a/spec/lib/custom_field_form_builder_spec.rb+++ b/spec/lib/custom_field_form_builder_spec.rb@@ -32,7 +32,7 @@ require 'ostruct'describe CustomFieldFormBuilder doinclude Capybara::RSpecMatchers- let(:helper) { ActionView::Base.new }+ let(:helper) { ActionView::Base.new(ActionView::LookupContext.new('')) }let(:builder) { described_class.new(:user, resource, helper, {}) }describe '#custom_field' do@@ -103,8 +103,8 @@ describe CustomFieldFormBuilder do<textarea class="custom-class form--text-area"id="user#{resource.custom_field_id}"name="user[#{resource.custom_field_id}]"- rows="3"- with_text_formatting="true">+ with_text_formatting="true"+ macros="false"></textarea>}).at_path('textarea')enddiff --git a/spec/support/components/wysiwyg/wysiwyg_editor.rb b/spec/support/components/wysiwyg/wysiwyg_editor.rbindex fa58123d2a0..4d26764f255 100644--- a/spec/support/components/wysiwyg/wysiwyg_editor.rb+++ b/spec/support/components/wysiwyg/wysiwyg_editor.rb@@ -54,6 +54,11 @@ module Componentsexpect(editor_element.text).to eq(value)end+ def expect_supports_no_macros+ expect(container)+ .to have_no_selector('.ck-button', visible: :all, text: 'Macros')+ end+def within_enabled_previewclick_toolbar_button 'Toggle preview mode'begin