@mdaemon/html-editor 1.6.0 → 1.7.0

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/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Dynamic JSON Badge](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fmdaemon-technologies%2FMDHTMLEditor%2Fmaster%2Fpackage.json&query=%24.version&prefix=v&label=npm&color=blue)](https://www.npmjs.com/package/@mdaemon/html-editor) [![install size](https://packagephobia.com/badge?p=@mdaemon/html-editor)](https://packagephobia.com/result?p=@mdaemon/html-editor) [![Dynamic JSON Badge](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fmdaemon-technologies%2FMDHTMLEditor%2Fmaster%2Fpackage.json&query=%24.license&prefix=v&label=license&color=green)](https://github.com/mdaemon-technologies/MDHTMLEditor/blob/master/LICENSE) [![Node.js CI](https://github.com/mdaemon-technologies/MDHTMLEditor/actions/workflows/ci.yml/badge.svg)](https://github.com/mdaemon-technologies/MDHTMLEditor/actions/workflows/ci.yml)
2
+
1
3
  # MDHTMLEditor
2
4
 
3
5
  A TinyMCE-compatible HTML editor built on TipTap. This is the core vanilla TypeScript package - for React usage, see `@mdaemon/html-editor-react`.
@@ -54,6 +56,26 @@ editor.on('dirty', (isDirty) => {
54
56
  editor.destroy();
55
57
  ```
56
58
 
59
+ ### Browser (CDN / script tag)
60
+
61
+ For static pages without a bundler, load the self-contained UMD bundle via a `<script>` tag.
62
+ It exposes the entire public API under the `MDHTMLEditor` global. Styles must be loaded
63
+ separately — the UMD bundle contains JavaScript only.
64
+
65
+ ```html
66
+ <link rel="stylesheet" href="https://unpkg.com/@mdaemon/html-editor/dist/styles.css">
67
+ <script src="https://unpkg.com/@mdaemon/html-editor"></script>
68
+ <script>
69
+ const editor = new MDHTMLEditor.HTMLEditor(
70
+ document.getElementById('editor'),
71
+ { height: 400 }
72
+ );
73
+ </script>
74
+ ```
75
+
76
+ `unpkg` and `jsdelivr` both serve the package; pin a version for production
77
+ (e.g. `https://unpkg.com/@mdaemon/html-editor@1.7.0`).
78
+
57
79
  ### Custom Toolbar Buttons
58
80
 
59
81
  ```typescript
@@ -719,6 +741,36 @@ The editor DOM uses BEM-style classes you can target for further customization:
719
741
  - Safari (latest)
720
742
  - Edge (latest)
721
743
 
744
+ ## Development
745
+
746
+ Clone the repo and install dependencies with `npm install`, then use:
747
+
748
+ ```bash
749
+ npm run build # production build → dist/ (ES, CJS, UMD, .d.ts, styles.css)
750
+ npm run build:dev # development build (unminified, sourcemaps)
751
+ npm run dev # rebuild on change (watch mode)
752
+ npm test # run the Jest suite
753
+ npm run test:dist # build, then smoke-test the built UMD bundle
754
+ npm run typecheck # tsc --noEmit (strict)
755
+ npm run lint # eslint src
756
+ ```
757
+
758
+ ### Demos
759
+
760
+ ```bash
761
+ npm run demo # live demo from TypeScript source (Vite dev server, HTTPS)
762
+ npm run demo:umd # build, then serve the UMD/script-tag demo as static files
763
+ ```
764
+
765
+ - **`npm run demo`** serves `test/index.html` through Vite's dev server, importing the editor
766
+ directly from `src/`. Use this for day-to-day feature work — it hot-reloads and exercises the
767
+ full toolbar. It runs over HTTPS (self-signed cert) so microphone-dependent features
768
+ (Speech-to-Text, Dictation) work.
769
+ - **`npm run demo:umd`** runs a production build and then serves `test/umd.html` as raw static
770
+ files (via `test/serve-umd.mjs`), loading the built `dist/index.umd.js` and `dist/styles.css`
771
+ exactly the way a CDN / `<script>`-tag consumer would. Use this to verify the UMD bundle and
772
+ the `MDHTMLEditor` global.
773
+
722
774
  ## License
723
775
 
724
776
  LGPL 3.0 or later - MDaemon Technologies
package/dist/index.d.ts CHANGED
@@ -864,15 +864,21 @@ declare module '@tiptap/core' {
864
864
 
865
865
  declare module '@tiptap/core' {
866
866
  interface Commands<ReturnType> {
867
- lineHeight: {
868
- /**
869
- * Set the line height
870
- */
871
- setLineHeight: (lineHeight: string) => ReturnType;
872
- /**
873
- * Unset the line height
874
- */
875
- unsetLineHeight: () => ReturnType;
867
+ inlineStyle: {
868
+ /** Apply a CSS class to the current selection via the textStyle mark. */
869
+ setInlineClass: (className: string) => ReturnType;
870
+ /** Remove the textStyle class. */
871
+ unsetInlineClass: () => ReturnType;
872
+ };
873
+ }
874
+ }
875
+
876
+
877
+ declare module '@tiptap/core' {
878
+ interface Commands<ReturnType> {
879
+ anchor: {
880
+ /** Insert a named anchor at the cursor. */
881
+ setAnchor: (name: string) => ReturnType;
876
882
  };
877
883
  }
878
884
  }
@@ -896,21 +902,15 @@ declare module '@tiptap/core' {
896
902
 
897
903
  declare module '@tiptap/core' {
898
904
  interface Commands<ReturnType> {
899
- anchor: {
900
- /** Insert a named anchor at the cursor. */
901
- setAnchor: (name: string) => ReturnType;
902
- };
903
- }
904
- }
905
-
906
-
907
- declare module '@tiptap/core' {
908
- interface Commands<ReturnType> {
909
- inlineStyle: {
910
- /** Apply a CSS class to the current selection via the textStyle mark. */
911
- setInlineClass: (className: string) => ReturnType;
912
- /** Remove the textStyle class. */
913
- unsetInlineClass: () => ReturnType;
905
+ lineHeight: {
906
+ /**
907
+ * Set the line height
908
+ */
909
+ setLineHeight: (lineHeight: string) => ReturnType;
910
+ /**
911
+ * Unset the line height
912
+ */
913
+ unsetLineHeight: () => ReturnType;
914
914
  };
915
915
  }
916
916
  }