tinymce-solid 0.0.8 → 0.0.10

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,227 +0,0 @@
1
- import { createSignal, Show } from 'solid-js';
2
- import { render } from "solid-js/web";
3
- import { describe, it, expect } from 'vitest';
4
- import { type IAllProps } from "~/index";
5
-
6
- import { Editor } from './fixtures/Editor';
7
- import SolidEditor from '~/index';
8
- import { ScriptLoader } from '~/ScriptLoader2';
9
- import { Editor as TinyMCE } from 'tinymce';
10
-
11
- describe("Test <SolidEditor />", () => {
12
- const container = document.createElement('div');
13
- document.body.append(container);
14
-
15
- beforeEach(() => {
16
- container.innerHTML = '';
17
- })
18
-
19
- it("initializes with cloud scripts", async () => {
20
- render(() => <SolidEditor />, container);
21
- const editorArea = await vi.waitUntil(() =>
22
- container.querySelector('iframe')?.contentWindow?.document.getElementById('tinymce'),
23
- { timeout: 1000, interval: 50 }
24
- );
25
- expect(editorArea).to.exist;
26
- });
27
-
28
- it("renders the editor target with DIV tag", () => {
29
- render(() => <Editor inline />, container);
30
- const target = container.querySelector('div');
31
-
32
- expect(target).to.exist;
33
- });
34
-
35
- it("removes TinyMCE instance on unmount", async () => {
36
- const [mounted, setMounted] = createSignal(true);
37
- render(() => <Show fallback={'Not mounted'} when={mounted()}><Editor /></Show>, container);
38
-
39
- const editorArea = await vi.waitUntil(() =>
40
- container.querySelector('iframe')?.contentWindow?.document.getElementById('tinymce'),
41
- { timeout: 1000, interval: 50 }
42
- );
43
- expect(editorArea).to.exist;
44
-
45
- setTimeout(() => {
46
- setMounted(false);
47
- }, 1100)
48
-
49
- setTimeout(() => {
50
- expect(editorArea).to.not.exist;
51
- }, 1200)
52
- });
53
-
54
- it("reinitialize on demand", async () => {
55
- render(() => <SolidEditor licenseKey='gpl' tinymceScriptSrc={['tinymce/tinymce.js']} />, container);
56
-
57
- const editorArea = await vi.waitUntil(() =>
58
- container.querySelector('iframe')?.contentWindow?.document.getElementById('tinymce'),
59
- { timeout: 1000, interval: 50 }
60
- );
61
- expect(editorArea).to.exist;
62
-
63
- setTimeout(() => {
64
- ScriptLoader.reinitialize();
65
- expect(editorArea).to.not.exist;
66
- }, 1100)
67
-
68
- setTimeout(() => {
69
- expect(editorArea).to.exist;
70
- }, 1200)
71
-
72
- });
73
-
74
- it("reacts to CONTENT changes", async () => {
75
- const [content, setContent] = createSignal('<p>Hello TinyMCE!</p>');
76
-
77
- const SolidEditor = () => {
78
- return (
79
- <Editor
80
- id="tiny-mce-test"
81
- initialValue='Some initial Value'
82
- value={content()}
83
- init={{
84
- height: 500,
85
- menubar: false,
86
- placeholder: "Type an email content here...",
87
- file_picker_types: "image",
88
- plugins:
89
- "preview importcss searchreplace autolink autosave save directionality code visualblocks visualchars fullscreen image link media codesample table charmap pagebreak nonbreaking anchor insertdatetime advlist lists wordcount help charmap quickbars emoticons accordion help",
90
- toolbar:
91
- "undo redo | blocks fontfamily fontsize | bold italic underline strikethrough | align numlist bullist | link image | table media | lineheight outdent indent| forecolor backcolor removeformat | charmap emoticons | code fullscreen preview | save print | accordion accordionremove | pagebreak anchor codesample | ltr rtl | help",
92
- }}
93
- onEditorChange={(newContent: string) => {
94
- setContent(newContent);
95
- }}
96
- />
97
- );
98
- };
99
-
100
- render(() => <SolidEditor />, container);
101
-
102
- const editorArea = await vi.waitUntil(() => {
103
- return container.querySelector('iframe')?.contentWindow?.document.getElementById('tinymce');
104
- }, { timeout: 1000, interval: 50 });
105
- expect(editorArea).to.exist;
106
-
107
- setTimeout(() => {
108
- expect(editorArea?.innerText).to.contain('Hello TinyMCE!');
109
- setContent('New Content');
110
- }, 1100)
111
-
112
- setTimeout(() => {
113
- expect(editorArea?.innerText).to.contain('New Content');
114
- }, 1200);
115
-
116
- setTimeout(() => {
117
- // console.log(editorArea.innerText);
118
- expect(editorArea?.innerText).to.contain('testtext');
119
- expect(editorArea?.innerHTML).to.equal(content());
120
- }, 1300);
121
-
122
- });
123
-
124
- it("reacts to keyboard inputs", async () => {
125
- const [content, setContent] = createSignal('');
126
-
127
- const SolidEditor = () => {
128
- return (
129
- <Editor
130
- value={content()}
131
- onEditorChange={(newContent: string) => {
132
- setContent(newContent);
133
- }}
134
- />
135
- );
136
- };
137
-
138
- render(() => <SolidEditor />, container);
139
-
140
- const editorArea = await vi.waitUntil(() => {
141
- return container.querySelector('iframe')?.contentWindow?.document.getElementById('tinymce');
142
- }, { timeout: 1000, interval: 50 });
143
- expect(editorArea).to.exist;
144
-
145
- setTimeout(() => {
146
- editorArea.focus();
147
- 'testtext'.split('').forEach(c => {
148
- editorArea.dispatchEvent(new KeyboardEvent('keypress', { key: c }));
149
- })
150
- }, 1100);
151
-
152
- setTimeout(() => {
153
- expect(editorArea?.innerText).to.contain('testtext');
154
- expect(editorArea?.innerHTML).to.equal(content());
155
- }, 1200);
156
-
157
- });
158
-
159
- it("reacts to theme changes", async () => {
160
- const [skin, setSkin] = createSignal<IAllProps["skin"]>("oxide");
161
- const [css, setCss] = createSignal<IAllProps["contentCss"]>("default");
162
- const ToggleDark = () => <button id="dark" onClick={() => {
163
- setCss(prev => prev === 'default' ? 'dark' : 'default')
164
- setSkin(prev => prev === 'oxide' ? 'oxide-dark' : 'oxide')
165
- }}>{css() === 'default' ? "LIGHT" : "DARK"}</button>;
166
- render(() => <><ToggleDark /><Editor skin={skin()} contentCss={css()} /></>, container);
167
- const textarea = document.querySelector('textarea');
168
-
169
- const editorArea = await vi.waitUntil(() =>
170
- container.querySelector('iframe')?.contentWindow?.document.getElementById('tinymce'), { timeout: 1000, interval: 50 }
171
- );
172
- expect(editorArea).to.exist;
173
-
174
- setTimeout(() => {
175
- document.getElementById('dark')?.click()
176
- }, 1200);
177
-
178
- setTimeout(() => {
179
- expect(textarea?.dataset.skin).to.equal('oxide-dark');
180
- expect(textarea?.dataset.css).to.equal('dark');
181
- }, 1300)
182
-
183
- setTimeout(() => {
184
- document.getElementById('dark')?.click()
185
- }, 1400);
186
-
187
- setTimeout(() => {
188
- expect(textarea?.dataset.skin).to.equal('oxide');
189
- expect(textarea?.dataset.css).to.equal('default');
190
- }, 1500)
191
- });
192
-
193
- it("reacts to DISABLED changes", async () => {
194
- let editorRef: TinyMCE;
195
- const [disabled, setDisabled] = createSignal(false);
196
- const ToggleDisabled = () => <button id="disable" onClick={() => setDisabled(prev => !prev)}>{disabled() ? 'ENABLE' : 'DISABLE'}</button>
197
-
198
- render(() => <><ToggleDisabled /><Editor onInit={(_, ed) => editorRef = ed} disabled={disabled()} /></>, container);
199
- const textarea = document.querySelector('textarea');
200
-
201
- const editorArea = await vi.waitUntil(() => {
202
- return container.querySelector('iframe')?.contentWindow?.document.getElementById('tinymce');
203
- }, { timeout: 1000, interval: 50 });
204
- expect(editorArea).to.exist;
205
-
206
- document.getElementById('disable')?.click();
207
-
208
- setTimeout(() => {
209
- expect(editorRef).to.not.be.undefined;
210
-
211
- expect(textarea?.dataset.disabled).to.equal('true');
212
- document.getElementById('disable')?.click()
213
- }, 100)
214
-
215
- setTimeout(() => {
216
- expect(textarea?.dataset.disabled).to.equal('false');
217
- }, 150)
218
-
219
- setTimeout(() => {
220
- document.getElementById('disable')?.click()
221
- }, 200)
222
-
223
- setTimeout(() => {
224
- expect(textarea?.dataset.disabled).to.equal('true');
225
- }, 250)
226
- });
227
- });
package/tsconfig.json DELETED
@@ -1,25 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "ESNext",
5
- "lib": ["DOM", "DOM.Iterable", "ESNext"],
6
- "moduleResolution": "bundler",
7
- "allowSyntheticDefaultImports": true,
8
- "allowImportingTsExtensions": true,
9
- "esModuleInterop": true,
10
- "jsx": "preserve",
11
- "jsxImportSource": "solid-js",
12
- "allowJs": true,
13
- "strict": true,
14
- "noEmit": true,
15
- "types": ["vite/client", "vitest/globals", "node"],
16
- "isolatedModules": true,
17
- "baseUrl": ".",
18
- "paths": {
19
- "~/*": ["./src/*"],
20
- "@/*": ["./demo/*"],
21
- }
22
- },
23
- "include": ["src", "test", "demo", "vitest.config-ui.ts", "vitest.config.ts"],
24
- "exclude": ["node_modules", "dist", "experiments"]
25
- }
package/tsup.config.ts DELETED
@@ -1,40 +0,0 @@
1
- import { defineConfig } from "tsup";
2
- import * as preset from "tsup-preset-solid";
3
-
4
- const preset_options: preset.PresetOptions = {
5
- // array or single object
6
- entries: [
7
- // default entry (index)
8
- {
9
- // entries with '.tsx' extension will have `solid` export condition generated
10
- entry: "./src/index.tsx",
11
- // will generate a separate development entry
12
- dev_entry: true,
13
- },
14
- ],
15
- // Set to `true` to remove all `console.*` calls and `debugger` statements in prod builds
16
- drop_console: true,
17
- // Set to `true` to generate a CommonJS build alongside ESM
18
- // cjs: true,
19
- };
20
-
21
- const CI =
22
- process.env['CI'] === 'true' ||
23
- process.env['GITHUB_ACTIONS'] === 'true' ||
24
- process.env['CI'] === '"1"' ||
25
- process.env['GITHUB_ACTIONS'] === '"1"'
26
-
27
- export default defineConfig(config => {
28
- const watching = !!config.watch;
29
-
30
- const parsed_options = preset.parsePresetOptions(preset_options, watching);
31
-
32
- if (!watching && !CI) {
33
- const package_fields = preset.generatePackageExports(parsed_options)
34
-
35
- // will update ./package.json with the correct export fields
36
- preset.writePackageJson(package_fields)
37
- }
38
-
39
- return preset.generateTsupOptions(parsed_options);
40
- });