Skip to content

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

Allow codeBlock plugin in primer forms using custom modal target

Oliver Günther09fe77035dea
diff --git a/frontend/src/app/shared/components/modals/editor/editor-macros.service.ts b/frontend/src/app/shared/components/modals/editor/editor-macros.service.ts
index a65293ffe4d..5c50973485f 100644
--- a/frontend/src/app/shared/components/modals/editor/editor-macros.service.ts
+++ b/frontend/src/app/shared/components/modals/editor/editor-macros.service.ts
@@ -28,15 +28,26 @@
import { OpModalService } from 'core-app/shared/components/modal/modal.service';
import { Injectable, Injector } from '@angular/core';
-import { WpButtonMacroModalComponent } from 'core-app/shared/components/modals/editor/macro-wp-button-modal/wp-button-macro.modal';
-import { WikiIncludePageMacroModalComponent } from 'core-app/shared/components/modals/editor/macro-wiki-include-page-modal/wiki-include-page-macro.modal';
-import { CodeBlockMacroModalComponent } from 'core-app/shared/components/modals/editor/macro-code-block-modal/code-block-macro.modal';
-import { ChildPagesMacroModalComponent } from 'core-app/shared/components/modals/editor/macro-child-pages-modal/child-pages-macro.modal';
+import {
+ WpButtonMacroModalComponent,
+} from 'core-app/shared/components/modals/editor/macro-wp-button-modal/wp-button-macro.modal';
+import {
+ WikiIncludePageMacroModalComponent,
+} from 'core-app/shared/components/modals/editor/macro-wiki-include-page-modal/wiki-include-page-macro.modal';
+import {
+ CodeBlockMacroModalComponent,
+} from 'core-app/shared/components/modals/editor/macro-code-block-modal/code-block-macro.modal';
+import {
+ ChildPagesMacroModalComponent,
+} from 'core-app/shared/components/modals/editor/macro-child-pages-modal/child-pages-macro.modal';
+import { PortalOutletTarget } from 'core-app/shared/components/modal/portal-outlet-target.enum';
@Injectable()
export class EditorMacrosService {
- constructor(readonly opModalService:OpModalService,
- readonly injector:Injector) {
+ constructor(
+ readonly opModalService:OpModalService,
+ readonly injector:Injector,
+ ) {
}
/**
@@ -44,7 +55,7 @@ export class EditorMacrosService {
* Used from within ckeditor-augmented-textarea.
*/
public configureWorkPackageButton(typeName?:string, classes?:string):Promise<{ type:string, classes:string }> {
- return new Promise<{ type:string, classes:string }>((resolve, reject) => {
+ return new Promise<{ type:string, classes:string }>((resolve, _) => {
this.opModalService.show(
WpButtonMacroModalComponent,
this.injector,
@@ -82,10 +93,15 @@ export class EditorMacrosService {
*/
public editCodeBlock(content:string, languageClass:string):Promise<{ content:string, languageClass:string }> {
return new Promise<{ content:string, languageClass:string }>((resolve, _) => {
+ const target = document.querySelector('opce-custom-modal-overlay') ? PortalOutletTarget.Custom : PortalOutletTarget.Default;
+
this.opModalService.show(
CodeBlockMacroModalComponent,
this.injector,
{ content, languageClass },
+ false,
+ false,
+ target,
).subscribe((modal) => modal.closingEvent.subscribe(() => {
if (modal.changed) {
resolve({ languageClass: modal.languageClass, content: modal.content });
diff --git a/lib/primer/open_project/forms/rich_text_area.html.erb b/lib/primer/open_project/forms/rich_text_area.html.erb
index 92851cac8a8..671274e3f04 100644
--- a/lib/primer/open_project/forms/rich_text_area.html.erb
+++ b/lib/primer/open_project/forms/rich_text_area.html.erb
@@ -6,7 +6,6 @@
inputs: @rich_text_options.reverse_merge(
{
textareaSelector: "##{builder.field_id(@input.name)}",
- removePlugins: ["CodeBlock"],
macros: false,
turboMode: true
}
diff --git a/modules/overviews/app/components/project_custom_fields/sections/edit_component.html.erb b/modules/overviews/app/components/project_custom_fields/sections/edit_component.html.erb
index 9a8fb2480d6..28189882934 100644
--- a/modules/overviews/app/components/project_custom_fields/sections/edit_component.html.erb
+++ b/modules/overviews/app/components/project_custom_fields/sections/edit_component.html.erb
@@ -1,3 +1,4 @@
+<%= helpers.angular_component_tag 'opce-custom-modal-overlay' %>
<%=
component_wrapper do
primer_form_with(