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

First commit #1219

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ excludeLanguages ?= ''
includePlugins ?= ''
excludePlugins ?= ''
singleRun ?= true
forceSwc ?= false
isTest ?= false
debug ?= false
updateTests ?= false
Expand Down Expand Up @@ -53,6 +54,7 @@ start dev love:
--env includePlugins=$(includePlugins) \
--env excludePlugins=$(excludePlugins) \
--env isTest=$(isTest) \
--env forceSwc=$(forceSwc) \
--env fat=$(fat)

.PHONY: build
Expand Down
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"@eslint/js": "^9.16.0",
"@playwright/test": "^1.49.0",
"@swc/core": "^1.10.11",
"@swc/helpers": "^0.5.15",
"@types/ace": "^0.0.52",
"@types/fs-extra": "^11.0.4",
"@types/karma": "^6.3.9",
Expand Down
23 changes: 14 additions & 9 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @module config
*/

// eslint-disable-next-line max-classes-per-file
import * as consts from 'jodit/core/constants';
import {
globalDocument,
Expand All @@ -39,11 +40,22 @@ import type {
Nullable
} from './types';

class ProtoConfig {
/**
* Behavior for buttons
*/
controls: Controls = {};
}

ProtoConfig.prototype.controls = {};

/**
* Default Editor's Configuration
*/
class Config implements IViewOptions {
private constructor() {}
class Config extends ProtoConfig implements IViewOptions {
private constructor() {
super();
}

/**
* Use cache for heavy methods
Expand Down Expand Up @@ -940,11 +952,6 @@ class Config implements IViewOptions {
}
];

/**
* Behavior for buttons
*/
controls!: Controls;

/**
* Some events are called when the editor is initialized, for example, the `afterInit` event.
* So this code won't work:
Expand Down Expand Up @@ -998,6 +1005,4 @@ class Config implements IViewOptions {
}
}

Config.prototype.controls = {};

export { Config };
6 changes: 6 additions & 0 deletions src/core/helpers/utils/assert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/

import { IS_PROD } from 'jodit/core/constants';

/**
* @module helpers/utils
*/
Expand All @@ -20,6 +22,10 @@ function assert<T>(
condition: T | false | 0 | '' | null | undefined,
message: string
): asserts condition {
if (IS_PROD) {
return;
}

if (!condition) {
throw new AssertionError(`Assertion failed: ${message}`);
}
Expand Down
6 changes: 4 additions & 2 deletions src/jodit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1267,8 +1267,10 @@ export class Jodit extends ViewWithToolbar implements IJodit, Dlgs {
});
}

currentPlace!: IWorkPlace;
places!: IWorkPlace[];
currentPlace: IWorkPlace = {
options: this.options
} as any;
places: IWorkPlace[] = [];

private readonly __elementToPlace: Map<HTMLElement, IWorkPlace> = new Map();

Expand Down
40 changes: 33 additions & 7 deletions tools/rules/internal-typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,35 @@ export default (
isProd,
isTest,
fat,
superDirname
superDirname,
uglify,
forceSwc
}: Variables,
cwd: string
): RuleSetRule => {
return {
test: /\.(js|ts)$/,
use: [
{
const useSWC = (isProd && !isTest && !generateTypes) || forceSwc;
if (useSWC) {
console.info('Use SWC');
}

const loader = useSWC
? {
loader: 'swc-loader',
options: {
jsc: {
target: ES,
parser: {
syntax: 'typescript',
tsx: false,
dynamicImport: false,
decorators: true
}
// externalHelpers: true
},
minify: uglify
}
}
: {
loader: 'ts-loader',
options: {
transpileOnly: isProd && !isTest && !generateTypes,
Expand All @@ -39,11 +60,16 @@ export default (
declaration: true,
declarationDir: path.resolve(dirname, './build/types')
},
getCustomTransformers: (program: ts.Program) => ({
getCustomTransformers: (): unknown => ({
before: isProd && !isTest ? [removeAsserts()] : []
})
}
},
};

return {
test: /\.(js|ts)$/,
use: [
loader,
{
loader: path.resolve(
superDirname,
Expand Down
3 changes: 3 additions & 0 deletions tools/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function Bool(str: string | boolean | undefined): boolean {

export type ES_TARGET = 'es5' | 'es2015' | 'es2018' | 'es2021';
export type Argv = {
forceSwc?: boolean;
WEBPACK_SERVE?: boolean;
filename?: (name: string) => string;
env: object;
Expand All @@ -33,6 +34,7 @@ export type Argv = {

export type Variables = {
argv: { filename?: (name: string) => string };
forceSwc?: boolean;
exclude: string[];
/**
* Path to root Jodit directory
Expand Down Expand Up @@ -119,6 +121,7 @@ export const variables = (argv: Argv, dir: string): Variables => {
? parseInt(process.env.WEBPACK_DEV_PORT)
: 2000,
argv,
forceSwc: Bool(argv.forceSwc),
onlyTS: false, // TODO
exclude,
generateTypes: Bool(argv.generateTypes),
Expand Down
Loading