@seorii/tiptap 0.2.3 → 0.2.5

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.
@@ -1,5 +1,5 @@
1
1
  export default {
2
- target: ['ko'],
2
+ target: ['ko', 'ko-KR'],
3
3
  lang: 'ko',
4
4
  country: 'KR',
5
5
  text: '텍스트',
@@ -0,0 +1,21 @@
1
+ import { Node } from '@tiptap/core';
2
+ export interface EmbedOptions {
3
+ allowFullscreen: boolean;
4
+ type: string;
5
+ HTMLAttributes: {
6
+ [key: string]: any;
7
+ };
8
+ }
9
+ declare module '@tiptap/core' {
10
+ interface Commands<ReturnType> {
11
+ embed: {
12
+ setEmbed: (options: {
13
+ src: string;
14
+ type: string;
15
+ width: string;
16
+ }) => ReturnType;
17
+ };
18
+ }
19
+ }
20
+ declare const _default: Node<EmbedOptions, any>;
21
+ export default _default;
@@ -0,0 +1,46 @@
1
+ import { mergeAttributes, Node } from '@tiptap/core';
2
+ export default Node.create({
3
+ name: 'embed',
4
+ group: 'block',
5
+ atom: true,
6
+ addOptions() {
7
+ return {
8
+ allowFullscreen: true,
9
+ HTMLAttributes: {
10
+ class: 'embed-wrapper',
11
+ },
12
+ };
13
+ },
14
+ addAttributes() {
15
+ return {
16
+ src: { default: null },
17
+ frameborder: { default: 0 },
18
+ allowfullscreen: {
19
+ default: this.options.allowFullscreen,
20
+ parseHTML: () => this.options.allowFullscreen,
21
+ },
22
+ width: { default: '100%' },
23
+ height: { default: '800px' },
24
+ type: { default: '' }
25
+ };
26
+ },
27
+ parseHTML() {
28
+ return [{
29
+ tag: 'embed',
30
+ }];
31
+ },
32
+ renderHTML({ HTMLAttributes }) {
33
+ return ['div', this.options.HTMLAttributes, ['embed', mergeAttributes(HTMLAttributes, { credentialless: true })]];
34
+ },
35
+ addCommands() {
36
+ return {
37
+ setEmbed: (options) => ({ tr, dispatch }) => {
38
+ const { selection } = tr;
39
+ const node = this.type.create(options);
40
+ if (dispatch)
41
+ tr.replaceRangeWith(selection.from, selection.to, node);
42
+ return true;
43
+ },
44
+ };
45
+ },
46
+ });
@@ -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.chain().focus().insertContent({type: 'iframe', attrs: {src: iframe}}).insertContent('\n').run()}/>
31
+ on:submit={() => $tiptap.chain().focus().insertContent([{type: 'iframe', attrs: {src: iframe}}, {type: 'paragraph'}]).run()}/>
32
32
  <footer>
33
33
  <Button tabindex="0" transparent small on:click={() => {
34
34
  iframe = ''
@@ -38,7 +38,7 @@ $: setTimeout(() => focus?.focus?.(), 100);
38
38
  <Button tabindex="0" transparent small
39
39
  on:click={() => {
40
40
  $slashSelection?.();
41
- $tiptap.chain().focus().insertContent({type: 'iframe', attrs: {src: iframe}}).insertContent('\n').run();
41
+ $tiptap.chain().focus().insertContent([{type: 'iframe', attrs: {src: iframe}}, {type: 'paragraph'}]).run();
42
42
  }}>{i18n('insert')}
43
43
  </Button>
44
44
  </footer>
@@ -10,7 +10,7 @@ import { slashItems, slashProps, slashVisible } from "../plugin/command/stores";
10
10
  import i18n from "../i18n";
11
11
  import { fallbackUpload } from "../plugin/image/dragdrop";
12
12
  const san = (body) => sanitizeHtml(body, {
13
- allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img', 'math-inline', 'math-node', 'iframe', 'tiptap-file', 'lite-youtube', 'blockquote']),
13
+ allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img', 'math-inline', 'math-node', 'iframe', 'tiptap-file', 'lite-youtube', 'blockquote', 'embed']),
14
14
  allowedStyles: '*', allowedAttributes: {
15
15
  '*': ['style', 'class'],
16
16
  a: ['href', 'name', 'target'],
@@ -20,6 +20,7 @@ const san = (body) => sanitizeHtml(body, {
20
20
  td: ['colwidth', 'colspan', 'rowspan'],
21
21
  'tiptap-file': ['id'],
22
22
  'lite-youtube': ['videoid', 'params', 'nocookie', 'title', 'provider'],
23
+ embed: ['src', 'type', 'frameborder', 'allowfullscreen']
23
24
  },
24
25
  });
25
26
  export let body = '', editable = false, ref = null, options = {};
@@ -20,6 +20,7 @@ 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
+ import Embed from "../plugin/embed";
23
24
  // @ts-ignore
24
25
  import { MathInline, MathBlock } from "@seorii/prosemirror-math/tiptap";
25
26
  import Youtube from "../plugin/youtube";
@@ -70,6 +71,7 @@ export default (element, content, { placeholder = i18n('placeholder'), plugins =
70
71
  Color,
71
72
  TextStyle,
72
73
  Iframe,
74
+ Embed,
73
75
  Code.extend({
74
76
  renderHTML({ HTMLAttributes }) {
75
77
  return ['code', mergeAttributes(HTMLAttributes, { class: 'inline' })];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seorii/tiptap",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "svelte-kit sync && svelte-package",