Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prioritize reading files from config/env/envName/ckeditor.js|ts first #172

Closed
cslegany-synerinsoft opened this issue Oct 21, 2024 · 3 comments
Labels
issue: bug Something isn't working

Comments

@cslegany-synerinsoft
Copy link

Is your feature request related to a problem? Please describe.
A custom configuration is needed by us to remove h1 and h2 options and keep just the rest. Here is the content of config/ ckeditor.ts which ovverrides the default preset.

const CKEConfig = () => ({ presets: { default: { editorConfig: { heading: { options: [ { model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph' }, { model: 'heading3', view: 'h3', title: 'Heading 3', class: 'ck-heading_heading3', }, { model: 'heading4', view: 'h4', title: 'Heading 4', class: 'ck-heading_heading4', }, { model: 'heading5', view: 'h5', title: 'Heading 5', class: 'ck-heading_heading5', }, { model: 'heading6', view: 'h6', title: 'Heading 6', class: 'ck-heading_heading6', }, ], }, } } }, });

We have different environments like production, staging etc. Currently the strapi ckeditor plugin doesn't support priorized reading from config/env/envName/ckeditor.js|ts first. As a result it seems to me that the plugin cannot load the config file on our environments.

Describe the solution you'd like
Priorized reading from config/env/envName/ckeditor.js|ts first.

@nshenderov nshenderov added the issue: bug Something isn't working label Oct 21, 2024
@nshenderov
Copy link
Owner

@cslegany-synerinsoft
Copy link
Author

Thanks, but it wasn't working in the Typescript Strapi project using the latest version of the plugin.

Generated js file is as follows:

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const CKEConfig = () => ({
    presets: {
        default: {
            editorConfig: {
                heading: {
                    options: [
                        { model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph' },
                        {
                            model: 'heading3',
                            view: 'h3',
                            title: 'Heading 3',
                            class: 'ck-heading_heading3',
                        },
                        {
                            model: 'heading4',
                            view: 'h4',
                            title: 'Heading 4',
                            class: 'ck-heading_heading4',
                        },
                        {
                            model: 'heading5',
                            view: 'h5',
                            title: 'Heading 5',
                            class: 'ck-heading_heading5',
                        },
                        {
                            model: 'heading6',
                            view: 'h6',
                            title: 'Heading 6',
                            class: 'ck-heading_heading6',
                        },
                    ],
                },
            }
        }
    },
});

globalThis.SH_CKE_CONFIG = CKEConfig()
globalThis.SH_CKE_UPLOAD_ADAPTER_IS_RESPONSIVE = true

The plugin doesn't load even on localhost and we get Uncaught ReferenceError: exports is not defined on line
Object.defineProperty(exports, "__esModule", { value: true });

in the file generated from Typescript. Tsconfig.json is as follows:

{
  "compilerOptions": {
    "module": "CommonJS",
    "moduleDetection": "force",
    "moduleResolution": "Node",
    "lib": ["ES2020"],
    "target": "ES2019",
    }
}

moduleDetection is needed because of the different environments, and CommonJS and ES2019 are needed by Strapi, you cannot go back to es2015 because Strapi would fail to load.

@nshenderov
Copy link
Owner

@cslegany-synerinsoft I see the issue. I didn't test it with "moduleDetection": "force". Since the content of ckeditor.js is pasted into the script tag, the line added by TS Object.defineProperty(exports, "__esModule", { value: true }); causes a problem. I'll look into a solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants