solid-tiptap 0.5.0 → 0.6.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 +1 -1
- package/dist/cjs/development/index.cjs +3 -7
- package/dist/cjs/development/index.cjs.map +2 -2
- package/dist/cjs/production/index.cjs +1 -1
- package/dist/esm/development/index.mjs +3 -7
- package/dist/esm/development/index.mjs.map +2 -2
- package/dist/esm/production/index.mjs +1 -1
- package/dist/types/Editor.d.ts +0 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +10 -10
- package/src/Editor.tsx +3 -9
- package/src/index.ts +0 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/solid-tiptap) [](https://github.com/airbnb/javascript) [](https://codesandbox.io/s/github/LXSMNSYC/solid-tiptap/tree/main/examples/simple-example)
|
|
6
6
|
|
|
7
|
-

|
|
8
8
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
@@ -24,7 +24,6 @@ __export(src_exports, {
|
|
|
24
24
|
createEditorTransaction: () => createEditorTransaction,
|
|
25
25
|
createTiptapEditor: () => useEditor,
|
|
26
26
|
useEditor: () => useEditor,
|
|
27
|
-
useEditorCharacterCount: () => useEditorCharacterCount,
|
|
28
27
|
useEditorHTML: () => useEditorHTML,
|
|
29
28
|
useEditorIsActive: () => useEditorIsActive,
|
|
30
29
|
useEditorIsEditable: () => useEditorIsEditable,
|
|
@@ -39,9 +38,9 @@ module.exports = __toCommonJS(src_exports);
|
|
|
39
38
|
var import_solid_js = require("solid-js");
|
|
40
39
|
var import_core = require("@tiptap/core");
|
|
41
40
|
function createEditorTransaction(instance, read) {
|
|
42
|
-
const [
|
|
41
|
+
const [depend, update] = (0, import_solid_js.createSignal)(void 0, { equals: false });
|
|
43
42
|
function forceUpdate() {
|
|
44
|
-
|
|
43
|
+
update();
|
|
45
44
|
}
|
|
46
45
|
(0, import_solid_js.createEffect)(() => {
|
|
47
46
|
const editor = instance();
|
|
@@ -53,7 +52,7 @@ function createEditorTransaction(instance, read) {
|
|
|
53
52
|
}
|
|
54
53
|
});
|
|
55
54
|
return () => {
|
|
56
|
-
|
|
55
|
+
depend();
|
|
57
56
|
return read(instance());
|
|
58
57
|
};
|
|
59
58
|
}
|
|
@@ -76,9 +75,6 @@ function useEditorHTML(editor) {
|
|
|
76
75
|
function useEditorJSON(editor) {
|
|
77
76
|
return createEditorTransaction(editor, (instance) => instance == null ? void 0 : instance.getJSON());
|
|
78
77
|
}
|
|
79
|
-
function useEditorCharacterCount(editor) {
|
|
80
|
-
return createEditorTransaction(editor, (instance) => instance == null ? void 0 : instance.getCharacterCount());
|
|
81
|
-
}
|
|
82
78
|
function useEditorIsActive(editor, ...args) {
|
|
83
79
|
return createEditorTransaction(editor, (instance) => {
|
|
84
80
|
if (args.length === 2) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/index.ts", "../../../src/Editor.tsx"],
|
|
4
|
-
"sourcesContent": ["export {\n default as useEditor,\n default as createEditor,\n default as useTiptapEditor,\n default as createTiptapEditor,\n UseEditorOptions,\n EditorRef,\n createEditorTransaction,\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA
|
|
4
|
+
"sourcesContent": ["export {\n default as useEditor,\n default as createEditor,\n default as useTiptapEditor,\n default as createTiptapEditor,\n UseEditorOptions,\n EditorRef,\n createEditorTransaction,\n useEditorHTML,\n useEditorIsActive,\n useEditorIsEditable,\n useEditorIsEmpty,\n useEditorIsFocused,\n useEditorJSON,\n} from './Editor';\n", "import {\n createEffect,\n createSignal,\n onCleanup,\n} from 'solid-js';\nimport {\n Editor,\n EditorOptions,\n} from '@tiptap/core';\n\nexport type EditorRef = Editor | ((editor: Editor) => void);\n\nexport type BaseEditorOptions = Omit<Partial<EditorOptions>, 'element'>;\n\nexport interface UseEditorOptions<T extends HTMLElement> extends BaseEditorOptions {\n element: T;\n}\n\nexport function createEditorTransaction<T, V extends Editor | undefined>(\n instance: () => V,\n read: (value: V) => T,\n): () => T {\n const [depend, update] = createSignal(undefined, { equals: false });\n\n function forceUpdate() {\n update()\n }\n\n createEffect(() => {\n const editor = instance();\n if (editor) {\n editor.on('transaction', forceUpdate);\n onCleanup(() => {\n editor.off('transaction', forceUpdate);\n });\n }\n });\n\n return () => {\n depend();\n return read(instance());\n };\n}\n\nexport default function useEditor<T extends HTMLElement>(\n props: () => UseEditorOptions<T>,\n): () => Editor | undefined {\n const [signal, setSignal] = createSignal<Editor>();\n\n createEffect(() => {\n const instance = new Editor({\n ...props(),\n });\n\n onCleanup(() => {\n instance.destroy();\n });\n\n setSignal(instance);\n });\n\n return signal;\n}\n\nexport function useEditorHTML<V extends Editor | undefined>(\n editor: () => V,\n): () => string | undefined {\n return createEditorTransaction(editor, (instance) => instance?.getHTML());\n}\n\nexport function useEditorJSON<V extends Editor | undefined, R extends Record<string, any>>(\n editor: () => V,\n): () => R | undefined {\n return createEditorTransaction(editor, (instance) => instance?.getJSON() as R);\n}\n\nexport function useEditorIsActive<V extends Editor | undefined, R extends Record<string, any>>(\n editor: () => V,\n ...args: [name: () => string, options?: R] | [options: R]\n): () => boolean | undefined {\n return createEditorTransaction(editor, (instance) => {\n if (args.length === 2) {\n return instance?.isActive(\n args[0](),\n args[1],\n );\n }\n return instance?.isActive(\n args[0],\n );\n });\n}\n\nexport function useEditorIsEmpty<V extends Editor | undefined>(\n editor: () => V,\n): () => boolean | undefined {\n return createEditorTransaction(editor, (instance) => instance?.isEmpty);\n}\n\nexport function useEditorIsEditable<V extends Editor | undefined>(\n editor: () => V,\n): () => boolean | undefined {\n return createEditorTransaction(editor, (instance) => instance?.isEditable);\n}\n\nexport function useEditorIsFocused<V extends Editor | undefined>(\n editor: () => V,\n): () => boolean | undefined {\n return createEditorTransaction(editor, (instance) => instance?.isFocused);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,sBAIO;AACP,kBAGO;AAUA,SAAS,wBACd,UACA,MACS;AACT,QAAM,CAAC,QAAQ,MAAM,QAAI,8BAAa,QAAW,EAAE,QAAQ,MAAM,CAAC;AAElE,WAAS,cAAc;AACrB,WAAO;AAAA,EACT;AAEA,oCAAa,MAAM;AACjB,UAAM,SAAS,SAAS;AACxB,QAAI,QAAQ;AACV,aAAO,GAAG,eAAe,WAAW;AACpC,qCAAU,MAAM;AACd,eAAO,IAAI,eAAe,WAAW;AAAA,MACvC,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AAED,SAAO,MAAM;AACX,WAAO;AACP,WAAO,KAAK,SAAS,CAAC;AAAA,EACxB;AACF;AAEe,SAAR,UACL,OAC0B;AAC1B,QAAM,CAAC,QAAQ,SAAS,QAAI,8BAAqB;AAEjD,oCAAa,MAAM;AACjB,UAAM,WAAW,IAAI,mBAAO;AAAA,MAC1B,GAAG,MAAM;AAAA,IACX,CAAC;AAED,mCAAU,MAAM;AACd,eAAS,QAAQ;AAAA,IACnB,CAAC;AAED,cAAU,QAAQ;AAAA,EACpB,CAAC;AAED,SAAO;AACT;AAEO,SAAS,cACd,QAC0B;AAC1B,SAAO,wBAAwB,QAAQ,CAAC,aAAa,qCAAU,SAAS;AAC1E;AAEO,SAAS,cACd,QACqB;AACrB,SAAO,wBAAwB,QAAQ,CAAC,aAAa,qCAAU,SAAc;AAC/E;AAEO,SAAS,kBACd,WACG,MACwB;AAC3B,SAAO,wBAAwB,QAAQ,CAAC,aAAa;AACnD,QAAI,KAAK,WAAW,GAAG;AACrB,aAAO,qCAAU;AAAA,QACf,KAAK,CAAC,EAAE;AAAA,QACR,KAAK,CAAC;AAAA;AAAA,IAEV;AACA,WAAO,qCAAU;AAAA,MACf,KAAK,CAAC;AAAA;AAAA,EAEV,CAAC;AACH;AAEO,SAAS,iBACd,QAC2B;AAC3B,SAAO,wBAAwB,QAAQ,CAAC,aAAa,qCAAU,OAAO;AACxE;AAEO,SAAS,oBACd,QAC2B;AAC3B,SAAO,wBAAwB,QAAQ,CAAC,aAAa,qCAAU,UAAU;AAC3E;AAEO,SAAS,mBACd,QAC2B;AAC3B,SAAO,wBAAwB,QAAQ,CAAC,aAAa,qCAAU,SAAS;AAC1E;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var s=Object.defineProperty;var
|
|
1
|
+
"use strict";var s=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var y=(t,e)=>{for(var o in e)s(t,o,{get:e[o],enumerable:!0})},I=(t,e,o,u)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of O(e))!R.call(t,r)&&r!==o&&s(t,r,{get:()=>e[r],enumerable:!(u=m(e,r))||u.enumerable});return t};var b=t=>I(s({},"__esModule",{value:!0}),t);var g={};y(g,{createEditor:()=>n,createEditorTransaction:()=>i,createTiptapEditor:()=>n,useEditor:()=>n,useEditorHTML:()=>p,useEditorIsActive:()=>x,useEditorIsEditable:()=>T,useEditorIsEmpty:()=>a,useEditorIsFocused:()=>V,useEditorJSON:()=>l,useTiptapEditor:()=>n});module.exports=b(g);var d=require("solid-js"),f=require("@tiptap/core");function i(t,e){let[o,u]=(0,d.createSignal)(void 0,{equals:!1});function r(){u()}return(0,d.createEffect)(()=>{let E=t();E&&(E.on("transaction",r),(0,d.onCleanup)(()=>{E.off("transaction",r)}))}),()=>(o(),e(t()))}function n(t){let[e,o]=(0,d.createSignal)();return(0,d.createEffect)(()=>{let u=new f.Editor({...t()});(0,d.onCleanup)(()=>{u.destroy()}),o(u)}),e}function p(t){return i(t,e=>e==null?void 0:e.getHTML())}function l(t){return i(t,e=>e==null?void 0:e.getJSON())}function x(t,...e){return i(t,o=>e.length===2?o==null?void 0:o.isActive(e[0](),e[1]):o==null?void 0:o.isActive(e[0]))}function a(t){return i(t,e=>e==null?void 0:e.isEmpty)}function T(t){return i(t,e=>e==null?void 0:e.isEditable)}function V(t){return i(t,e=>e==null?void 0:e.isFocused)}
|
|
@@ -8,9 +8,9 @@ import {
|
|
|
8
8
|
Editor
|
|
9
9
|
} from "@tiptap/core";
|
|
10
10
|
function createEditorTransaction(instance, read) {
|
|
11
|
-
const [
|
|
11
|
+
const [depend, update] = createSignal(void 0, { equals: false });
|
|
12
12
|
function forceUpdate() {
|
|
13
|
-
|
|
13
|
+
update();
|
|
14
14
|
}
|
|
15
15
|
createEffect(() => {
|
|
16
16
|
const editor = instance();
|
|
@@ -22,7 +22,7 @@ function createEditorTransaction(instance, read) {
|
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
return () => {
|
|
25
|
-
|
|
25
|
+
depend();
|
|
26
26
|
return read(instance());
|
|
27
27
|
};
|
|
28
28
|
}
|
|
@@ -45,9 +45,6 @@ function useEditorHTML(editor) {
|
|
|
45
45
|
function useEditorJSON(editor) {
|
|
46
46
|
return createEditorTransaction(editor, (instance) => instance == null ? void 0 : instance.getJSON());
|
|
47
47
|
}
|
|
48
|
-
function useEditorCharacterCount(editor) {
|
|
49
|
-
return createEditorTransaction(editor, (instance) => instance == null ? void 0 : instance.getCharacterCount());
|
|
50
|
-
}
|
|
51
48
|
function useEditorIsActive(editor, ...args) {
|
|
52
49
|
return createEditorTransaction(editor, (instance) => {
|
|
53
50
|
if (args.length === 2) {
|
|
@@ -75,7 +72,6 @@ export {
|
|
|
75
72
|
createEditorTransaction,
|
|
76
73
|
useEditor as createTiptapEditor,
|
|
77
74
|
useEditor,
|
|
78
|
-
useEditorCharacterCount,
|
|
79
75
|
useEditorHTML,
|
|
80
76
|
useEditorIsActive,
|
|
81
77
|
useEditorIsEditable,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/Editor.tsx"],
|
|
4
|
-
"sourcesContent": ["import {\n createEffect,\n createSignal,\n onCleanup,\n} from 'solid-js';\nimport {\n Editor,\n EditorOptions,\n} from '@tiptap/core';\n\nexport type EditorRef = Editor | ((editor: Editor) => void);\n\nexport type BaseEditorOptions = Omit<Partial<EditorOptions>, 'element'>;\n\nexport interface UseEditorOptions<T extends HTMLElement> extends BaseEditorOptions {\n element: T;\n}\n\nexport function createEditorTransaction<T, V extends Editor | undefined>(\n instance: () => V,\n read: (value: V) => T,\n): () => T {\n const [
|
|
5
|
-
"mappings": ";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,OAEK;AAUA,SAAS,wBACd,UACA,MACS;AACT,QAAM,CAAC,QAAQ,
|
|
4
|
+
"sourcesContent": ["import {\n createEffect,\n createSignal,\n onCleanup,\n} from 'solid-js';\nimport {\n Editor,\n EditorOptions,\n} from '@tiptap/core';\n\nexport type EditorRef = Editor | ((editor: Editor) => void);\n\nexport type BaseEditorOptions = Omit<Partial<EditorOptions>, 'element'>;\n\nexport interface UseEditorOptions<T extends HTMLElement> extends BaseEditorOptions {\n element: T;\n}\n\nexport function createEditorTransaction<T, V extends Editor | undefined>(\n instance: () => V,\n read: (value: V) => T,\n): () => T {\n const [depend, update] = createSignal(undefined, { equals: false });\n\n function forceUpdate() {\n update()\n }\n\n createEffect(() => {\n const editor = instance();\n if (editor) {\n editor.on('transaction', forceUpdate);\n onCleanup(() => {\n editor.off('transaction', forceUpdate);\n });\n }\n });\n\n return () => {\n depend();\n return read(instance());\n };\n}\n\nexport default function useEditor<T extends HTMLElement>(\n props: () => UseEditorOptions<T>,\n): () => Editor | undefined {\n const [signal, setSignal] = createSignal<Editor>();\n\n createEffect(() => {\n const instance = new Editor({\n ...props(),\n });\n\n onCleanup(() => {\n instance.destroy();\n });\n\n setSignal(instance);\n });\n\n return signal;\n}\n\nexport function useEditorHTML<V extends Editor | undefined>(\n editor: () => V,\n): () => string | undefined {\n return createEditorTransaction(editor, (instance) => instance?.getHTML());\n}\n\nexport function useEditorJSON<V extends Editor | undefined, R extends Record<string, any>>(\n editor: () => V,\n): () => R | undefined {\n return createEditorTransaction(editor, (instance) => instance?.getJSON() as R);\n}\n\nexport function useEditorIsActive<V extends Editor | undefined, R extends Record<string, any>>(\n editor: () => V,\n ...args: [name: () => string, options?: R] | [options: R]\n): () => boolean | undefined {\n return createEditorTransaction(editor, (instance) => {\n if (args.length === 2) {\n return instance?.isActive(\n args[0](),\n args[1],\n );\n }\n return instance?.isActive(\n args[0],\n );\n });\n}\n\nexport function useEditorIsEmpty<V extends Editor | undefined>(\n editor: () => V,\n): () => boolean | undefined {\n return createEditorTransaction(editor, (instance) => instance?.isEmpty);\n}\n\nexport function useEditorIsEditable<V extends Editor | undefined>(\n editor: () => V,\n): () => boolean | undefined {\n return createEditorTransaction(editor, (instance) => instance?.isEditable);\n}\n\nexport function useEditorIsFocused<V extends Editor | undefined>(\n editor: () => V,\n): () => boolean | undefined {\n return createEditorTransaction(editor, (instance) => instance?.isFocused);\n}\n"],
|
|
5
|
+
"mappings": ";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,OAEK;AAUA,SAAS,wBACd,UACA,MACS;AACT,QAAM,CAAC,QAAQ,MAAM,IAAI,aAAa,QAAW,EAAE,QAAQ,MAAM,CAAC;AAElE,WAAS,cAAc;AACrB,WAAO;AAAA,EACT;AAEA,eAAa,MAAM;AACjB,UAAM,SAAS,SAAS;AACxB,QAAI,QAAQ;AACV,aAAO,GAAG,eAAe,WAAW;AACpC,gBAAU,MAAM;AACd,eAAO,IAAI,eAAe,WAAW;AAAA,MACvC,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AAED,SAAO,MAAM;AACX,WAAO;AACP,WAAO,KAAK,SAAS,CAAC;AAAA,EACxB;AACF;AAEe,SAAR,UACL,OAC0B;AAC1B,QAAM,CAAC,QAAQ,SAAS,IAAI,aAAqB;AAEjD,eAAa,MAAM;AACjB,UAAM,WAAW,IAAI,OAAO;AAAA,MAC1B,GAAG,MAAM;AAAA,IACX,CAAC;AAED,cAAU,MAAM;AACd,eAAS,QAAQ;AAAA,IACnB,CAAC;AAED,cAAU,QAAQ;AAAA,EACpB,CAAC;AAED,SAAO;AACT;AAEO,SAAS,cACd,QAC0B;AAC1B,SAAO,wBAAwB,QAAQ,CAAC,aAAa,qCAAU,SAAS;AAC1E;AAEO,SAAS,cACd,QACqB;AACrB,SAAO,wBAAwB,QAAQ,CAAC,aAAa,qCAAU,SAAc;AAC/E;AAEO,SAAS,kBACd,WACG,MACwB;AAC3B,SAAO,wBAAwB,QAAQ,CAAC,aAAa;AACnD,QAAI,KAAK,WAAW,GAAG;AACrB,aAAO,qCAAU;AAAA,QACf,KAAK,CAAC,EAAE;AAAA,QACR,KAAK,CAAC;AAAA;AAAA,IAEV;AACA,WAAO,qCAAU;AAAA,MACf,KAAK,CAAC;AAAA;AAAA,EAEV,CAAC;AACH;AAEO,SAAS,iBACd,QAC2B;AAC3B,SAAO,wBAAwB,QAAQ,CAAC,aAAa,qCAAU,OAAO;AACxE;AAEO,SAAS,oBACd,QAC2B;AAC3B,SAAO,wBAAwB,QAAQ,CAAC,aAAa,qCAAU,UAAU;AAC3E;AAEO,SAAS,mBACd,QAC2B;AAC3B,SAAO,wBAAwB,QAAQ,CAAC,aAAa,qCAAU,SAAS;AAC1E;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createEffect as E,createSignal as s,onCleanup as f}from"solid-js";import{Editor as p}from"@tiptap/core";function
|
|
1
|
+
import{createEffect as E,createSignal as s,onCleanup as f}from"solid-js";import{Editor as p}from"@tiptap/core";function d(t,e){let[o,i]=s(void 0,{equals:!1});function n(){i()}return E(()=>{let u=t();u&&(u.on("transaction",n),f(()=>{u.off("transaction",n)}))}),()=>(o(),e(t()))}function r(t){let[e,o]=s();return E(()=>{let i=new p({...t()});f(()=>{i.destroy()}),o(i)}),e}function l(t){return d(t,e=>e==null?void 0:e.getHTML())}function x(t){return d(t,e=>e==null?void 0:e.getJSON())}function a(t,...e){return d(t,o=>e.length===2?o==null?void 0:o.isActive(e[0](),e[1]):o==null?void 0:o.isActive(e[0]))}function T(t){return d(t,e=>e==null?void 0:e.isEmpty)}function V(t){return d(t,e=>e==null?void 0:e.isEditable)}function m(t){return d(t,e=>e==null?void 0:e.isFocused)}export{r as createEditor,d as createEditorTransaction,r as createTiptapEditor,r as useEditor,l as useEditorHTML,a as useEditorIsActive,V as useEditorIsEditable,T as useEditorIsEmpty,m as useEditorIsFocused,x as useEditorJSON,r as useTiptapEditor};
|
package/dist/types/Editor.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ export declare function createEditorTransaction<T, V extends Editor | undefined>
|
|
|
8
8
|
export default function useEditor<T extends HTMLElement>(props: () => UseEditorOptions<T>): () => Editor | undefined;
|
|
9
9
|
export declare function useEditorHTML<V extends Editor | undefined>(editor: () => V): () => string | undefined;
|
|
10
10
|
export declare function useEditorJSON<V extends Editor | undefined, R extends Record<string, any>>(editor: () => V): () => R | undefined;
|
|
11
|
-
export declare function useEditorCharacterCount<V extends Editor | undefined>(editor: () => V): () => number | undefined;
|
|
12
11
|
export declare function useEditorIsActive<V extends Editor | undefined, R extends Record<string, any>>(editor: () => V, ...args: [name: () => string, options?: R] | [options: R]): () => boolean | undefined;
|
|
13
12
|
export declare function useEditorIsEmpty<V extends Editor | undefined>(editor: () => V): () => boolean | undefined;
|
|
14
13
|
export declare function useEditorIsEditable<V extends Editor | undefined>(editor: () => V): () => boolean | undefined;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as useEditor, default as createEditor, default as useTiptapEditor, default as createTiptapEditor, UseEditorOptions, EditorRef, createEditorTransaction,
|
|
1
|
+
export { default as useEditor, default as createEditor, default as useTiptapEditor, default as createTiptapEditor, UseEditorOptions, EditorRef, createEditorTransaction, useEditorHTML, useEditorIsActive, useEditorIsEditable, useEditorIsEmpty, useEditorIsFocused, useEditorJSON, } from './Editor';
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.6.0",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"types": "./dist/types/index.d.ts",
|
|
5
5
|
"main": "./dist/cjs/production/index.cjs",
|
|
@@ -28,20 +28,20 @@
|
|
|
28
28
|
],
|
|
29
29
|
"name": "solid-tiptap",
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@tiptap/core": "^2.0.
|
|
32
|
-
"@tiptap/pm": "^2.0.
|
|
31
|
+
"@tiptap/core": "^2.0.2",
|
|
32
|
+
"@tiptap/pm": "^2.0.2",
|
|
33
33
|
"@types/node": "^18.14.5",
|
|
34
|
-
"eslint": "^8.
|
|
35
|
-
"eslint-config-lxsmnsyc": "^0.
|
|
34
|
+
"eslint": "^8.38.0",
|
|
35
|
+
"eslint-config-lxsmnsyc": "^0.5.1",
|
|
36
36
|
"pridepack": "^2.4.1",
|
|
37
|
-
"solid-js": "^1.
|
|
37
|
+
"solid-js": "^1.7.3",
|
|
38
38
|
"tslib": "^2.5.0",
|
|
39
39
|
"typescript": "^4.9.5"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@tiptap/core": "^2
|
|
43
|
-
"@tiptap/pm": "^2
|
|
44
|
-
"solid-js": "^1.
|
|
42
|
+
"@tiptap/core": "^2",
|
|
43
|
+
"@tiptap/pm": "^2",
|
|
44
|
+
"solid-js": "^1.7"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"prepublishOnly": "pridepack clean && pridepack build",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"typesVersions": {
|
|
70
70
|
"*": {}
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "5e493b3c99878d49dc4df45395deaee8a467cc32"
|
|
73
73
|
}
|
package/src/Editor.tsx
CHANGED
|
@@ -20,10 +20,10 @@ export function createEditorTransaction<T, V extends Editor | undefined>(
|
|
|
20
20
|
instance: () => V,
|
|
21
21
|
read: (value: V) => T,
|
|
22
22
|
): () => T {
|
|
23
|
-
const [
|
|
23
|
+
const [depend, update] = createSignal(undefined, { equals: false });
|
|
24
24
|
|
|
25
25
|
function forceUpdate() {
|
|
26
|
-
|
|
26
|
+
update()
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
createEffect(() => {
|
|
@@ -37,7 +37,7 @@ export function createEditorTransaction<T, V extends Editor | undefined>(
|
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
return () => {
|
|
40
|
-
|
|
40
|
+
depend();
|
|
41
41
|
return read(instance());
|
|
42
42
|
};
|
|
43
43
|
}
|
|
@@ -74,12 +74,6 @@ export function useEditorJSON<V extends Editor | undefined, R extends Record<str
|
|
|
74
74
|
return createEditorTransaction(editor, (instance) => instance?.getJSON() as R);
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
export function useEditorCharacterCount<V extends Editor | undefined>(
|
|
78
|
-
editor: () => V,
|
|
79
|
-
): () => number | undefined {
|
|
80
|
-
return createEditorTransaction(editor, (instance) => instance?.getCharacterCount());
|
|
81
|
-
}
|
|
82
|
-
|
|
83
77
|
export function useEditorIsActive<V extends Editor | undefined, R extends Record<string, any>>(
|
|
84
78
|
editor: () => V,
|
|
85
79
|
...args: [name: () => string, options?: R] | [options: R]
|