jodit-react 5.0.2 → 5.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * jodit - Jodit is an awesome and useful wysiwyg editor with filebrowser
3
3
  * Author: Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/jodit/)
4
- * Version: v4.2.47
4
+ * Version: v4.2.49
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -1,14 +1,13 @@
1
1
  import React from 'react';
2
2
  import type { IJodit } from 'jodit/types/types/jodit';
3
- import type { Jodit as JoditConstructorType } from 'jodit';
4
- import type { Config } from 'jodit/config';
3
+ import type { Jodit as JoditBaseConstructor } from 'jodit/types/index';
4
+ import type { Config as BaseConfig } from 'jodit/config';
5
+ import type { Config } from 'jodit/types/config';
5
6
  import { Jodit } from './include.jodit';
6
- type DeepPartial<T> = T extends object ? {
7
- [P in keyof T]?: DeepPartial<T[P]>;
8
- } : T;
9
- interface Props<T extends typeof JoditConstructorType = typeof Jodit> {
7
+ import type { DeepPartial } from 'jodit/types/types';
8
+ interface Props<T extends typeof JoditBaseConstructor = typeof Jodit> {
10
9
  JoditConstructor?: T;
11
- config?: DeepPartial<Config>;
10
+ config?: DeepPartial<Config & BaseConfig>;
12
11
  className?: string;
13
12
  id?: string;
14
13
  name?: string;
@@ -18,5 +17,5 @@ interface Props<T extends typeof JoditConstructorType = typeof Jodit> {
18
17
  value?: string;
19
18
  editorRef?: (editor: IJodit) => void;
20
19
  }
21
- declare const JoditEditor: React.ForwardRefExoticComponent<Props<typeof JoditConstructorType> & React.RefAttributes<IJodit>>;
20
+ declare const JoditEditor: React.ForwardRefExoticComponent<Props<typeof JoditBaseConstructor> & React.RefAttributes<IJodit>>;
22
21
  export default JoditEditor;
package/jest.config.ts ADDED
@@ -0,0 +1,191 @@
1
+ /**
2
+ * For a detailed explanation regarding each configuration property, visit:
3
+ * https://jestjs.io/docs/configuration
4
+ */
5
+
6
+ import type { Config } from 'jest';
7
+
8
+ const config: Config = {
9
+ // All imported modules in your tests should be mocked automatically
10
+ // automock: false,
11
+
12
+ // Stop running tests after `n` failures
13
+ // bail: 0,
14
+
15
+ // The directory where Jest should store its cached dependency information
16
+ // cacheDirectory: "/private/var/folders/8l/p68024d92vv46q4x6txcn21n2frs00/T/jest_j4gfsw",
17
+
18
+ // Automatically clear mock calls, instances, contexts and results before every test
19
+ clearMocks: true,
20
+
21
+ // Indicates whether the coverage information should be collected while executing the test
22
+ collectCoverage: true,
23
+
24
+ // An array of glob patterns indicating a set of files for which coverage information should be collected
25
+ // collectCoverageFrom: undefined,
26
+
27
+ // The directory where Jest should output its coverage files
28
+ coverageDirectory: 'coverage',
29
+
30
+ // An array of regexp pattern strings used to skip coverage collection
31
+ // coveragePathIgnorePatterns: [
32
+ // "/node_modules/"
33
+ // ],
34
+
35
+ // Indicates which provider should be used to instrument code for coverage
36
+ coverageProvider: 'v8',
37
+
38
+ // A list of reporter names that Jest uses when writing coverage reports
39
+ // coverageReporters: [
40
+ // "json",
41
+ // "text",
42
+ // "lcov",
43
+ // "clover"
44
+ // ],
45
+
46
+ // An object that configures minimum threshold enforcement for coverage results
47
+ // coverageThreshold: undefined,
48
+
49
+ // A path to a custom dependency extractor
50
+ // dependencyExtractor: undefined,
51
+
52
+ // Make calling deprecated APIs throw helpful error messages
53
+ // errorOnDeprecated: false,
54
+
55
+ // The default configuration for fake timers
56
+ // fakeTimers: {
57
+ // "enableGlobally": false
58
+ // },
59
+
60
+ // Force coverage collection from ignored files using an array of glob patterns
61
+ // forceCoverageMatch: [],
62
+
63
+ // A path to a module which exports an async function that is triggered once before all test suites
64
+ // globalSetup: undefined,
65
+
66
+ // A path to a module which exports an async function that is triggered once after all test suites
67
+ // globalTeardown: undefined,
68
+
69
+ // A set of global variables that need to be available in all test environments
70
+ // globals: {},
71
+
72
+ // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
73
+ // maxWorkers: "50%",
74
+
75
+ // An array of directory names to be searched recursively up from the requiring module's location
76
+ // moduleDirectories: [
77
+ // "node_modules"
78
+ // ],
79
+
80
+ // An array of file extensions your modules use
81
+ moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json', 'css'],
82
+
83
+ // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
84
+ moduleNameMapper: {
85
+ '\\.(css|less)$': '<rootDir>/__mocks__/styleMock.js'
86
+ },
87
+
88
+ // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
89
+ // modulePathIgnorePatterns: [],
90
+
91
+ // Activates notifications for test results
92
+ // notify: false,
93
+
94
+ // An enum that specifies notification mode. Requires { notify: true }
95
+ // notifyMode: "failure-change",
96
+
97
+ // A preset that is used as a base for Jest's configuration
98
+ // preset: undefined,
99
+
100
+ // Run tests from one or more projects
101
+ // projects: undefined,
102
+
103
+ // Use this configuration option to add custom reporters to Jest
104
+ // reporters: undefined,
105
+
106
+ // Automatically reset mock state before every test
107
+ // resetMocks: false,
108
+
109
+ // Reset the module registry before running each individual test
110
+ // resetModules: false,
111
+
112
+ // A path to a custom resolver
113
+ // resolver: undefined,
114
+
115
+ // Automatically restore mock state and implementation before every test
116
+ // restoreMocks: false,
117
+
118
+ // The root directory that Jest should scan for tests and modules within
119
+ // rootDir: undefined,
120
+
121
+ // A list of paths to directories that Jest should use to search for files in
122
+ // roots: [
123
+ // "<rootDir>"
124
+ // ],
125
+
126
+ // Allows you to use a custom runner instead of Jest's default test runner
127
+ // runner: "jest-runner",
128
+
129
+ // The paths to modules that run some code to configure or set up the testing environment before each test
130
+ // setupFiles: [],
131
+
132
+ // A list of paths to modules that run some code to configure or set up the testing framework before each test
133
+ // setupFilesAfterEnv: [],
134
+
135
+ // The number of seconds after which a test is considered as slow and reported as such in the results.
136
+ // slowTestThreshold: 5,
137
+
138
+ // A list of paths to snapshot serializer modules Jest should use for snapshot testing
139
+ // snapshotSerializers: [],
140
+
141
+ // The test environment that will be used for testing
142
+ testEnvironment: 'jsdom',
143
+
144
+ // Options that will be passed to the testEnvironment
145
+ // testEnvironmentOptions: {},
146
+
147
+ // Adds a location field to test results
148
+ // testLocationInResults: false,
149
+
150
+ // The glob patterns Jest uses to detect test files
151
+ // testMatch: [
152
+ // "**/__tests__/**/*.[jt]s?(x)",
153
+ // "**/?(*.)+(spec|test).[tj]s?(x)"
154
+ // ],
155
+
156
+ // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
157
+ // testPathIgnorePatterns: [
158
+ // "/node_modules/"
159
+ // ],
160
+
161
+ // The regexp pattern or array of patterns that Jest uses to detect test files
162
+ // testRegex: [],
163
+
164
+ // This option allows the use of a custom results processor
165
+ // testResultsProcessor: undefined,
166
+
167
+ // This option allows use of a custom test runner
168
+ // testRunner: "jest-circus/runner",
169
+
170
+ // A map from regular expressions to paths to transformers
171
+ transform: {
172
+ '^.+.tsx?$': ['ts-jest', {}]
173
+ }
174
+
175
+ // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
176
+ // transformIgnorePatterns: ['/node_modules/', '\\.css$']
177
+
178
+ // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
179
+ // unmockedModulePathPatterns: undefined,
180
+
181
+ // Indicates whether each individual test should be reported during the run
182
+ // verbose: undefined,
183
+
184
+ // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
185
+ // watchPathIgnorePatterns: [],
186
+
187
+ // Whether to use watchman for file crawling
188
+ // watchman: true,
189
+ };
190
+
191
+ export default config;
package/package.json CHANGED
@@ -1,84 +1,96 @@
1
1
  {
2
- "name": "jodit-react",
3
- "version": "5.0.2",
4
- "description": "Jodit is awesome and usefully wysiwyg editor with filebrowser",
5
- "main": "build/jodit-react.js",
6
- "author": "Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/)",
7
- "keywords": [
8
- "react",
9
- "jodit",
10
- "html",
11
- "text",
12
- "editor",
13
- "wysisyg",
14
- "rich editor",
15
- "rich text editor",
16
- "rte"
17
- ],
18
- "dependencies": {
19
- "jodit": "^4.2.47"
20
- },
21
- "peerDependencies": {
22
- "react": "~0.14 || ^15 || ^16 || ^17 || ^18 || ^19",
23
- "react-dom": "~0.14 || ^15 || ^16 || ^17 || ^18 || ^19"
24
- },
25
- "devDependencies": {
26
- "@eslint/compat": "^1.2.5",
27
- "@swc-node/register": "^1.10.9",
28
- "@swc/core": "^1.10.7",
29
- "@types/react": "^19.0.7",
30
- "@types/react-dom": "^19.0.3",
31
- "@typescript-eslint/eslint-plugin": "^8.20.0",
32
- "css-loader": "^7.1.2",
33
- "eslint": "9.18.0",
34
- "eslint-config-prettier": "^10.0.1",
35
- "eslint-plugin-prettier": "^5.2.3",
36
- "eslint-plugin-react": "^7.37.4",
37
- "eslint-plugin-react-hooks": "^5.1.0",
38
- "prettier": "^3.4.2",
39
- "react": "^19.0.0",
40
- "react-dom": "^19.0.0",
41
- "replace": "^1.2.2",
42
- "style-loader": "^4.0.0",
43
- "swc-loader": "^0.2.6",
44
- "typescript": "^5.7.3",
45
- "webpack": "^5.97.1",
46
- "webpack-cli": "^6.0.1",
47
- "webpack-dev-server": "^5.2.0"
48
- },
49
- "scripts": {
50
- "newversion": "npm version patch --no-git-tag-version && npm run github",
51
- "lint": "npm run lint:ts && npm run lint:eslint",
52
- "lint:ts": "tsc --noEmit",
53
- "lint:eslint": "eslint ./",
54
- "demo": "NODE_ENV=development node -r @swc-node/register ./node_modules/.bin/webpack serve --config ./examples/webpack.config.ts --mode development",
55
- "start": "npm run demo",
56
- "build": "npm run build:react && npm run build:types",
57
- "build:react": "NODE_ENV=production node -r @swc-node/register ./node_modules/.bin/webpack --mode production",
58
- "build:types": "rm -rf ./build/types && tsc --project tsconfig.types.json --emitDeclarationOnly",
59
- "remove-css": "replace \"import '[^']+.css';\" '' ./build/**/*.ts",
60
- "github": "npm run git && git push --tags origin HEAD:main",
61
- "git": "git add --all && git commit -m \"New version $npm_package_version. Read more https://github.com/jodit/jodit-react/releases/tag/$npm_package_version \" && git tag $npm_package_version"
62
- },
63
- "repository": {
64
- "type": "git",
65
- "url": "git+https://github.com/jodit/jodit-react.git"
66
- },
67
- "license": "MIT",
68
- "bugs": {
69
- "url": "https://github.com/jodit/jodit-react/issues"
70
- },
71
- "homepage": "https://xdsoft.net/jodit/",
72
- "ava": {
73
- "extensions": [
74
- "ts",
75
- "tsx"
76
- ],
77
- "require": [
78
- "@swc-node/register"
79
- ],
80
- "files": [
81
- "packages/**/*.spec.{ts,tsx}"
82
- ]
83
- }
2
+ "name": "jodit-react",
3
+ "version": "5.0.7",
4
+ "description": "Jodit is awesome and usefully wysiwyg editor with filebrowser",
5
+ "main": "build/jodit-react.js",
6
+ "author": "Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/)",
7
+ "keywords": [
8
+ "react",
9
+ "jodit",
10
+ "html",
11
+ "text",
12
+ "editor",
13
+ "wysisyg",
14
+ "rich editor",
15
+ "rich text editor",
16
+ "rte"
17
+ ],
18
+ "dependencies": {
19
+ "jodit": "^4.2.48"
20
+ },
21
+ "peerDependencies": {
22
+ "react": "~0.14 || ^15 || ^16 || ^17 || ^18 || ^19",
23
+ "react-dom": "~0.14 || ^15 || ^16 || ^17 || ^18 || ^19"
24
+ },
25
+ "devDependencies": {
26
+ "@eslint/compat": "^1.2.5",
27
+ "@jest/globals": "^29.7.0",
28
+ "@swc-node/register": "^1.10.9",
29
+ "@swc/core": "^1.10.7",
30
+ "@testing-library/dom": "^10.4.0",
31
+ "@testing-library/jest-dom": "^6.6.3",
32
+ "@testing-library/react": "^16.2.0",
33
+ "@testing-library/user-event": "^14.6.0",
34
+ "@types/jest": "^29.5.14",
35
+ "@types/react": "^19.0.7",
36
+ "@types/react-dom": "^19.0.3",
37
+ "@typescript-eslint/eslint-plugin": "^8.20.0",
38
+ "css-loader": "^7.1.2",
39
+ "eslint": "9.18.0",
40
+ "eslint-config-prettier": "^10.0.1",
41
+ "eslint-plugin-jest": "^28.11.0",
42
+ "eslint-plugin-prettier": "^5.2.3",
43
+ "eslint-plugin-react": "^7.37.4",
44
+ "eslint-plugin-react-hooks": "^5.1.0",
45
+ "jest": "^29.7.0",
46
+ "jest-environment-jsdom": "^29.7.0",
47
+ "prettier": "^3.4.2",
48
+ "react": "^19.0.0",
49
+ "react-dom": "^19.0.0",
50
+ "replace": "^1.2.2",
51
+ "style-loader": "^4.0.0",
52
+ "swc-loader": "^0.2.6",
53
+ "ts-jest": "^29.2.5",
54
+ "ts-node": "^10.9.2",
55
+ "typescript": "^5.7.3",
56
+ "webpack": "^5.97.1",
57
+ "webpack-cli": "^6.0.1",
58
+ "webpack-dev-server": "^5.2.0"
59
+ },
60
+ "scripts": {
61
+ "newversion": "npm version patch --no-git-tag-version && npm run github",
62
+ "lint": "npm run lint:ts && npm run lint:eslint",
63
+ "lint:ts": "tsc --noEmit",
64
+ "lint:eslint": "eslint ./",
65
+ "demo": "NODE_ENV=development node -r @swc-node/register ./node_modules/.bin/webpack serve --config ./examples/webpack.config.ts --mode development",
66
+ "start": "npm run demo",
67
+ "build": "npm run build:react && npm run build:types",
68
+ "build:react": "NODE_ENV=production node -r @swc-node/register ./node_modules/.bin/webpack --mode production",
69
+ "build:types": "rm -rf ./build/types && tsc --project tsconfig.types.json --emitDeclarationOnly",
70
+ "remove-css": "replace \"import '[^']+.css';\" '' ./build/**/*.ts",
71
+ "github": "npm run git && git push --tags origin HEAD:main",
72
+ "git": "git add --all && git commit -m \"New version $npm_package_version. Read more https://github.com/jodit/jodit-react/releases/tag/$npm_package_version \" && git tag $npm_package_version",
73
+ "test": "jest"
74
+ },
75
+ "repository": {
76
+ "type": "git",
77
+ "url": "git+https://github.com/jodit/jodit-react.git"
78
+ },
79
+ "license": "MIT",
80
+ "bugs": {
81
+ "url": "https://github.com/jodit/jodit-react/issues"
82
+ },
83
+ "homepage": "https://xdsoft.net/jodit/",
84
+ "ava": {
85
+ "extensions": [
86
+ "ts",
87
+ "tsx"
88
+ ],
89
+ "require": [
90
+ "@swc-node/register"
91
+ ],
92
+ "files": [
93
+ "packages/**/*.spec.{ts,tsx}"
94
+ ]
95
+ }
84
96
  }
@@ -1,8 +1,10 @@
1
1
  import React, { useEffect, useRef, forwardRef, useLayoutEffect } from 'react';
2
2
  import type { IJodit } from 'jodit/types/types/jodit';
3
- import type { Jodit as JoditConstructorType } from 'jodit';
4
- import type { Config } from 'jodit/config';
3
+ import type { Jodit as JoditBaseConstructor } from 'jodit/types/index';
4
+ import type { Config as BaseConfig } from 'jodit/config';
5
+ import type { Config } from 'jodit/types/config';
5
6
  import { Jodit } from './include.jodit';
7
+ import type { DeepPartial } from 'jodit/types/types';
6
8
 
7
9
  function usePrevious(value: string): string {
8
10
  const ref = useRef<string>('');
@@ -12,15 +14,9 @@ function usePrevious(value: string): string {
12
14
  return ref.current;
13
15
  }
14
16
 
15
- type DeepPartial<T> = T extends object
16
- ? {
17
- [P in keyof T]?: DeepPartial<T[P]>;
18
- }
19
- : T;
20
-
21
- interface Props<T extends typeof JoditConstructorType = typeof Jodit> {
17
+ interface Props<T extends typeof JoditBaseConstructor = typeof Jodit> {
22
18
  JoditConstructor?: T;
23
- config?: DeepPartial<Config>;
19
+ config?: DeepPartial<Config & BaseConfig>;
24
20
  className?: string;
25
21
  id?: string;
26
22
  name?: string;
@@ -70,8 +66,12 @@ const JoditEditor = forwardRef<IJodit, Props>(
70
66
  }
71
67
 
72
68
  return () => {
73
- if (jodit) {
69
+ if (jodit.isReady) {
74
70
  jodit.destruct();
71
+ } else {
72
+ jodit
73
+ .waitForReady()
74
+ .then(joditInstance => joditInstance.destruct());
75
75
  }
76
76
  };
77
77
  }, [JoditConstructor, config, editorRef]);