@witchcraft/editor 0.0.2 → 0.0.3

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/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "witchcraftEditor",
3
3
  "configKey": "witchcraftEditor",
4
- "version": "0.0.2",
4
+ "version": "0.0.3",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
package/dist/module.mjs CHANGED
@@ -4,7 +4,7 @@ import { defu } from 'defu';
4
4
  import fs from 'node:fs/promises';
5
5
 
6
6
  const dependencies = {
7
- "@witchcraft/ui": "^0.2.4"};
7
+ "@witchcraft/ui": "^0.3.0"};
8
8
  const pkg = {
9
9
  dependencies: dependencies};
10
10
 
@@ -9,6 +9,10 @@ export const useEditor = (options = {}) => {
9
9
  }
10
10
  onBeforeUnmount(() => {
11
11
  const nodes = editor.value?.options.element;
12
+ if (nodes && !(nodes instanceof HTMLElement)) {
13
+ console.warn(`Expected editor element to be an HTMLElement, got ${nodes.constructor.name}: ${nodes}`);
14
+ return;
15
+ }
12
16
  const newEl = nodes?.cloneNode(true);
13
17
  nodes?.parentNode?.replaceChild(newEl, nodes);
14
18
  editor.value?.destroy();
@@ -5,7 +5,7 @@ export const useWindowDebugging = (editor) => {
5
5
  watch(editor, () => {
6
6
  if (!editor.value) return;
7
7
  if (typeof window === "undefined" || typeof process === "undefined") return;
8
- if (process.env.NODE_ENV === "development" && editor.value !== void 0) {
8
+ if (import.meta.dev && editor.value !== void 0) {
9
9
  const w = window;
10
10
  w.editor = editor.value;
11
11
  w.tr = () => editor.value.state.tr;
@@ -2,7 +2,7 @@ import type { Editor } from "@tiptap/core";
2
2
  import { Plugin, PluginKey } from "@tiptap/pm/state";
3
3
  export declare const debugSelectionPluginKey: PluginKey<any>;
4
4
  /**
5
- * Sets the window title to the current selection for debugging in development mode (by checking process.env.NODE_ENV).
5
+ * Sets the window title to the current selection for debugging in development mode (by checking import.meta.dev).
6
6
  *
7
7
  * For embedded editors, adds the selection as `[from - to]`.
8
8
  */
@@ -11,7 +11,7 @@ export const debugSelectionPlugin = (editor, log = false) => {
11
11
  init() {
12
12
  },
13
13
  apply(tr) {
14
- if (process.env.NODE_ENV === "production") {
14
+ if (!import.meta.dev) {
15
15
  return;
16
16
  }
17
17
  const sel = `${tr.selection.from} - ${tr.selection.to}`;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@witchcraft/editor",
3
3
  "description": "Block base prosemirror editor with partial/full editable document embeds, infinite embeds, and document uploads.",
4
- "version": "0.0.2",
4
+ "version": "0.0.3",
5
5
  "main": "./dist/runtime/main.lib.js",
6
6
  "type": "module",
7
7
  "sideEffects": false,
@@ -123,7 +123,7 @@
123
123
  "@tiptap/extension-underline": "^3.4.2",
124
124
  "@tiptap/pm": "^3.4.2",
125
125
  "@tiptap/vue-3": "^3.4.2",
126
- "@witchcraft/ui": "^0.2.3",
126
+ "@witchcraft/ui": "^0.3.0",
127
127
  "tailwindcss": "^4.0.0",
128
128
  "vue": "^3.2.47"
129
129
  },
@@ -148,7 +148,7 @@
148
148
  "@fortawesome/free-solid-svg-icons": "^7.0.1",
149
149
  "@nuxt/eslint-config": "^1.9.0",
150
150
  "@witchcraft/nuxt-utils": "^0.3.2",
151
- "@witchcraft/ui": "^0.2.4",
151
+ "@witchcraft/ui": "^0.3.0",
152
152
  "colord": "^2.9.3",
153
153
  "defu": "^6.1.4",
154
154
  "highlight.js": "^11.11.1",
@@ -158,7 +158,7 @@
158
158
  "nanoid": "^5.1.5",
159
159
  "reka-ui": "^2.5.0",
160
160
  "tailwind-merge": "^3.3.1",
161
- "unplugin-vue-components": "^29.0.0",
161
+ "unplugin-vue-components": "^29.1.0",
162
162
  "uuid": "^13.0.0",
163
163
  "y-prosemirror": "^1.3.7",
164
164
  "yjs": "^13.6.27"
@@ -182,7 +182,7 @@
182
182
  "@vitejs/plugin-vue": "^6.0.1",
183
183
  "@vitest/browser": "^3.2.4",
184
184
  "@vitest/coverage-v8": "^3.2.4",
185
- "@witchcraft/ui": "^0.2.3",
185
+ "@witchcraft/ui": "^0.3.0",
186
186
  "concurrently": "^9.2.1",
187
187
  "cross-env": "^10.0.0",
188
188
  "eslint": "^9.35.0",
@@ -18,6 +18,11 @@ export const useEditor = (options: Partial<EditorOptions> = {}) => {
18
18
  onBeforeUnmount(() => {
19
19
  // Cloning root node (and its children) to avoid content being lost by destroy
20
20
  const nodes = editor.value?.options.element
21
+ if (nodes && !(nodes instanceof HTMLElement)) {
22
+ // eslint-disable-next-line no-console
23
+ console.warn(`Expected editor element to be an HTMLElement, got ${nodes.constructor.name}: ${nodes}`)
24
+ return
25
+ }
21
26
  const newEl = nodes?.cloneNode(true) as HTMLElement
22
27
 
23
28
  nodes?.parentNode?.replaceChild(newEl, nodes)
@@ -9,7 +9,7 @@ export const useWindowDebugging = (editor: ShallowRef<Editor | undefined>): void
9
9
  watch(editor, () => {
10
10
  if (!editor.value) return
11
11
  if (typeof window === "undefined" || typeof process === "undefined") return
12
- if (process.env.NODE_ENV === "development" && editor.value !== undefined) {
12
+ if (import.meta.dev && editor.value !== undefined) {
13
13
  const w = window as any
14
14
  w.editor = editor.value
15
15
  w.tr = () => editor.value!.state.tr
@@ -9,7 +9,7 @@ const SUB_SELECTION_REGEX = /(\[[0-9 -]*\])/
9
9
 
10
10
  export const debugSelectionPluginKey = new PluginKey("debugSelection")
11
11
  /**
12
- * Sets the window title to the current selection for debugging in development mode (by checking process.env.NODE_ENV).
12
+ * Sets the window title to the current selection for debugging in development mode (by checking import.meta.dev).
13
13
  *
14
14
  * For embedded editors, adds the selection as `[from - to]`.
15
15
  */
@@ -20,7 +20,7 @@ export const debugSelectionPlugin = (editor: Editor, log: boolean = false): Plug
20
20
  state: {
21
21
  init(): void { /**/ },
22
22
  apply(tr: Transaction): void {
23
- if (process.env.NODE_ENV === "production") { return }
23
+ if (!import.meta.dev) { return }
24
24
  const sel = `${tr.selection.from} - ${tr.selection.to}`
25
25
  if (isEmbeddedBlock(editor.view)) {
26
26
  if (log) {