@bendyline/squisq-editor-react 1.1.0 → 1.1.1
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/EditorContext.d.ts +6 -2
- package/dist/EditorContext.d.ts.map +1 -1
- package/dist/EditorContext.js +3 -1
- package/dist/EditorContext.js.map +1 -1
- package/dist/EditorShell.d.ts +11 -1
- package/dist/EditorShell.d.ts.map +1 -1
- package/dist/EditorShell.js +9 -7
- package/dist/EditorShell.js.map +1 -1
- package/dist/ImageNodeView.d.ts +15 -0
- package/dist/ImageNodeView.d.ts.map +1 -0
- package/dist/ImageNodeView.js +52 -0
- package/dist/ImageNodeView.js.map +1 -0
- package/dist/PreviewControls.d.ts +41 -0
- package/dist/PreviewControls.d.ts.map +1 -0
- package/dist/PreviewControls.js +201 -0
- package/dist/PreviewControls.js.map +1 -0
- package/dist/PreviewPanel.d.ts +7 -7
- package/dist/PreviewPanel.d.ts.map +1 -1
- package/dist/PreviewPanel.js +183 -199
- package/dist/PreviewPanel.js.map +1 -1
- package/dist/Toolbar.d.ts +8 -1
- package/dist/Toolbar.d.ts.map +1 -1
- package/dist/Toolbar.js +4 -12
- package/dist/Toolbar.js.map +1 -1
- package/dist/WysiwygEditor.d.ts.map +1 -1
- package/dist/WysiwygEditor.js +3 -1
- package/dist/WysiwygEditor.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/tiptapBridge.d.ts.map +1 -1
- package/dist/tiptapBridge.js +4 -5
- package/dist/tiptapBridge.js.map +1 -1
- package/package.json +5 -4
- package/src/EditorContext.tsx +8 -1
- package/src/EditorShell.tsx +71 -32
- package/src/ImageNodeView.tsx +70 -0
- package/src/PreviewControls.tsx +340 -0
- package/src/PreviewPanel.tsx +216 -287
- package/src/Toolbar.tsx +23 -6
- package/src/WysiwygEditor.tsx +3 -1
- package/src/index.ts +6 -0
- package/src/styles/editor.css +31 -8
- package/src/tiptapBridge.ts +5 -6
package/src/WysiwygEditor.tsx
CHANGED
|
@@ -21,6 +21,7 @@ import TaskList from '@tiptap/extension-task-list';
|
|
|
21
21
|
import TaskItem from '@tiptap/extension-task-item';
|
|
22
22
|
import Placeholder from '@tiptap/extension-placeholder';
|
|
23
23
|
import { HeadingWithTemplate } from './TemplateAnnotation';
|
|
24
|
+
import { ImageWithMediaProvider } from './ImageNodeView';
|
|
24
25
|
import { useEditorContext } from './EditorContext';
|
|
25
26
|
import { markdownToTiptap, tiptapToMarkdown } from './tiptapBridge';
|
|
26
27
|
|
|
@@ -73,6 +74,7 @@ export function WysiwygEditor({
|
|
|
73
74
|
TableHeader,
|
|
74
75
|
TaskList,
|
|
75
76
|
TaskItem.configure({ nested: true }),
|
|
77
|
+
ImageWithMediaProvider.configure({ inline: false }),
|
|
76
78
|
Placeholder.configure({ placeholder }),
|
|
77
79
|
],
|
|
78
80
|
content: markdownToTiptap(stripFrontmatter(markdownSource).body),
|
|
@@ -117,7 +119,7 @@ export function WysiwygEditor({
|
|
|
117
119
|
|
|
118
120
|
return (
|
|
119
121
|
<div
|
|
120
|
-
className={className}
|
|
122
|
+
className={`squisq-wysiwyg-container${className ? ` ${className}` : ''}`}
|
|
121
123
|
style={{ width: '100%', height: '100%', overflow: 'auto' }}
|
|
122
124
|
data-testid="wysiwyg-container"
|
|
123
125
|
>
|
package/src/index.ts
CHANGED
|
@@ -40,6 +40,12 @@ export type { WysiwygEditorProps } from './WysiwygEditor.js';
|
|
|
40
40
|
|
|
41
41
|
export { PreviewPanel } from './PreviewPanel.js';
|
|
42
42
|
export type { PreviewPanelProps } from './PreviewPanel.js';
|
|
43
|
+
export {
|
|
44
|
+
PreviewSettingsProvider,
|
|
45
|
+
PreviewToolbarControls,
|
|
46
|
+
usePreviewSettings,
|
|
47
|
+
} from './PreviewControls.js';
|
|
48
|
+
export type { PreviewSettings } from './PreviewControls.js';
|
|
43
49
|
|
|
44
50
|
// Chrome (for custom layouts)
|
|
45
51
|
export { ViewSwitcher } from './ViewSwitcher.js';
|
package/src/styles/editor.css
CHANGED
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
display: flex;
|
|
59
59
|
align-items: center;
|
|
60
60
|
flex-wrap: wrap;
|
|
61
|
-
padding:
|
|
61
|
+
padding: 0 12px 0 0;
|
|
62
62
|
gap: 2px;
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -67,7 +67,12 @@
|
|
|
67
67
|
.squisq-toolbar-view-tabs {
|
|
68
68
|
display: flex;
|
|
69
69
|
gap: 0;
|
|
70
|
-
margin-right:
|
|
70
|
+
margin-right: 12px;
|
|
71
|
+
padding: 0 16px 0 12px;
|
|
72
|
+
background: rgba(0, 0, 0, 0.07);
|
|
73
|
+
border-right: 1px solid rgba(0, 0, 0, 0.12);
|
|
74
|
+
align-self: stretch;
|
|
75
|
+
align-items: center;
|
|
71
76
|
}
|
|
72
77
|
|
|
73
78
|
.squisq-toolbar-actions {
|
|
@@ -80,7 +85,7 @@
|
|
|
80
85
|
padding: 4px 14px;
|
|
81
86
|
border: none;
|
|
82
87
|
background: transparent;
|
|
83
|
-
color: #
|
|
88
|
+
color: #4b5563;
|
|
84
89
|
cursor: pointer;
|
|
85
90
|
font-size: 13px;
|
|
86
91
|
font-weight: 500;
|
|
@@ -91,11 +96,12 @@
|
|
|
91
96
|
}
|
|
92
97
|
|
|
93
98
|
.squisq-toolbar-view-tab:hover {
|
|
94
|
-
color: #
|
|
99
|
+
color: #111827;
|
|
95
100
|
}
|
|
96
101
|
|
|
97
102
|
.squisq-toolbar-view-tab--active {
|
|
98
|
-
color: #
|
|
103
|
+
color: #1d4ed8;
|
|
104
|
+
font-weight: 600;
|
|
99
105
|
border-bottom-color: #2563eb;
|
|
100
106
|
}
|
|
101
107
|
|
|
@@ -237,12 +243,18 @@
|
|
|
237
243
|
|
|
238
244
|
/* ─── WYSIWYG Editor ─────────────────────────────────── */
|
|
239
245
|
|
|
246
|
+
.squisq-wysiwyg-container {
|
|
247
|
+
background: #eeecea;
|
|
248
|
+
}
|
|
249
|
+
|
|
240
250
|
.squisq-wysiwyg-editor {
|
|
241
251
|
padding: 16px 24px;
|
|
242
252
|
max-width: 800px;
|
|
243
253
|
margin: 0 auto;
|
|
244
254
|
outline: none;
|
|
245
255
|
min-height: 100%;
|
|
256
|
+
background: #fff;
|
|
257
|
+
box-shadow: 0 0 8px rgba(0, 0, 0, 0.06);
|
|
246
258
|
}
|
|
247
259
|
|
|
248
260
|
.squisq-wysiwyg-editor h1 {
|
|
@@ -437,17 +449,22 @@
|
|
|
437
449
|
/* no border-top — sits directly in header */
|
|
438
450
|
}
|
|
439
451
|
|
|
452
|
+
.squisq-editor-shell[data-theme='dark'] .squisq-toolbar-view-tabs {
|
|
453
|
+
background: rgba(255, 255, 255, 0.08);
|
|
454
|
+
border-right-color: rgba(255, 255, 255, 0.15);
|
|
455
|
+
}
|
|
456
|
+
|
|
440
457
|
/* View tabs (dark) */
|
|
441
458
|
.squisq-editor-shell[data-theme='dark'] .squisq-toolbar-view-tab {
|
|
442
|
-
color: #
|
|
459
|
+
color: #d1d5db;
|
|
443
460
|
}
|
|
444
461
|
|
|
445
462
|
.squisq-editor-shell[data-theme='dark'] .squisq-toolbar-view-tab:hover {
|
|
446
|
-
color: #
|
|
463
|
+
color: #f9fafb;
|
|
447
464
|
}
|
|
448
465
|
|
|
449
466
|
.squisq-editor-shell[data-theme='dark'] .squisq-toolbar-view-tab--active {
|
|
450
|
-
color: #
|
|
467
|
+
color: #93c5fd;
|
|
451
468
|
border-bottom-color: #60a5fa;
|
|
452
469
|
}
|
|
453
470
|
|
|
@@ -516,8 +533,14 @@
|
|
|
516
533
|
}
|
|
517
534
|
|
|
518
535
|
/* WYSIWYG Editor */
|
|
536
|
+
.squisq-editor-shell[data-theme='dark'] .squisq-wysiwyg-container {
|
|
537
|
+
background: #0f1219;
|
|
538
|
+
}
|
|
539
|
+
|
|
519
540
|
.squisq-editor-shell[data-theme='dark'] .squisq-wysiwyg-editor {
|
|
520
541
|
color: #e5e7eb;
|
|
542
|
+
background: #111827;
|
|
543
|
+
box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
|
|
521
544
|
}
|
|
522
545
|
|
|
523
546
|
.squisq-editor-shell[data-theme='dark'] .squisq-wysiwyg-editor blockquote {
|
package/src/tiptapBridge.ts
CHANGED
|
@@ -39,9 +39,8 @@ const RE_STRIP_TAGS = /<[^>]+>/g;
|
|
|
39
39
|
export function markdownToTiptap(markdown: string): string {
|
|
40
40
|
if (!markdown.trim()) return '<p></p>';
|
|
41
41
|
|
|
42
|
-
//
|
|
43
|
-
|
|
44
|
-
const html = markdown;
|
|
42
|
+
// Normalize line endings — content from zip archives may use \r\n
|
|
43
|
+
const html = markdown.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
45
44
|
|
|
46
45
|
// Process blocks line by line for accurate conversion
|
|
47
46
|
const lines = html.split('\n');
|
|
@@ -384,12 +383,12 @@ function inlineToHtml(text: string): string {
|
|
|
384
383
|
// Inline code: `text`
|
|
385
384
|
result = result.replace(RE_INLINE_CODE, '<code>$1</code>');
|
|
386
385
|
|
|
386
|
+
// Images first:  — must be before links so the `!` prefix is consumed
|
|
387
|
+
result = result.replace(RE_IMAGE, '<img alt="$1" src="$2">');
|
|
388
|
+
|
|
387
389
|
// Links: [text](url)
|
|
388
390
|
result = result.replace(RE_LINK, '<a href="$2">$1</a>');
|
|
389
391
|
|
|
390
|
-
// Images: 
|
|
391
|
-
result = result.replace(RE_IMAGE, '<img alt="$1" src="$2">');
|
|
392
|
-
|
|
393
392
|
return result;
|
|
394
393
|
}
|
|
395
394
|
|