@teriusu/rich-editor 0.5.2 → 0.5.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.
@@ -2,7 +2,7 @@ export declare function sanitizeHtml(html: string): string;
2
2
  /**
3
3
  * 레거시 TipTap v2 커스텀 태그를 현재 형식으로 변환.
4
4
  * 에디터 content 로드 전, 또는 게시물 렌더링 전에 호출.
5
- * tiptap-file → data-file-id, tiptap-midibus → iframe으로 변환.
5
+ * tiptap-file → data-file-id 변환. tiptap-midibus는 호스트 앱이 처리.
6
6
  */
7
7
  export declare function transformLegacyHtml(html: string): string;
8
8
  export declare function stripHtmlToExcerpt(html: string, maxLen?: number): string;
@@ -1 +1 @@
1
- {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../src/utils/sanitize.ts"],"names":[],"mappings":"AAyBA,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAcjD;AA0BD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAyExD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,SAAM,GAAG,MAAM,CAWrE"}
1
+ {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../src/utils/sanitize.ts"],"names":[],"mappings":"AA2BA,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAcjD;AA0BD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA4DxD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,SAAM,GAAG,MAAM,CAWrE"}
@@ -5,6 +5,7 @@ const ALLOWED_TAGS = new Set([
5
5
  "blockquote", "pre", "code", "img", "figure", "figcaption",
6
6
  "table", "colgroup", "col", "thead", "tbody", "tr", "th", "td",
7
7
  "span", "div", "hr", "sub", "sup",
8
+ "tiptap-midibus",
8
9
  ]);
9
10
  const ALLOWED_ATTRS = {
10
11
  a: new Set(["href", "title", "target", "rel"]),
@@ -16,6 +17,7 @@ const ALLOWED_ATTRS = {
16
17
  div: new Set(["data-pdf-src", "data-pdf-name"]),
17
18
  pre: new Set(["class"]),
18
19
  code: new Set(["class"]),
20
+ "tiptap-midibus": new Set(["id", "start", "uuid", "width", "height"]),
19
21
  "*": new Set(["class", "id"]),
20
22
  };
21
23
  const SAFE_URL_PATTERN = /^(?:https?:\/\/|\/[\w])/i;
@@ -58,7 +60,7 @@ function sanitizeAttributes(tag, attrString) {
58
60
  /**
59
61
  * 레거시 TipTap v2 커스텀 태그를 현재 형식으로 변환.
60
62
  * 에디터 content 로드 전, 또는 게시물 렌더링 전에 호출.
61
- * tiptap-file → data-file-id, tiptap-midibus → iframe으로 변환.
63
+ * tiptap-file → data-file-id 변환. tiptap-midibus는 호스트 앱이 처리.
62
64
  */
63
65
  export function transformLegacyHtml(html) {
64
66
  if (!html)
@@ -87,13 +89,6 @@ export function transformLegacyHtml(html) {
87
89
  const name = text.trim() || "\uD30C\uC77C";
88
90
  return `<div data-file-id="${id}" data-file-name="${name}"></div>`;
89
91
  })
90
- // <tiptap-midibus id="X" ...></tiptap-midibus> + 뒤따르는 iframe-wrapper 제거
91
- // → <div data-youtube-video><iframe src="https://play.mbus.tv/v1/hls/X" allowfullscreen></iframe></div>
92
- .replace(/<tiptap-midibus\s+id="([^"]*)"[^>]*>(?:<\/tiptap-midibus>)?/gi, (_match, id) => {
93
- return `<div data-youtube-video=""><iframe src="https://play.mbus.tv/v1/hls/${id}" width="100%" height="400" frameborder="0" allowfullscreen="true"></iframe></div>`;
94
- })
95
- // 미디버스 뒤에 따라오는 빈 iframe-wrapper 제거
96
- .replace(/<div\s+class="iframe-wrapper"[^>]*>[\s\S]*?<\/div>/gi, "")
97
92
  // <div class="tiptap-columns"> → <div data-type="columns">
98
93
  .replace(/<div\s+class="tiptap-columns">/gi, '<div data-type="columns">')
99
94
  // <div class="tiptap-column"> → <div data-type="column">
@@ -22,13 +22,11 @@ describe('transformLegacyHtml', () => {
22
22
  const result = transformLegacyHtml(input);
23
23
  expect(result).toContain('data-file-name="파일"');
24
24
  });
25
- it('converts <tiptap-midibus id="X"> to iframe', () => {
25
+ it('preserves <tiptap-midibus> for host app custom extension', () => {
26
26
  const input = '<tiptap-midibus id="vid123"></tiptap-midibus>';
27
27
  const result = transformLegacyHtml(input);
28
- expect(result).toContain('data-youtube-video');
29
- expect(result).toContain('https://play.mbus.tv/v1/hls/vid123');
30
- expect(result).toContain('iframe');
31
- expect(result).not.toContain('tiptap-midibus');
28
+ expect(result).toContain('tiptap-midibus');
29
+ expect(result).toContain('id="vid123"');
32
30
  });
33
31
  it('converts <tiptap-collapsable title="X"> to <details><summary>', () => {
34
32
  const input = '<tiptap-collapsable title="Click me">Hidden content</tiptap-collapsable>';
@@ -73,10 +71,10 @@ describe('transformLegacyHtml', () => {
73
71
  expect(result).toContain('Before');
74
72
  expect(result).toContain('After');
75
73
  });
76
- it('removes iframe-wrapper divs after midibus conversion', () => {
74
+ it('preserves midibus with trailing iframe-wrapper intact', () => {
77
75
  const input = '<tiptap-midibus id="vid"></tiptap-midibus><div class="iframe-wrapper"><iframe></iframe></div>';
78
76
  const result = transformLegacyHtml(input);
79
- expect(result).not.toContain('iframe-wrapper');
77
+ expect(result).toContain('tiptap-midibus');
80
78
  });
81
79
  it('parses margin-left: 40px via Indent extension (not transformLegacyHtml itself)', () => {
82
80
  // transformLegacyHtml does NOT handle margin-left; the Indent extension does.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teriusu/rich-editor",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "TipTap 기반 Notion-style 리치 텍스트 에디터 (Svelte)",
5
5
  "type": "module",
6
6
  "svelte": "./dist/index.js",