@seorii/tiptap 0.2.0 → 0.2.2

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.
@@ -39,5 +39,6 @@ declare const _default: {
39
39
  youtubeInfo: string;
40
40
  blockquoteInfo: string;
41
41
  newLineInfo: string;
42
+ placeholder: string;
42
43
  };
43
44
  export default _default;
@@ -38,5 +38,6 @@ export default {
38
38
  iframeInfo: 'Embed another website',
39
39
  youtubeInfo: 'Embed Youtube video',
40
40
  blockquoteInfo: 'Blockquote',
41
- newLineInfo: 'Press / to enter commands. Or'
41
+ newLineInfo: 'Press / to enter commands. Or',
42
+ placeholder: 'Enter content here...',
42
43
  };
@@ -39,5 +39,6 @@ declare const _default: {
39
39
  youtubeInfo: string;
40
40
  blockquoteInfo: string;
41
41
  newLineInfo: string;
42
+ placeholder: string;
42
43
  };
43
44
  export default _default;
@@ -38,5 +38,6 @@ export default {
38
38
  iframeInfo: '다른 웹사이트 삽입',
39
39
  youtubeInfo: '유튜브 동영상 삽입',
40
40
  blockquoteInfo: '있어보이는 인용구 삽입',
41
- newLineInfo: '/로 명령어 입력. 또는'
41
+ newLineInfo: '/로 명령어 입력. 또는',
42
+ placeholder: '내용을 입력하세요...',
42
43
  };
@@ -43,7 +43,7 @@ export const emoji = {
43
43
  filtered.push({
44
44
  title: emojis[i] + ' ' + tags[i],
45
45
  command: ({ editor, range }) => {
46
- editor.chain().deleteRange(fixRange(editor, range, ':')).insertContent(emojis[i]).run();
46
+ editor.chain().deleteRange(fixRange(editor, range, ':')).insertContent(emojis[i] + ' ').run();
47
47
  }
48
48
  });
49
49
  if (filtered.length >= max)
@@ -7,15 +7,7 @@ export declare const suggest: {
7
7
  query: any;
8
8
  }) => {
9
9
  section: any;
10
- list: {
11
- icon: string;
12
- title: any;
13
- subtitle: any;
14
- command: ({ editor, range }: {
15
- editor: any;
16
- range: any;
17
- }) => void;
18
- }[];
10
+ list: any[];
19
11
  }[];
20
12
  render: () => {
21
13
  onStart: (props: any) => void;
@@ -83,6 +83,7 @@ export const suggest = {
83
83
  },
84
84
  {
85
85
  section: i18n('block'), list: [
86
+ ...(window.__tiptap_blocks),
86
87
  {
87
88
  icon: 'image',
88
89
  title: i18n('image'),
@@ -28,7 +28,7 @@ $: setTimeout(() => focus?.focus?.(), 100);
28
28
  <div class="title">iframe</div>
29
29
  </header>
30
30
  <Input placeholder="url" fullWidth bind:value={iframe} bind:input={focus}
31
- on:submit={() => $tiptap.commands.insertContent({type: 'iframe', attrs: {src: iframe}})}/>
31
+ on:submit={() => $tiptap.chain().focus().insertContent({type: 'iframe', attrs: {src: iframe}}).insertContent('\n').run()}/>
32
32
  <footer>
33
33
  <Button tabindex="0" transparent small on:click={() => {
34
34
  iframe = ''
@@ -38,8 +38,8 @@ $: setTimeout(() => focus?.focus?.(), 100);
38
38
  <Button tabindex="0" transparent small
39
39
  on:click={() => {
40
40
  $slashSelection?.();
41
- $tiptap.commands.insertContent({type: 'iframe', attrs: {src: iframe}})}
42
- }>{i18n('insert')}
41
+ $tiptap.chain().focus().insertContent({type: 'iframe', attrs: {src: iframe}}).insertContent('\n').run();
42
+ }}>{i18n('insert')}
43
43
  </Button>
44
44
  </footer>
45
45
  </div>
@@ -50,7 +50,7 @@ $: setTimeout(() => focus?.focus?.(), 100);
50
50
  <div class="title">Youtube</div>
51
51
  </header>
52
52
  <Input placeholder="url" fullWidth bind:value={iframe} bind:input={focus}
53
- on:submit={() => $tiptap.commands.insertVideoPlayer({url: iframe})}/>
53
+ on:submit={() => $tiptap.chain().focus().insertVideoPlayer({url: iframe}).insertContent('\n').run()}/>
54
54
  <footer>
55
55
  <Button tabindex="0" transparent small on:click={() => {
56
56
  iframe = ''
@@ -59,7 +59,7 @@ $: setTimeout(() => focus?.focus?.(), 100);
59
59
  </Button>
60
60
  <Button tabindex="0" transparent small on:click={() => {
61
61
  $slashSelection?.();
62
- $tiptap.commands.insertVideoPlayer({url: iframe});
62
+ $tiptap.chain().focus().insertVideoPlayer({url: iframe}).insertContent('\n').run();
63
63
  }}>{i18n('insert')}
64
64
  </Button>
65
65
  </footer>
@@ -135,7 +135,7 @@ main {
135
135
  font-size: 0.8em;
136
136
  font-weight: 300;
137
137
  color: var(--on-surface, #000);
138
- opacity: 0.8;
138
+ opacity: 0.7;
139
139
  }
140
140
 
141
141
  .list {
@@ -23,11 +23,13 @@ const san = (body) => sanitizeHtml(body, {
23
23
  },
24
24
  });
25
25
  export let body = '', editable = false, ref = null, options = {};
26
- export const imageUpload = fallbackUpload, style = '';
26
+ export let imageUpload = fallbackUpload, style = '';
27
+ export let blocks = [], placeholder = i18n('placeholder');
27
28
  const tiptap = setContext('editor', writable(null));
28
29
  let element, fullscreen = false, mounted = false, last = '';
29
30
  $: $tiptap && $tiptap.setEditable(editable);
30
31
  $: browser && (window.__image_uploader = imageUpload);
32
+ $: browser && (window.__tiptap_blocks = blocks);
31
33
  if (browser) {
32
34
  onMount(() => {
33
35
  body = last = san(body);
@@ -36,6 +38,7 @@ if (browser) {
36
38
  if (!mounted)
37
39
  return;
38
40
  ref = $tiptap = tt(element, body, {
41
+ placeholder,
39
42
  editable: editable,
40
43
  onTransaction: () => ref = $tiptap = $tiptap,
41
44
  ...options,
@@ -158,11 +161,16 @@ div > :global(div) {
158
161
  outline: none !important;
159
162
  }
160
163
  div > :global(div) :global(.ProseMirror) :global(p.is-editor-empty:first-child::before) {
161
- color: #adb5bd;
164
+ color: var(--on-surface, #000);
165
+ opacity: 0.7;
162
166
  content: attr(data-placeholder);
163
167
  float: left;
164
168
  height: 0;
165
169
  pointer-events: none;
170
+ transition: 0.2s opacity ease-in-out;
171
+ }
172
+ div > :global(div) :global(.ProseMirror-focused) :global(p.is-editor-empty:first-child::before) {
173
+ opacity: 0;
166
174
  }
167
175
  div > :global(div) :global(a) {
168
176
  cursor: pointer;
@@ -8,7 +8,9 @@ declare const __propDef: {
8
8
  ref?: null | undefined;
9
9
  options?: {} | undefined;
10
10
  imageUpload?: UploadFn | undefined;
11
- style?: "" | undefined;
11
+ style?: string | undefined;
12
+ blocks?: any[] | undefined;
13
+ placeholder?: any;
12
14
  };
13
15
  events: {
14
16
  [evt: string]: CustomEvent<any>;
@@ -21,7 +23,5 @@ export type TipTapProps = typeof __propDef.props;
21
23
  export type TipTapEvents = typeof __propDef.events;
22
24
  export type TipTapSlots = typeof __propDef.slots;
23
25
  export default class TipTap extends SvelteComponentTyped<TipTapProps, TipTapEvents, TipTapSlots> {
24
- get imageUpload(): UploadFn;
25
- get style(): "";
26
26
  }
27
27
  export {};
@@ -1,3 +1,3 @@
1
1
  import { Editor } from "@tiptap/core";
2
- declare const _default: (element: Element, content: string, { plugins, ...props }?: any) => Editor;
2
+ declare const _default: (element: Element, content: string, { placeholder, plugins, ...props }?: any) => Editor;
3
3
  export default _default;
@@ -23,9 +23,11 @@ import Iframe from "../plugin/iframe";
23
23
  // @ts-ignore
24
24
  import { MathInline, MathBlock } from "@seorii/prosemirror-math/tiptap";
25
25
  import Youtube from "../plugin/youtube";
26
+ import Placeholder from "@tiptap/extension-placeholder";
26
27
  import command from "../plugin/command/suggest";
27
28
  import emoji from "../plugin/command/emoji";
28
- export default (element, content, { plugins = [], ...props } = {}) => {
29
+ import i18n from "../i18n";
30
+ export default (element, content, { placeholder = i18n('placeholder'), plugins = [], ...props } = {}) => {
29
31
  const tt = new Editor({
30
32
  element, content, ...props,
31
33
  extensions: [
@@ -73,6 +75,7 @@ export default (element, content, { plugins = [], ...props } = {}) => {
73
75
  return ['code', mergeAttributes(HTMLAttributes, { class: 'inline' })];
74
76
  }
75
77
  }),
78
+ Placeholder.configure({ placeholder }),
76
79
  ...plugins,
77
80
  ],
78
81
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seorii/tiptap",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "svelte-kit sync && svelte-package",