@seorii/tiptap 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/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export default TipTap;
2
- import TipTap from "./tiptap";
2
+ import TipTap from "./tiptap/index.js";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // Reexport your entry components here
2
- import TipTap from "./tiptap";
2
+ import TipTap from "./tiptap/index.js";
3
3
 
4
4
  export default TipTap;
@@ -0,0 +1,7 @@
1
+ declare const _default: import("@tiptap/core").Node<{
2
+ sizes: string[];
3
+ inline: boolean;
4
+ allowBase64: boolean;
5
+ HTMLAttributes: Record<string, any>;
6
+ }, any>;
7
+ export default _default;
@@ -0,0 +1,10 @@
1
+ import Image from "@tiptap/extension-image";
2
+ import { mergeAttributes } from "@tiptap/core";
3
+ export default Image.extend({
4
+ defaultOptions: { ...Image.options, sizes: ["inline", "block", "left", "right"] },
5
+ parseHTML: () => [{ tag: 'img' }],
6
+ renderHTML({ HTMLAttributes }) {
7
+ const { style } = HTMLAttributes;
8
+ return ["figure", { style }, ["img", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)]];
9
+ }
10
+ }).configure({ HTMLAttributes: { crossorigin: 'anonymous' } });
@@ -14,9 +14,10 @@ const san = (body, force = false) => (editor || force) ? body : sanitizeHtml(bod
14
14
  'tiptap-file': ['id']
15
15
  },
16
16
  });
17
- export let body = '', editor = false, style = '';
17
+ export let body = '', editor = false, style = '', ref = null, plugins = [];
18
18
  const tiptap = setContext('editor', writable(null));
19
19
  let element, _body = san(body, true), fullscreen = false, html = false, mounted = false;
20
+ $: ref = $tiptap;
20
21
  $: _san = san(body);
21
22
  $: if (_san !== _body && $tiptap)
22
23
  $tiptap?.commands.setContent(_body = _san);
@@ -30,6 +31,7 @@ if (browser)
30
31
  $tiptap = tt(element, _body, {
31
32
  editable: editor,
32
33
  onTransaction: () => $tiptap = $tiptap,
34
+ plugins,
33
35
  });
34
36
  $tiptap.on('update', ({ editor: tiptap }) => {
35
37
  let content = tiptap.getHTML(), json = tiptap.getJSON().content;
@@ -5,6 +5,8 @@ declare const __propDef: {
5
5
  body?: string | undefined;
6
6
  editor?: boolean | undefined;
7
7
  style?: string | undefined;
8
+ ref?: any;
9
+ plugins?: any[] | undefined;
8
10
  };
9
11
  events: {
10
12
  [evt: string]: CustomEvent<any>;
@@ -1,3 +1,3 @@
1
1
  import { Editor } from "@tiptap/core";
2
- declare const _default: (element: Element, content: string, { placeholder, ...props }?: any) => Editor;
2
+ declare const _default: (element: Element, content: string, { placeholder, plugins, ...props }?: any) => Editor;
3
3
  export default _default;
@@ -1,7 +1,7 @@
1
1
  import { Editor, mergeAttributes } from "@tiptap/core";
2
2
  import { CodeBlockLowlight } from "@tiptap/extension-code-block-lowlight";
3
3
  import { lowlight } from "lowlight";
4
- import Image from "@tiptap/extension-image";
4
+ import Image from "../plugin/image";
5
5
  import StarterKit from "@tiptap/starter-kit";
6
6
  import Underline from "@tiptap/extension-underline";
7
7
  import Highlight from "@tiptap/extension-highlight";
@@ -20,19 +20,13 @@ import { Indent } from "../plugin/indent";
20
20
  import { Color } from '@tiptap/extension-color';
21
21
  import TextStyle from '@tiptap/extension-text-style';
22
22
  import Iframe from "../plugin/iframe";
23
+ //@ts-ignore
23
24
  import Math from "tiptap-katex";
24
- export default (element, content, { placeholder = '내용을 입력하세요...', ...props } = {}) => new Editor({
25
+ export default (element, content, { placeholder = '내용을 입력하세요...', plugins = [], ...props } = {}) => new Editor({
25
26
  element, content, ...props,
26
27
  extensions: [
27
28
  CodeBlockLowlight.configure({ lowlight }),
28
- Image.extend({
29
- defaultOptions: { ...Image.options, sizes: ["inline", "block", "left", "right"] },
30
- parseHTML: () => [{ tag: 'img' }],
31
- renderHTML({ HTMLAttributes }) {
32
- const { style } = HTMLAttributes;
33
- return ["figure", { style }, ["img", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)]];
34
- }
35
- }).configure({ HTMLAttributes: { crossorigin: 'anonymous' } }),
29
+ Image,
36
30
  StarterKit,
37
31
  Underline,
38
32
  Highlight.configure({ multicolor: true }),
@@ -52,5 +46,6 @@ export default (element, content, { placeholder = '내용을 입력하세요...'
52
46
  TextStyle,
53
47
  Math,
54
48
  Iframe,
49
+ ...plugins,
55
50
  ],
56
51
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seorii/tiptap",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "svelte-kit sync && svelte-package",
@@ -16,11 +16,11 @@
16
16
  "@sveltejs/package": "^2.2.0",
17
17
  "@typescript-eslint/eslint-plugin": "^6.2.0",
18
18
  "@typescript-eslint/parser": "^6.2.0",
19
- "eslint": "^8.45.0",
20
- "eslint-config-prettier": "^8.8.0",
19
+ "eslint": "^8.46.0",
20
+ "eslint-config-prettier": "^8.9.0",
21
21
  "eslint-plugin-svelte3": "^4.0.0",
22
22
  "prettier": "^3.0.0",
23
- "prettier-plugin-svelte": "^3.0.1",
23
+ "prettier-plugin-svelte": "^3.0.3",
24
24
  "sass": "^1.64.1",
25
25
  "svelte": "^4.1.1",
26
26
  "svelte-check": "^3.4.6",
@@ -55,8 +55,8 @@
55
55
  "prosemirror-model": "^1.19.3",
56
56
  "prosemirror-state": "^1.4.3",
57
57
  "prosemirror-tables": "^1.3.4",
58
- "prosemirror-transform": "^1.7.3",
59
- "prosemirror-view": "^1.31.6",
58
+ "prosemirror-transform": "^1.7.4",
59
+ "prosemirror-view": "^1.31.7",
60
60
  "sanitize-html": "^2.11.0",
61
61
  "tiptap-katex": "^0.0.2"
62
62
  },