Merge pull request #6450 from opf/fix/bootstrapping-plugin-context

Allow bootstrapping in legacy context

[ci skip]
pull/6453/head
Oliver Günther 6 years ago committed by GitHub
commit 890254e733
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      frontend/legacy/typings/open-project-legacy.typings.d.ts
  2. 1
      frontend/src/app/components/ckeditor/ckeditor-setup.service.ts
  3. 9
      frontend/src/app/components/ckeditor/op-ckeditor-form.component.ts
  4. 12
      frontend/src/app/modules/plugins/plugin-context.ts
  5. 6
      spec/support/components/wysiwyg/wysiwyg_editor.rb

@ -39,6 +39,7 @@ import {GlobalI18n} from "../../src/app/modules/common/i18n/i18n.service";
export interface IPluginContext {
classes:any;
services:any;
bootstrap(element:HTMLElement):void;
}
declare global {

@ -5,6 +5,7 @@ import {Injectable} from "@angular/core";
export interface ICKEditorInstance {
getData():string;
setData(content:string):void;
model:any;
editing:any;
config:any;
}

@ -66,7 +66,6 @@ export class OpCkeditorFormComponent implements OnInit {
protected halResourceService:HalResourceService,
protected ckEditorSetup:CKEditorSetupService,
protected ConfigurationService:ConfigurationService) {
}
public ngOnInit() {
@ -110,7 +109,7 @@ export class OpCkeditorFormComponent implements OnInit {
}
// Listen for form submission to set textarea content
this.formElement.on('submit.ckeditor', () => {
this.formElement.on('submit.ckeditor change.ckeditor', () => {
const value = this.ckeditor.getData();
this.wrappedTextArea.val(value);
@ -138,4 +137,8 @@ export class OpCkeditorFormComponent implements OnInit {
}
}
DynamicBootstrapper.register({ selector: 'op-ckeditor-form', cls: OpCkeditorFormComponent });
DynamicBootstrapper.register({
selector: 'op-ckeditor-form',
cls: OpCkeditorFormComponent,
embeddable: true
});

@ -1,4 +1,4 @@
import {Injector} from "@angular/core";
import {ApplicationRef, Injector} from "@angular/core";
import {HookService} from "core-app/modules/plugins/hook-service";
import {NotificationsService} from "core-app/modules/common/notifications/notifications.service";
import {ConfirmDialogService} from "core-components/modals/confirm-dialog/confirm-dialog.service";
@ -22,6 +22,7 @@ import {EditorMacrosService} from "core-components/modals/editor/editor-macros.s
import {HTMLSanitizeService} from "../common/html-sanitize/html-sanitize.service";
import {PathHelperService} from "../common/path-helper/path-helper.service";
import {CKEditorPreviewService} from "core-components/ckeditor/ckeditor-preview.service";
import {DynamicBootstrapper} from "core-app/globals/dynamic-bootstrapper";
/**
* Plugin context bridge for plugins outside the CLI compiler context
@ -53,7 +54,7 @@ export class OpenProjectPluginContext {
macros: this.injector.get<EditorMacrosService>(EditorMacrosService),
htmlSanitizeService: this.injector.get<HTMLSanitizeService>(HTMLSanitizeService),
ckEditorPreview: this.injector.get<CKEditorPreviewService>(CKEditorPreviewService),
pathHelperService: this.injector.get<PathHelperService>(PathHelperService)
pathHelperService: this.injector.get<PathHelperService>(PathHelperService),
};
// Random collection of classes needed outside of angular
@ -78,4 +79,11 @@ export class OpenProjectPluginContext {
this.hooks[hook] = (callback:Function) => this.services.hooks.register(hook, callback);
});
}
public bootstrap(element:HTMLElement) {
DynamicBootstrapper.bootstrapOptionalEmbeddable(
this.injector.get(ApplicationRef),
element
)
}
}

@ -24,7 +24,7 @@ module Components
end
def expect_value(value)
expect(input_element.text).to eq(value)
expect(editor_element.text).to eq(value)
end
def within_enabled_preview
@ -43,10 +43,10 @@ module Components
def click_and_type_slowly(text)
sleep 0.5
input_element.click
editor_element.click
sleep 0.5
input_element.send_keys text
editor_element.send_keys text
sleep 0.5
end

Loading…
Cancel
Save