Skip to content

Commit

Permalink
Merge pull request #16 from Patternslib/classbased
Browse files Browse the repository at this point in the history
Classbased
  • Loading branch information
thet authored Oct 17, 2022
2 parents 6b3bd5e + 7dea759 commit 5f559ea
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 18 deletions.
2 changes: 0 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Webpack entry point for module federation.
import "@patternslib/patternslib/webpack/module_federation";
// The next import needs to be kept with brackets, otherwise we get this error:
// "Shared module is not available for eager consumption."
import("./bundle-config");
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"devDependencies": {
"@patternslib/dev": "^3.0.0",
"@patternslib/patternslib": ">= 9.7.0-alpha.2"
"@patternslib/patternslib": ">= 9.7.0-alpha.3"
},
"scripts": {
"start": "NODE_ENV=development webpack serve --config webpack.config.js",
Expand Down
24 changes: 17 additions & 7 deletions src/ckeditor.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import Base from "@patternslib/patternslib/src/core/base";
import { BasePattern } from "@patternslib/patternslib/src/core/basepattern";
import Parser from "@patternslib/patternslib/src/core/parser";
import registry from "@patternslib/patternslib/src/core/registry";

export default Base.extend({
name: "ckeditor",
trigger: ".pat-ckeditor",
editor: null,
export const parser = new Parser("ckeditor");

class Pattern extends BasePattern {
static name = "ckeditor";
static trigger = ".pat-ckeditor";
parser = parser;
editor = null;

async init() {
const CKEditor = (await import("@ckeditor/ckeditor5-build-classic")).default;
Expand All @@ -13,5 +18,10 @@ export default Base.extend({
// Synchonize text changes with textarea
this.el.value = this.editor.getData();
});
},
});
}
}

registry.register(Pattern);

export default Pattern;
export { Pattern };
8 changes: 4 additions & 4 deletions src/ckeditor.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pattern from "./ckeditor";
import utils from "@patternslib/patternslib/src/core/utils";
import Pattern from "./ckeditor";
import events from "@patternslib/patternslib/src/core/events";

describe("pat-ckeditor", () => {
beforeEach(() => {
Expand All @@ -13,8 +13,8 @@ describe("pat-ckeditor", () => {
</form>
`;

const instance = pattern.init(document.querySelector(".pat-ckeditor"));
await utils.timeout(1);
const instance = new Pattern(document.querySelector(".pat-ckeditor"));
await events.await_pattern_init(instance);

expect(document.querySelector(".ck")).toBeTruthy();
expect(document.querySelector("textarea").value).toBe("");
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2444,10 +2444,10 @@
whybundled "^2.0.0"
yarn "^1.22.19"

"@patternslib/patternslib@>= 9.7.0-alpha.2":
version "9.7.0-alpha.2"
resolved "https://registry.yarnpkg.com/@patternslib/patternslib/-/patternslib-9.7.0-alpha.2.tgz#7f5b0698059c180412d1a86562b05b612bb6f6ee"
integrity sha512-Pdkk1i799YSKUiwkLpVoVI/LppE5140AoYjBc7wgGadRuG7e7EkIGfA1sHQHMmoR/K+qbQsp7DAxsB1g7So7QQ==
"@patternslib/patternslib@>= 9.7.0-alpha.3":
version "9.7.0-alpha.3"
resolved "https://registry.yarnpkg.com/@patternslib/patternslib/-/patternslib-9.7.0-alpha.3.tgz#e1c0124d60f4470ee75be1cee587080119e598c9"
integrity sha512-7fWPE1hOl4+rA8v6w9VdWZ8pla4C1z9E5sajCaeHu9rS4onKzkSBnrDBAvlgZ6ucuHZQX/E5ilEQVpKhe+XkEw==
dependencies:
"@fullcalendar/adaptive" "^5.11.3"
"@fullcalendar/core" "^5.11.3"
Expand Down

0 comments on commit 5f559ea

Please sign in to comment.