tinymce-solid 0.0.2 → 0.0.4

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.
package/package.json CHANGED
@@ -1,9 +1,16 @@
1
1
  {
2
2
  "name": "tinymce-solid",
3
- "version": "0.0.2",
4
- "description": "TinyMCE Component for SolidJS",
3
+ "version": "0.0.4",
4
+ "description": "📝 TinyMCE Component for SolidJS",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
+ "keywords": [
8
+ "solidjs",
9
+ "tinymce",
10
+ "editor",
11
+ "wysiwyg",
12
+ "typescript"
13
+ ],
7
14
  "homepage": "https://thednp.github.io/tinymce-solid",
8
15
  "bugs": {
9
16
  "url": "https://github.com/thednp/tinymce-solid/issues"
@@ -14,27 +21,27 @@
14
21
  },
15
22
  "dependencies": {
16
23
  "solid-js": "^1.8.17",
17
- "tinymce": "^7.1.1"
24
+ "tinymce": "^7.1.2"
18
25
  },
19
26
  "devDependencies": {
20
27
  "@kobalte/core": "^0.13.3",
21
28
  "@kobalte/utils": "^0.9.0",
22
- "@types/node": "^20.14.1",
29
+ "@types/node": "^20.14.2",
23
30
  "@types/prop-types": "^15.7.12",
24
31
  "autoprefixer": "^10.4.19",
25
32
  "class-variance-authority": "^0.7.0",
26
33
  "clsx": "^2.1.1",
27
34
  "postcss": "^8.4.38",
28
- "prettier": "^3.3.0",
35
+ "prettier": "^3.3.1",
29
36
  "prop-types": "^15.8.1",
30
37
  "tailwind-merge": "^2.3.0",
31
- "tailwindcss": "^3.4.3",
38
+ "tailwindcss": "^3.4.4",
32
39
  "tailwindcss-animate": "^1.0.7",
33
40
  "tsup": "^8.1.0",
34
41
  "tsup-preset-solid": "^2.2.0",
35
42
  "typescript": "^5.4.5",
36
43
  "typescript-eslint": "^7.12.0",
37
- "vite": "^5.2.12",
44
+ "vite": "^5.2.13",
38
45
  "vite-plugin-compression2": "^1.1.1",
39
46
  "vite-plugin-solid": "^2.10.2"
40
47
  },
@@ -70,6 +77,7 @@
70
77
  "build:docs": "vite build demo --config demo/vite.config.docs.ts",
71
78
  "copy:tiny": "cp -a './node_modules/.pnpm/tinymce@7.1.1/node_modules/tinymce' './demo/public'",
72
79
  "serve:docs": "vite serve docs --port 3000",
80
+ "badges": "npx -p dependency-version-badge update-badge solid-js tinymce typescript prettier vite",
73
81
  "lint": "pnpm lint:types && pnpm lint:code",
74
82
  "lint:code": "eslint 'src/**/*.{ts,tsx}' --max-warnings 0",
75
83
  "lint:types": "tsc --noEmit src/**/* --jsx preserve",
package/src/TinyMCE.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { TinyMCE as TinyMCEGlobal } from "tinymce";
1
+ import { type TinyMCE as TinyMCEGlobal } from "tinymce";
2
2
 
3
3
  const getTinymce = (view: Window): TinyMCEGlobal | null => {
4
4
  const global = view as unknown as { tinymce: TinyMCEGlobal | null };
@@ -27,6 +27,7 @@ export const SolidEditor = (props: Partial<IAllProps>) => {
27
27
  const value = () => props.value || "";
28
28
  const skin = () => props.skin || "oxide";
29
29
  const contentCss = () => props.contentCss || "default";
30
+ const disabled = () => props.disabled || false;
30
31
  const [editor, setEditor] = createSignal<TinyMCEEditor>();
31
32
  const [currentContent, setCurrentContent] = createSignal<string>(value());
32
33
  const [rollbackTimer, setRollbackTimer] = createSignal<number>();
@@ -103,6 +104,14 @@ export const SolidEditor = (props: Partial<IAllProps>) => {
103
104
  }
104
105
  }
105
106
  };
107
+ const successHandler = () => {
108
+ props.onScriptsLoad?.();
109
+ initialise();
110
+ };
111
+ const errorHandler = (err: unknown) => {
112
+ // console.warn(err);
113
+ props.onScriptsLoadError?.(err);
114
+ };
106
115
 
107
116
  const initialise = (attempts = 0) => {
108
117
  const target = props.elementRef;
@@ -178,8 +187,8 @@ export const SolidEditor = (props: Partial<IAllProps>) => {
178
187
  editor.setDirty(false);
179
188
  }
180
189
  setCurrentContent(newCurrentValue);
181
- const disabled = props.disabled ?? false;
182
- setMode(editor, disabled ? "readonly" : "design");
190
+ const isDisabled = disabled() ?? false;
191
+ setMode(editor, isDisabled ? "readonly" : "design");
183
192
  // ensure existing init_instance_callback is called
184
193
  if (props.init && isFunction(props.init.init_instance_callback)) {
185
194
  props.init.init_instance_callback(editor);
@@ -202,24 +211,12 @@ export const SolidEditor = (props: Partial<IAllProps>) => {
202
211
  Array.isArray(props.tinymceScriptSrc) &&
203
212
  props.tinymceScriptSrc.length === 0
204
213
  ) {
205
- // props.onScriptsLoadError?.(
206
- // new Error("No `tinymce` global is present but the `tinymceScriptSrc` prop was an empty array."),
207
- // );
208
- throw new Error(
209
- "No `tinymce` global is present but the `tinymceScriptSrc` prop was an empty array.",
214
+ props.onScriptsLoadError?.(
215
+ new Error(
216
+ "No `tinymce` global is present but the `tinymceScriptSrc` prop was an empty array.",
217
+ ),
210
218
  );
211
219
  } else if (props?.elementRef?.ownerDocument) {
212
- const successHandler = () => {
213
- // console.log("loaded");
214
- // props.onScriptsLoad?.();
215
- initialise();
216
- };
217
- const errorHandler = (err: unknown) => {
218
- // console.warn(err);
219
- // props.onScriptsLoadError?.(err);
220
- throw new Error(err as string);
221
- };
222
-
223
220
  ScriptLoader.loadList(
224
221
  props.elementRef.ownerDocument,
225
222
  getScriptSources(),
@@ -259,9 +256,17 @@ export const SolidEditor = (props: Partial<IAllProps>) => {
259
256
  createEffect(
260
257
  on(skin, () => {
261
258
  cleanUpCallback();
262
- setTimeout(() => {
263
- mountCallback();
264
- }, 34);
259
+ setTimeout(mountCallback, 1);
260
+ }),
261
+ );
262
+
263
+ createEffect(
264
+ on(disabled, () => {
265
+ const tinyEditor = editor();
266
+ if (tinyEditor?.initialized) {
267
+ const isDisabled = disabled() ?? false;
268
+ setMode(tinyEditor, isDisabled ? "readonly" : "design");
269
+ }
265
270
  }),
266
271
  );
267
272
 
@@ -373,7 +378,7 @@ export const SolidEditor = (props: Partial<IAllProps>) => {
373
378
 
374
379
  return props.inline ? (
375
380
  <div
376
- style={{ display: editor() ? "" : "none" }}
381
+ style={{ visibility: "hidden" }}
377
382
  ref={props.elementRef as HTMLDivElement}
378
383
  id={id()}
379
384
  data-testid={props.testid}
@@ -381,7 +386,7 @@ export const SolidEditor = (props: Partial<IAllProps>) => {
381
386
  />
382
387
  ) : (
383
388
  <textarea
384
- style={{ display: editor() ? "" : "none" }}
389
+ style={{ visibility: "hidden" }}
385
390
  ref={props.elementRef as HTMLTextAreaElement}
386
391
  id={id()}
387
392
  data-testid={props.testid}
@@ -1,9 +1,16 @@
1
+ const plugin = require("tailwindcss/plugin");
2
+ // const defaultTheme = require("tailwindcss/defaultTheme");
3
+
1
4
  /** @type {import('tailwindcss').Config} */
2
5
  module.exports = {
3
6
  darkMode: ["class", '[data-kb-theme="dark"]'],
4
7
  content: ["src/**/*.{ts,tsx}", "demo/**/*.{ts,tsx}"],
5
8
  prefix: "",
6
9
  theme: {
10
+ fontFamily: {
11
+ sans: ["Hubot Sans", "-apple-system", "BlinkMacSystemFont", "Segoe UI", "Roboto", "Oxygen",
12
+ "Ubuntu", "Cantarell", "Open Sans", "Helvetica Neue", "sans-serif"],
13
+ },
7
14
  container: {
8
15
  center: true,
9
16
  padding: "2rem",
@@ -77,8 +84,54 @@ module.exports = {
77
84
  "collapsible-up": "collapsible-up 0.2s ease-out",
78
85
  },
79
86
  },
87
+ fontVariationSettings: {
88
+ stretch: [75, 90, 125],
89
+ weight: [200, 300, 400, 500, 600, 700, 800, 900],
90
+ italic: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
91
+ },
80
92
  },
81
93
  plugins: [
82
94
  require("tailwindcss-animate"),
95
+ plugin(function fontVariations({ addComponents, matchUtilities, theme }) {
96
+ const fontVariationProps = Object.entries(theme("fontVariationSettings"))
97
+ .map(([key, values]) => {
98
+ /**
99
+ * Generate the value for a CSS property based on the given key and value.
100
+ *
101
+ * @param {string} key - The key of the CSS property.
102
+ * @param {string|number} value - The value of the CSS property.
103
+ * @return {string} - The generated value for the CSS property.
104
+ */
105
+ const cssPropValue = (key, value) =>
106
+ key === "stretch"
107
+ ? `${value}%` // .font-stretch
108
+ : key === "italic"
109
+ ? `oblique ${value}deg` // .font-oblique
110
+ : value; // font-weight
111
+ return values.map(value => [
112
+ `.font-${key}-${value}`,
113
+ { [`font-${key.replace(/italic/g, "style")}`]: cssPropValue(key, value) },
114
+ ]);
115
+ })
116
+ .flat();
117
+
118
+ // console.log(Object.fromEntries(fontVariationProps));
119
+ addComponents(Object.fromEntries(fontVariationProps));
120
+
121
+ matchUtilities(
122
+ {
123
+ "font-weight": value => ({
124
+ "font-weight": value,
125
+ }),
126
+ "font-stretch": value => ({
127
+ "font-stretch": `${value}%`,
128
+ }),
129
+ "font-italic": value => ({
130
+ "font-style": `oblique ${value}deg`,
131
+ }),
132
+ },
133
+ { values: Object.fromEntries(fontVariationProps) },
134
+ );
135
+ }),
83
136
  ],
84
137
  };
package/tsconfig.json CHANGED
@@ -17,6 +17,7 @@
17
17
  "baseUrl": ".",
18
18
  "paths": {
19
19
  "~/*": ["./src/*"],
20
+ "@/*": ["./demo/*"],
20
21
  }
21
22
  },
22
23
  "include": ["src"],
package/tsup.config.ts CHANGED
@@ -29,10 +29,8 @@ export default defineConfig(config => {
29
29
 
30
30
  const parsed_options = preset.parsePresetOptions(preset_options, watching);
31
31
 
32
- // DON'T OVERRIDE MY PACKAGE.JSON PLEASE!
33
32
  if (!watching && !CI) {
34
33
  const package_fields = preset.generatePackageExports(parsed_options)
35
- // console.log(`package.json: \n\n${JSON.stringify(package_fields, null, 2)}\n\n`)
36
34
 
37
35
  // will update ./package.json with the correct export fields
38
36
  preset.writePackageJson(package_fields)
@@ -1,31 +0,0 @@
1
- name: "🐛 Bug report"
2
- description: Create a report to help us improve
3
- body:
4
- - type: markdown
5
- attributes:
6
- value: |
7
- Thank you for reporting an issue :pray:.
8
-
9
- The more information you fill in, the better the community can help you.
10
- - type: textarea
11
- id: description
12
- attributes:
13
- label: Describe the bug
14
- description: Provide a clear and concise description of the challenge you are running into.
15
- validations:
16
- required: true
17
- - type: input
18
- id: link
19
- attributes:
20
- label: Minimal Reproduction Link
21
- description: |
22
- Please provide a link to a minimal reproduction of the bug you are running into.
23
- It makes the process of verifying and fixing the bug much easier.
24
- Note:
25
- - Your bug will may get fixed much faster if we can run your code and it doesn't have dependencies other than the solid-js and solid-primitives.
26
- - To create a shareable code example you can use [Stackblitz](https://stackblitz.com/) (https://solid.new). Please no localhost URLs.
27
- - Please read these tips for providing a minimal example: https://stackoverflow.com/help/mcve.
28
- placeholder: |
29
- e.g. https://stackblitz.com/edit/...... OR Github Repo
30
- validations:
31
- required: true
@@ -1,27 +0,0 @@
1
- name: "Feature Request"
2
- description: For feature/enhancement requests. Please search for existing issues first.
3
- body:
4
- - type: markdown
5
- attributes:
6
- value: |
7
- Thank you for bringing your ideas here :pray:.
8
-
9
- The more information you fill in, the better the community can understand your idea.
10
- - type: textarea
11
- id: problem
12
- attributes:
13
- label: Describe The Problem To Be Solved
14
- description: Provide a clear and concise description of the challenge you are running into.
15
- validations:
16
- required: true
17
- - type: textarea
18
- id: solution
19
- attributes:
20
- label: Suggest A Solution
21
- description: |
22
- A concise description of your preferred solution. Things to address include:
23
- - Details of the technical implementation
24
- - Tradeoffs made in design decisions
25
- - Caveats and considerations for the future
26
- validations:
27
- required: true
@@ -1,2 +0,0 @@
1
- paths:
2
- - src
@@ -1,30 +0,0 @@
1
- name: Badges
2
- on:
3
- push:
4
- # [push, pull_request]
5
- # update README badge only if the README file changes
6
- # or if the package.json file changes, or this file changes
7
- branches:
8
- - main
9
- paths:
10
- - README.md
11
- - package.json
12
- - .github/workflows/badges.yml
13
-
14
- jobs:
15
- badges:
16
- name: Badges
17
- runs-on: ubuntu-20.04
18
- steps:
19
- - name: Checkout 🛎
20
- uses: actions/checkout@v3
21
-
22
- - name: Update version badges 🏷
23
- run: npx -p dependency-version-badge update-badge solid-js tinymce typescript prettier vite
24
-
25
- - name: Commit any changed files 💾
26
- uses: stefanzweifel/git-auto-commit-action@v4
27
- with:
28
- commit_message: Updated badges
29
- branch: main
30
- file_pattern: README.md
@@ -1,47 +0,0 @@
1
- name: CI & Test
2
-
3
- on: [push]
4
-
5
- jobs:
6
- build:
7
- runs-on: ${{ matrix.operating-system }}
8
-
9
- strategy:
10
- matrix:
11
- node-version: [18.x]
12
- operating-system: [ubuntu-latest]
13
-
14
- steps:
15
- - name: Checkout repo
16
- uses: actions/checkout@v2
17
- with:
18
- fetch-depth: 2
19
-
20
- - uses: pnpm/action-setup@v2.2.2
21
-
22
- - name: Setup Node.js environment ${{ matrix.node-version }}
23
- uses: actions/setup-node@v3
24
- with:
25
- node-version: ${{ matrix.node-version }}
26
- cache: pnpm
27
-
28
- - name: Install dependencies
29
- run: pnpm install --no-frozen-lockfile
30
-
31
- - name: Typecheck & ESLint
32
- run: pnpm lint
33
-
34
- - name: Build
35
- run: pnpm build
36
-
37
- - name: Build Docs
38
- run: pnpm build:docs
39
- # env:
40
- # BASE_PATH: '/tinymce-solid'
41
-
42
- - name: Deploy pages
43
- uses: JamesIves/github-pages-deploy-action@v4.4.1
44
- with:
45
- branch: gh-pages
46
- node-version: 18.x
47
- folder: docs
@@ -1,75 +0,0 @@
1
- # For most projects, this workflow file will not need changing; you simply need
2
- # to commit it to your repository.
3
- #
4
- # You may wish to alter this file to override the set of languages analyzed,
5
- # or to provide custom queries or build logic.
6
- #
7
- # ******** NOTE ********
8
- # We have attempted to detect the languages in your repository. Please check
9
- # the `language` matrix defined below to confirm you have the correct set of
10
- # supported CodeQL languages.
11
- #
12
- name: "CodeQL"
13
-
14
- on:
15
- push:
16
- branches: [ master ]
17
- pull_request:
18
- # The branches below must be a subset of the branches above
19
- branches: [ master ]
20
-
21
- jobs:
22
- analyze:
23
- name: Analyze
24
- runs-on: ubuntu-latest
25
- permissions:
26
- actions: read
27
- contents: read
28
- security-events: write
29
-
30
- strategy:
31
- fail-fast: false
32
- matrix:
33
- language: [ 'typescript' ]
34
- # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
35
- # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
36
-
37
- steps:
38
- - name: Checkout repository
39
- uses: actions/checkout@v3
40
-
41
- - name: Install dependencies
42
- run: npm install
43
-
44
- - name: Build
45
- run: npm run build
46
-
47
- # Initializes the CodeQL tools for scanning.
48
- - name: Initialize CodeQL
49
- uses: github/codeql-action/init@v2
50
- with:
51
- languages: ${{ matrix.language }}
52
- # If you wish to specify custom queries, you can do so here or in a config file.
53
- # By default, queries listed here will override any specified in a config file.
54
- # Prefix the list here with "+" to use these queries and those in the config file.
55
- # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
56
- # queries: security-extended,security-and-quality
57
- config-file: ./.github/codeql/codeql-config.yml
58
-
59
- # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
60
- # If this step fails, then you should remove it and run the build manually (see below)
61
- - name: Autobuild
62
- uses: github/codeql-action/autobuild@v2
63
-
64
- # ℹ️ Command-line programs to run using the OS shell.
65
- # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
66
-
67
- # If the Autobuild fails above, remove it and uncomment the following three lines.
68
- # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
69
-
70
- # - run: |
71
- # echo "Run, Build Application using script"
72
- # ./location_of_script_within_repo/buildscript.sh
73
-
74
- - name: Perform CodeQL Analysis
75
- uses: github/codeql-action/analyze@v2