solid-tiptap 0.2.1 → 0.3.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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2021 Alexis Munsayac
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Alexis Munsayac
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
@@ -153,4 +153,4 @@ function useEditorIsFocused(editor) {
153
153
  useEditorJSON,
154
154
  useTiptapEditor
155
155
  });
156
- //# sourceMappingURL=index.jsx.map
156
+ //# sourceMappingURL=index.js.map
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  var S=Object.create;var E=Object.defineProperty,v=Object.defineProperties,h=Object.getOwnPropertyDescriptor,H=Object.getOwnPropertyDescriptors,P=Object.getOwnPropertyNames,f=Object.getOwnPropertySymbols,A=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty,B=Object.prototype.propertyIsEnumerable;var l=(t,e,o)=>e in t?E(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,a=(t,e)=>{for(var o in e||(e={}))p.call(e,o)&&l(t,o,e[o]);if(f)for(var o of f(e))B.call(e,o)&&l(t,o,e[o]);return t},x=(t,e)=>v(t,H(e)),O=t=>E(t,"__esModule",{value:!0});var L=(t,e)=>{O(t);for(var o in e)E(t,o,{get:e[o],enumerable:!0})},M=(t,e,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of P(e))!p.call(t,r)&&r!=="default"&&E(t,r,{get:()=>e[r],enumerable:!(o=h(e,r))||o.enumerable});return t},T=t=>M(O(E(t!=null?S(A(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);L(exports,{createEditor:()=>u,createEditorTransaction:()=>i,createTiptapEditor:()=>u,useEditor:()=>u,useEditorCharacterCount:()=>b,useEditorHTML:()=>c,useEditorIsActive:()=>g,useEditorIsEditable:()=>I,useEditorIsEmpty:()=>y,useEditorIsFocused:()=>C,useEditorJSON:()=>R,useTiptapEditor:()=>u});var d=T(require("solid-js")),m=T(require("@tiptap/core")),V=["autofocus","content","editable","editorProps","enableInputRules","enablePasteRules","extensions","injectCSS","parseOptions"];function U(t,e,o){(0,d.createEffect)((0,d.on)(()=>o[e],r=>{t.setOptions({[e]:r})}))}function i(t,e){let[o,r]=(0,d.createSignal)([]);function n(){r([])}return(0,d.createEffect)(()=>{let s=t();s&&(s.on("transaction",n),(0,d.onCleanup)(()=>{s.off("transaction",n)}))}),()=>(o(),e(t()))}function u(t){let[e,o]=(0,d.createSignal)();return(0,d.createEffect)(()=>{let r=new m.Editor(x(a({},t),{element:t.element}));for(let n=0,s=V.length;n<s;n+=1)U(r,V[n],t);(0,d.onCleanup)(()=>{r.destroy()}),o(r)}),e}function c(t){return i(t,e=>e==null?void 0:e.getHTML())}function R(t){return i(t,e=>e==null?void 0:e.getJSON())}function b(t){return i(t,e=>e==null?void 0:e.getCharacterCount())}function g(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 y(t){return i(t,e=>e==null?void 0:e.isEmpty)}function I(t){return i(t,e=>e==null?void 0:e.isEditable)}function C(t){return i(t,e=>e==null?void 0:e.isFocused)}0&&(module.exports={createEditor,createEditorTransaction,createTiptapEditor,useEditor,useEditorCharacterCount,useEditorHTML,useEditorIsActive,useEditorIsEditable,useEditorIsEmpty,useEditorIsFocused,useEditorJSON,useTiptapEditor});
3
- //# sourceMappingURL=index.jsx.map
3
+ //# sourceMappingURL=index.js.map
@@ -121,4 +121,4 @@ export {
121
121
  useEditorJSON,
122
122
  useEditor as useTiptapEditor
123
123
  };
124
- //# sourceMappingURL=index.jsx.map
124
+ //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/Editor.tsx"],
3
+ "sources": ["../../../src/Editor.tsx"],
4
4
  "sourcesContent": ["import {\n createEffect,\n createSignal,\n on,\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\nconst WATCHED_PROPERTIES: (keyof BaseEditorOptions)[] = [\n 'autofocus',\n 'content',\n 'editable',\n 'editorProps',\n 'enableInputRules',\n 'enablePasteRules',\n 'extensions',\n 'injectCSS',\n 'parseOptions',\n];\n\nfunction createOptionPatch(\n instance: Editor,\n field: keyof BaseEditorOptions,\n props: BaseEditorOptions,\n): void {\n createEffect(on(() => props[field], (value) => {\n instance.setOptions({\n [field]: value,\n });\n }));\n}\n\nexport function createEditorTransaction<T, V extends Editor | undefined>(\n instance: () => V,\n read: (value: V) => T,\n): () => T {\n const [signal, setSignal] = createSignal([]);\n\n function forceUpdate() {\n setSignal([]);\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 signal();\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 element: props.element,\n });\n\n for (let i = 0, len = WATCHED_PROPERTIES.length; i < len; i += 1) {\n createOptionPatch(instance, WATCHED_PROPERTIES[i], 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 useEditorCharacterCount<V extends Editor | undefined>(\n editor: () => V,\n): () => number | undefined {\n return createEditorTransaction(editor, (instance) => instance?.getCharacterCount());\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
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA;AAAA;AAAA;AAaA,IAAM,qBAAkD;AAAA,EACtD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAGF,2BACE,UACA,OACA,OACM;AACN,eAAa,GAAG,MAAM,MAAM,QAAQ,CAAC,UAAU;AAC7C,aAAS,WAAW;AAAA,OACjB,QAAQ;AAAA;AAAA;AAAA;AAKR,iCACL,UACA,MACS;AACT,QAAM,CAAC,QAAQ,aAAa,aAAa;AAEzC,yBAAuB;AACrB,cAAU;AAAA;AAGZ,eAAa,MAAM;AACjB,UAAM,SAAS;AACf,QAAI,QAAQ;AACV,aAAO,GAAG,eAAe;AACzB,gBAAU,MAAM;AACd,eAAO,IAAI,eAAe;AAAA;AAAA;AAAA;AAKhC,SAAO,MAAM;AACX;AACA,WAAO,KAAK;AAAA;AAAA;AAID,mBACb,OAC0B;AAC1B,QAAM,CAAC,QAAQ,aAAa;AAE5B,eAAa,MAAM;AACjB,UAAM,WAAW,IAAI,OAAO,iCACvB,QADuB;AAAA,MAE1B,SAAS,MAAM;AAAA;AAGjB,aAAS,IAAI,GAAG,MAAM,mBAAmB,QAAQ,IAAI,KAAK,KAAK,GAAG;AAChE,wBAAkB,UAAU,mBAAmB,IAAI;AAAA;AAGrD,cAAU,MAAM;AACd,eAAS;AAAA;AAGX,cAAU;AAAA;AAGZ,SAAO;AAAA;AAGF,uBACL,QAC0B;AAC1B,SAAO,wBAAwB,QAAQ,CAAC,aAAa,qCAAU;AAAA;AAG1D,uBACL,QACqB;AACrB,SAAO,wBAAwB,QAAQ,CAAC,aAAa,qCAAU;AAAA;AAG1D,iCACL,QAC0B;AAC1B,SAAO,wBAAwB,QAAQ,CAAC,aAAa,qCAAU;AAAA;AAG1D,2BACL,WACG,MACwB;AAC3B,SAAO,wBAAwB,QAAQ,CAAC,aAAa;AACnD,QAAI,KAAK,WAAW,GAAG;AACrB,aAAO,qCAAU,SACf,KAAK,MACL,KAAK;AAAA;AAGT,WAAO,qCAAU,SACf,KAAK;AAAA;AAAA;AAKJ,0BACL,QAC2B;AAC3B,SAAO,wBAAwB,QAAQ,CAAC,aAAa,qCAAU;AAAA;AAG1D,6BACL,QAC2B;AAC3B,SAAO,wBAAwB,QAAQ,CAAC,aAAa,qCAAU;AAAA;AAG1D,4BACL,QAC2B;AAC3B,SAAO,wBAAwB,QAAQ,CAAC,aAAa,qCAAU;AAAA;",
6
6
  "names": []
@@ -0,0 +1,2 @@
1
+ var T=Object.defineProperty,m=Object.defineProperties;var V=Object.getOwnPropertyDescriptors;var E=Object.getOwnPropertySymbols;var c=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable;var f=(t,e,o)=>e in t?T(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,p=(t,e)=>{for(var o in e||(e={}))c.call(e,o)&&f(t,o,e[o]);if(E)for(var o of E(e))R.call(e,o)&&f(t,o,e[o]);return t},l=(t,e)=>m(t,V(e));import{createEffect as s,createSignal as a,on as b,onCleanup as x}from"solid-js";import{Editor as g}from"@tiptap/core";var O=["autofocus","content","editable","editorProps","enableInputRules","enablePasteRules","extensions","injectCSS","parseOptions"];function y(t,e,o){s(b(()=>o[e],d=>{t.setOptions({[e]:d})}))}function r(t,e){let[o,d]=a([]);function i(){d([])}return s(()=>{let n=t();n&&(n.on("transaction",i),x(()=>{n.off("transaction",i)}))}),()=>(o(),e(t()))}function u(t){let[e,o]=a();return s(()=>{let d=new g(l(p({},t),{element:t.element}));for(let i=0,n=O.length;i<n;i+=1)y(d,O[i],t);x(()=>{d.destroy()}),o(d)}),e}function I(t){return r(t,e=>e==null?void 0:e.getHTML())}function C(t){return r(t,e=>e==null?void 0:e.getJSON())}function S(t){return r(t,e=>e==null?void 0:e.getCharacterCount())}function v(t,...e){return r(t,o=>e.length===2?o==null?void 0:o.isActive(e[0](),e[1]):o==null?void 0:o.isActive(e[0]))}function h(t){return r(t,e=>e==null?void 0:e.isEmpty)}function H(t){return r(t,e=>e==null?void 0:e.isEditable)}function P(t){return r(t,e=>e==null?void 0:e.isFocused)}export{u as createEditor,r as createEditorTransaction,u as createTiptapEditor,u as useEditor,S as useEditorCharacterCount,I as useEditorHTML,v as useEditorIsActive,H as useEditorIsEditable,h as useEditorIsEmpty,P as useEditorIsFocused,C as useEditorJSON,u as useTiptapEditor};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/Editor.tsx"],
4
+ "sourcesContent": ["import {\n createEffect,\n createSignal,\n on,\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\nconst WATCHED_PROPERTIES: (keyof BaseEditorOptions)[] = [\n 'autofocus',\n 'content',\n 'editable',\n 'editorProps',\n 'enableInputRules',\n 'enablePasteRules',\n 'extensions',\n 'injectCSS',\n 'parseOptions',\n];\n\nfunction createOptionPatch(\n instance: Editor,\n field: keyof BaseEditorOptions,\n props: BaseEditorOptions,\n): void {\n createEffect(on(() => props[field], (value) => {\n instance.setOptions({\n [field]: value,\n });\n }));\n}\n\nexport function createEditorTransaction<T, V extends Editor | undefined>(\n instance: () => V,\n read: (value: V) => T,\n): () => T {\n const [signal, setSignal] = createSignal([]);\n\n function forceUpdate() {\n setSignal([]);\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 signal();\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 element: props.element,\n });\n\n for (let i = 0, len = WATCHED_PROPERTIES.length; i < len; i += 1) {\n createOptionPatch(instance, WATCHED_PROPERTIES[i], 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 useEditorCharacterCount<V extends Editor | undefined>(\n editor: () => V,\n): () => number | undefined {\n return createEditorTransaction(editor, (instance) => instance?.getCharacterCount());\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": "6aAAA,iFAMA,sCAaA,GAAM,GAAkD,CACtD,YACA,UACA,WACA,cACA,mBACA,mBACA,aACA,YACA,gBAGF,WACE,EACA,EACA,EACM,CACN,EAAa,EAAG,IAAM,EAAM,GAAQ,AAAC,GAAU,CAC7C,EAAS,WAAW,EACjB,GAAQ,OAKR,WACL,EACA,EACS,CACT,GAAM,CAAC,EAAQ,GAAa,EAAa,IAEzC,YAAuB,CACrB,EAAU,IAGZ,SAAa,IAAM,CACjB,GAAM,GAAS,IACf,AAAI,GACF,GAAO,GAAG,cAAe,GACzB,EAAU,IAAM,CACd,EAAO,IAAI,cAAe,QAKzB,IACL,KACO,EAAK,MAID,WACb,EAC0B,CAC1B,GAAM,CAAC,EAAQ,GAAa,IAE5B,SAAa,IAAM,CACjB,GAAM,GAAW,GAAI,GAAO,OACvB,GADuB,CAE1B,QAAS,EAAM,WAGjB,OAAS,GAAI,EAAG,EAAM,EAAmB,OAAQ,EAAI,EAAK,GAAK,EAC7D,EAAkB,EAAU,EAAmB,GAAI,GAGrD,EAAU,IAAM,CACd,EAAS,YAGX,EAAU,KAGL,EAGF,WACL,EAC0B,CAC1B,MAAO,GAAwB,EAAQ,AAAC,GAAa,iBAAU,WAG1D,WACL,EACqB,CACrB,MAAO,GAAwB,EAAQ,AAAC,GAAa,iBAAU,WAG1D,WACL,EAC0B,CAC1B,MAAO,GAAwB,EAAQ,AAAC,GAAa,iBAAU,qBAG1D,WACL,KACG,EACwB,CAC3B,MAAO,GAAwB,EAAQ,AAAC,GAClC,EAAK,SAAW,EACX,iBAAU,SACf,EAAK,KACL,EAAK,IAGF,iBAAU,SACf,EAAK,KAKJ,WACL,EAC2B,CAC3B,MAAO,GAAwB,EAAQ,AAAC,GAAa,iBAAU,SAG1D,WACL,EAC2B,CAC3B,MAAO,GAAwB,EAAQ,AAAC,GAAa,iBAAU,YAG1D,WACL,EAC2B,CAC3B,MAAO,GAAwB,EAAQ,AAAC,GAAa,iBAAU",
6
+ "names": []
7
+ }
@@ -1,15 +1,15 @@
1
- import { Editor, EditorOptions } from '@tiptap/core';
2
- export declare type EditorRef = Editor | ((editor: Editor) => void);
3
- export declare type BaseEditorOptions = Omit<Partial<EditorOptions>, 'element'>;
4
- export interface UseEditorOptions<T extends HTMLElement> extends BaseEditorOptions {
5
- element: T;
6
- }
7
- export declare function createEditorTransaction<T, V extends Editor | undefined>(instance: () => V, read: (value: V) => T): () => T;
8
- export default function useEditor<T extends HTMLElement>(props: UseEditorOptions<T>): () => Editor | undefined;
9
- export declare function useEditorHTML<V extends Editor | undefined>(editor: () => V): () => string | undefined;
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
- 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
- export declare function useEditorIsEmpty<V extends Editor | undefined>(editor: () => V): () => boolean | undefined;
14
- export declare function useEditorIsEditable<V extends Editor | undefined>(editor: () => V): () => boolean | undefined;
15
- export declare function useEditorIsFocused<V extends Editor | undefined>(editor: () => V): () => boolean | undefined;
1
+ import { Editor, EditorOptions } from '@tiptap/core';
2
+ export declare type EditorRef = Editor | ((editor: Editor) => void);
3
+ export declare type BaseEditorOptions = Omit<Partial<EditorOptions>, 'element'>;
4
+ export interface UseEditorOptions<T extends HTMLElement> extends BaseEditorOptions {
5
+ element: T;
6
+ }
7
+ export declare function createEditorTransaction<T, V extends Editor | undefined>(instance: () => V, read: (value: V) => T): () => T;
8
+ export default function useEditor<T extends HTMLElement>(props: UseEditorOptions<T>): () => Editor | undefined;
9
+ export declare function useEditorHTML<V extends Editor | undefined>(editor: () => V): () => string | undefined;
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
+ 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
+ export declare function useEditorIsEmpty<V extends Editor | undefined>(editor: () => V): () => boolean | undefined;
14
+ export declare function useEditorIsEditable<V extends Editor | undefined>(editor: () => V): () => boolean | undefined;
15
+ export declare function useEditorIsFocused<V extends Editor | undefined>(editor: () => V): () => boolean | undefined;
@@ -1 +1 @@
1
- export { default as useEditor, default as createEditor, default as useTiptapEditor, default as createTiptapEditor, UseEditorOptions, EditorRef, createEditorTransaction, useEditorCharacterCount, useEditorHTML, useEditorIsActive, useEditorIsEditable, useEditorIsEmpty, useEditorIsFocused, useEditorJSON, } from './Editor';
1
+ export { default as useEditor, default as createEditor, default as useTiptapEditor, default as createTiptapEditor, UseEditorOptions, EditorRef, createEditorTransaction, useEditorCharacterCount, useEditorHTML, useEditorIsActive, useEditorIsEditable, useEditorIsEmpty, useEditorIsFocused, useEditorJSON, } from './Editor';
package/package.json CHANGED
@@ -1,11 +1,39 @@
1
1
  {
2
- "version": "0.2.1",
2
+ "version": "0.3.3",
3
3
  "types": "dist/types/index.d.ts",
4
- "main": "dist/cjs/index.js",
5
- "module": "dist/esm/index.jsx",
4
+ "main": "dist/cjs/production/index.js",
5
+ "module": "dist/esm/production/index.js",
6
6
  "exports": {
7
- "require": "./dist/cjs/index.js",
8
- "import": "./dist/esm/index.jsx"
7
+ ".": {
8
+ "development": {
9
+ "require": "./dist/cjs/development/index.js",
10
+ "import": "./dist/esm/development/index.js"
11
+ },
12
+ "require": "./dist/cjs/production/index.js",
13
+ "import": "./dist/esm/production/index.js",
14
+ "types": "./dist/types/index.d.ts"
15
+ },
16
+ "./dev": {
17
+ "production": {
18
+ "require": "./dist/cjs/production/index.js",
19
+ "import": "./dist/esm/production/index.js"
20
+ },
21
+ "require": "./dist/cjs/development/index.js",
22
+ "import": "./dist/esm/development/index.js",
23
+ "types": "./dist/types/index.d.ts"
24
+ },
25
+ "./esm": {
26
+ "development": "./dist/esm/development/index.js",
27
+ "production": "./dist/esm/production/index.js",
28
+ "default": "./dist/esm/production/index.js",
29
+ "types": "./dist/types/index.d.ts"
30
+ },
31
+ "./cjs": {
32
+ "development": "./dist/cjs/development/index.js",
33
+ "production": "./dist/cjs/production/index.js",
34
+ "default": "./dist/cjs/production/index.js",
35
+ "types": "./dist/types/index.d.ts"
36
+ }
9
37
  },
10
38
  "files": [
11
39
  "dist",
@@ -21,21 +49,20 @@
21
49
  "name": "solid-tiptap",
22
50
  "devDependencies": {
23
51
  "@tiptap/core": "^2.0.0-beta.102",
24
- "@types/jest": "^27.0.1",
25
- "@types/node": "^16.7.10",
52
+ "@types/node": "^17.0.8",
26
53
  "eslint": "^7.32.0",
27
- "eslint-config-lxsmnsyc": "^0.2.3",
28
- "pridepack": "^0.12.2",
29
- "solid-js": "^1.1.2",
54
+ "eslint-config-lxsmnsyc": "^0.3.0",
55
+ "pridepack": "^1.0.3",
56
+ "solid-js": "^1.2.6",
30
57
  "tslib": "^2.3.1",
31
- "typescript": "^4.4.2"
58
+ "typescript": "^4.5.4"
32
59
  },
33
60
  "peerDependencies": {
34
61
  "@tiptap/core": "^2.0.0-beta.102",
35
- "solid-js": "^1.1.2"
62
+ "solid-js": "^1.2.0"
36
63
  },
37
64
  "scripts": {
38
- "prepublish": "pridepack clean && pridepack build",
65
+ "prepublishOnly": "pridepack clean && pridepack build",
39
66
  "build": "pridepack build",
40
67
  "type-check": "pridepack check",
41
68
  "lint": "pridepack lint",
@@ -57,5 +84,5 @@
57
84
  },
58
85
  "author": "Alexis Munsayac",
59
86
  "private": false,
60
- "gitHead": "ed66f7b6b84d05e77cc0d6a44917d91145069bb2"
87
+ "gitHead": "bae44d4637c3e87aa06b7219ea830c182db0f262"
61
88
  }
package/dist/cjs/index.js DELETED
@@ -1,8 +0,0 @@
1
-
2
- 'use strict';
3
- if (process.env.NODE_ENV === 'production') {
4
- module.exports = require('./production/index.jsx');
5
- } else {
6
- module.exports = require('./development/index.jsx');
7
- }
8
-