notra-editor 0.2.0 → 0.4.0
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/README.md +4 -8
- package/dist/components/blockquote-button/blockquote-button.cjs +91 -0
- package/dist/components/blockquote-button/blockquote-button.cjs.map +1 -0
- package/dist/components/blockquote-button/blockquote-button.d.cts +9 -0
- package/dist/components/blockquote-button/blockquote-button.d.ts +9 -0
- package/dist/components/blockquote-button/blockquote-button.mjs +67 -0
- package/dist/components/blockquote-button/blockquote-button.mjs.map +1 -0
- package/dist/components/code-block-button/code-block-button.cjs +91 -0
- package/dist/components/code-block-button/code-block-button.cjs.map +1 -0
- package/dist/components/code-block-button/code-block-button.d.cts +9 -0
- package/dist/components/code-block-button/code-block-button.d.ts +9 -0
- package/dist/components/code-block-button/code-block-button.mjs +67 -0
- package/dist/components/code-block-button/code-block-button.mjs.map +1 -0
- package/dist/components/code-block-view.cjs +39 -0
- package/dist/components/code-block-view.cjs.map +1 -0
- package/dist/components/code-block-view.d.cts +12 -0
- package/dist/components/code-block-view.d.ts +12 -0
- package/dist/components/code-block-view.mjs +17 -0
- package/dist/components/code-block-view.mjs.map +1 -0
- package/dist/components/copy-button.cjs +49 -0
- package/dist/components/copy-button.cjs.map +1 -0
- package/dist/components/copy-button.d.cts +9 -0
- package/dist/components/copy-button.d.ts +9 -0
- package/dist/components/copy-button.mjs +25 -0
- package/dist/components/copy-button.mjs.map +1 -0
- package/dist/components/heading-dropdown-menu/heading-dropdown-menu.cjs +67 -0
- package/dist/components/heading-dropdown-menu/heading-dropdown-menu.cjs.map +1 -0
- package/dist/components/heading-dropdown-menu/heading-dropdown-menu.d.cts +17 -0
- package/dist/components/heading-dropdown-menu/heading-dropdown-menu.d.ts +17 -0
- package/dist/components/heading-dropdown-menu/heading-dropdown-menu.mjs +51 -0
- package/dist/components/heading-dropdown-menu/heading-dropdown-menu.mjs.map +1 -0
- package/dist/components/heading-dropdown-menu/heading-menu-item.cjs +56 -0
- package/dist/components/heading-dropdown-menu/heading-menu-item.cjs.map +1 -0
- package/dist/components/heading-dropdown-menu/heading-menu-item.d.cts +12 -0
- package/dist/components/heading-dropdown-menu/heading-menu-item.d.ts +12 -0
- package/dist/components/heading-dropdown-menu/heading-menu-item.mjs +32 -0
- package/dist/components/heading-dropdown-menu/heading-menu-item.mjs.map +1 -0
- package/dist/components/heading-dropdown-menu/use-heading.cjs +109 -0
- package/dist/components/heading-dropdown-menu/use-heading.cjs.map +1 -0
- package/dist/components/heading-dropdown-menu/use-heading.d.cts +19 -0
- package/dist/components/heading-dropdown-menu/use-heading.d.ts +19 -0
- package/dist/components/heading-dropdown-menu/use-heading.mjs +83 -0
- package/dist/components/heading-dropdown-menu/use-heading.mjs.map +1 -0
- package/dist/components/link-popover/link-popover.cjs +148 -0
- package/dist/components/link-popover/link-popover.cjs.map +1 -0
- package/dist/components/link-popover/link-popover.d.cts +9 -0
- package/dist/components/link-popover/link-popover.d.ts +9 -0
- package/dist/components/link-popover/link-popover.mjs +129 -0
- package/dist/components/link-popover/link-popover.mjs.map +1 -0
- package/dist/components/link-popover/use-link-popover.cjs +71 -0
- package/dist/components/link-popover/use-link-popover.cjs.map +1 -0
- package/dist/components/link-popover/use-link-popover.d.cts +17 -0
- package/dist/components/link-popover/use-link-popover.d.ts +17 -0
- package/dist/components/link-popover/use-link-popover.mjs +47 -0
- package/dist/components/link-popover/use-link-popover.mjs.map +1 -0
- package/dist/components/list-dropdown-menu/list-dropdown-menu.cjs +73 -0
- package/dist/components/list-dropdown-menu/list-dropdown-menu.cjs.map +1 -0
- package/dist/components/list-dropdown-menu/list-dropdown-menu.d.cts +17 -0
- package/dist/components/list-dropdown-menu/list-dropdown-menu.d.ts +17 -0
- package/dist/components/list-dropdown-menu/list-dropdown-menu.mjs +57 -0
- package/dist/components/list-dropdown-menu/list-dropdown-menu.mjs.map +1 -0
- package/dist/components/list-dropdown-menu/list-menu-item.cjs +56 -0
- package/dist/components/list-dropdown-menu/list-menu-item.cjs.map +1 -0
- package/dist/components/list-dropdown-menu/list-menu-item.d.cts +12 -0
- package/dist/components/list-dropdown-menu/list-menu-item.d.ts +12 -0
- package/dist/components/list-dropdown-menu/list-menu-item.mjs +32 -0
- package/dist/components/list-dropdown-menu/list-menu-item.mjs.map +1 -0
- package/dist/components/list-dropdown-menu/use-list.cjs +111 -0
- package/dist/components/list-dropdown-menu/use-list.cjs.map +1 -0
- package/dist/components/list-dropdown-menu/use-list.d.cts +19 -0
- package/dist/components/list-dropdown-menu/use-list.d.ts +19 -0
- package/dist/components/list-dropdown-menu/use-list.mjs +85 -0
- package/dist/components/list-dropdown-menu/use-list.mjs.map +1 -0
- package/dist/components/mark-button/mark-button.cjs +72 -0
- package/dist/components/mark-button/mark-button.cjs.map +1 -0
- package/dist/components/mark-button/mark-button.d.cts +12 -0
- package/dist/components/mark-button/mark-button.d.ts +12 -0
- package/dist/components/mark-button/mark-button.mjs +48 -0
- package/dist/components/mark-button/mark-button.mjs.map +1 -0
- package/dist/components/mark-button/use-mark.cjs +71 -0
- package/dist/components/mark-button/use-mark.cjs.map +1 -0
- package/dist/components/mark-button/use-mark.d.cts +17 -0
- package/dist/components/mark-button/use-mark.d.ts +17 -0
- package/dist/components/mark-button/use-mark.mjs +47 -0
- package/dist/components/mark-button/use-mark.mjs.map +1 -0
- package/dist/components/toolbar/toolbar.cjs +77 -0
- package/dist/components/toolbar/toolbar.cjs.map +1 -0
- package/dist/components/toolbar/toolbar.d.cts +14 -0
- package/dist/components/toolbar/toolbar.d.ts +14 -0
- package/dist/components/toolbar/toolbar.mjs +51 -0
- package/dist/components/toolbar/toolbar.mjs.map +1 -0
- package/dist/components/ui/button.cjs +82 -0
- package/dist/components/ui/button.cjs.map +1 -0
- package/dist/components/ui/button.d.cts +14 -0
- package/dist/components/ui/button.d.ts +14 -0
- package/dist/components/ui/button.mjs +57 -0
- package/dist/components/ui/button.mjs.map +1 -0
- package/dist/components/ui/dropdown-menu.cjs +290 -0
- package/dist/components/ui/dropdown-menu.cjs.map +1 -0
- package/dist/components/ui/dropdown-menu.d.cts +32 -0
- package/dist/components/ui/dropdown-menu.d.ts +32 -0
- package/dist/components/ui/dropdown-menu.mjs +252 -0
- package/dist/components/ui/dropdown-menu.mjs.map +1 -0
- package/dist/components/ui/input.cjs +44 -0
- package/dist/components/ui/input.cjs.map +1 -0
- package/dist/components/ui/input.d.cts +6 -0
- package/dist/components/ui/input.d.ts +6 -0
- package/dist/components/ui/input.mjs +20 -0
- package/dist/components/ui/input.mjs.map +1 -0
- package/dist/components/ui/popover.cjs +72 -0
- package/dist/components/ui/popover.cjs.map +1 -0
- package/dist/components/ui/popover.d.cts +10 -0
- package/dist/components/ui/popover.d.ts +10 -0
- package/dist/components/ui/popover.mjs +45 -0
- package/dist/components/ui/popover.mjs.map +1 -0
- package/dist/components/ui/separator.cjs +51 -0
- package/dist/components/ui/separator.cjs.map +1 -0
- package/dist/components/ui/separator.d.cts +7 -0
- package/dist/components/ui/separator.d.ts +7 -0
- package/dist/components/ui/separator.mjs +27 -0
- package/dist/components/ui/separator.mjs.map +1 -0
- package/dist/components/ui/spacer.cjs +32 -0
- package/dist/components/ui/spacer.cjs.map +1 -0
- package/dist/components/ui/spacer.d.cts +5 -0
- package/dist/components/ui/spacer.d.ts +5 -0
- package/dist/components/ui/spacer.mjs +8 -0
- package/dist/components/ui/spacer.mjs.map +1 -0
- package/dist/components/undo-redo-button/undo-redo-button.cjs +63 -0
- package/dist/components/undo-redo-button/undo-redo-button.cjs.map +1 -0
- package/dist/components/undo-redo-button/undo-redo-button.d.cts +12 -0
- package/dist/components/undo-redo-button/undo-redo-button.d.ts +12 -0
- package/dist/components/undo-redo-button/undo-redo-button.mjs +39 -0
- package/dist/components/undo-redo-button/undo-redo-button.mjs.map +1 -0
- package/dist/components/undo-redo-button/use-undo-redo.cjs +68 -0
- package/dist/components/undo-redo-button/use-undo-redo.cjs.map +1 -0
- package/dist/components/undo-redo-button/use-undo-redo.d.cts +17 -0
- package/dist/components/undo-redo-button/use-undo-redo.d.ts +17 -0
- package/dist/components/undo-redo-button/use-undo-redo.mjs +44 -0
- package/dist/components/undo-redo-button/use-undo-redo.mjs.map +1 -0
- package/dist/extensions/code-block.cjs +46 -0
- package/dist/extensions/code-block.cjs.map +1 -0
- package/dist/extensions/code-block.d.cts +6 -0
- package/dist/extensions/code-block.d.ts +6 -0
- package/dist/extensions/code-block.mjs +12 -0
- package/dist/extensions/code-block.mjs.map +1 -0
- package/dist/extensions/editor.cjs +53 -0
- package/dist/extensions/editor.cjs.map +1 -0
- package/dist/extensions/editor.d.cts +9 -0
- package/dist/extensions/editor.d.ts +9 -0
- package/dist/extensions/editor.mjs +19 -0
- package/dist/extensions/editor.mjs.map +1 -0
- package/dist/extensions/index.cjs +32 -0
- package/dist/extensions/index.cjs.map +1 -0
- package/dist/extensions/index.d.cts +7 -0
- package/dist/extensions/index.d.ts +7 -0
- package/dist/extensions/index.mjs +7 -0
- package/dist/extensions/index.mjs.map +1 -0
- package/dist/extensions/shared.cjs +64 -0
- package/dist/extensions/shared.cjs.map +1 -0
- package/dist/extensions/shared.d.cts +8 -0
- package/dist/extensions/shared.d.ts +8 -0
- package/dist/extensions/shared.mjs +29 -0
- package/dist/extensions/shared.mjs.map +1 -0
- package/dist/hooks/use-copy-to-clipboard.cjs +50 -0
- package/dist/hooks/use-copy-to-clipboard.cjs.map +1 -0
- package/dist/hooks/use-copy-to-clipboard.d.cts +10 -0
- package/dist/hooks/use-copy-to-clipboard.d.ts +10 -0
- package/dist/hooks/use-copy-to-clipboard.mjs +26 -0
- package/dist/hooks/use-copy-to-clipboard.mjs.map +1 -0
- package/dist/hooks/use-markdown-editor.cjs +80 -0
- package/dist/hooks/use-markdown-editor.cjs.map +1 -0
- package/dist/hooks/use-markdown-editor.d.cts +13 -0
- package/dist/hooks/use-markdown-editor.d.ts +13 -0
- package/dist/hooks/use-markdown-editor.mjs +56 -0
- package/dist/hooks/use-markdown-editor.mjs.map +1 -0
- package/dist/icons/redo-icon.cjs +54 -0
- package/dist/icons/redo-icon.cjs.map +1 -0
- package/dist/icons/redo-icon.d.cts +7 -0
- package/dist/icons/redo-icon.d.ts +7 -0
- package/dist/icons/redo-icon.mjs +30 -0
- package/dist/icons/redo-icon.mjs.map +1 -0
- package/dist/icons/undo-icon.cjs +54 -0
- package/dist/icons/undo-icon.cjs.map +1 -0
- package/dist/icons/undo-icon.d.cts +7 -0
- package/dist/icons/undo-icon.d.ts +7 -0
- package/dist/icons/undo-icon.mjs +30 -0
- package/dist/icons/undo-icon.mjs.map +1 -0
- package/dist/index.cjs +25 -2127
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -110
- package/dist/index.d.ts +22 -110
- package/dist/index.mjs +16 -2098
- package/dist/index.mjs.map +1 -1
- package/dist/lib/utils.cjs +33 -0
- package/dist/lib/utils.cjs.map +1 -0
- package/dist/lib/utils.d.cts +5 -0
- package/dist/lib/utils.d.ts +5 -0
- package/dist/lib/utils.mjs +9 -0
- package/dist/lib/utils.mjs.map +1 -0
- package/dist/notra-editor.cjs +88 -0
- package/dist/notra-editor.cjs.map +1 -0
- package/dist/notra-editor.d.cts +17 -0
- package/dist/notra-editor.d.ts +17 -0
- package/dist/notra-editor.mjs +68 -0
- package/dist/notra-editor.mjs.map +1 -0
- package/dist/notra-reader.cjs +47 -0
- package/dist/notra-reader.cjs.map +1 -0
- package/dist/notra-reader.d.cts +11 -0
- package/dist/notra-reader.d.ts +11 -0
- package/dist/notra-reader.mjs +23 -0
- package/dist/notra-reader.mjs.map +1 -0
- package/dist/styles/globals.css +1170 -0
- package/dist/themes/default/editor.css +2 -116
- package/dist/themes/default/reader.css +2 -0
- package/dist/utils/markdown-to-json.cjs +50 -0
- package/dist/utils/markdown-to-json.cjs.map +1 -0
- package/dist/utils/markdown-to-json.d.cts +7 -0
- package/dist/utils/markdown-to-json.d.ts +7 -0
- package/dist/utils/markdown-to-json.mjs +26 -0
- package/dist/utils/markdown-to-json.mjs.map +1 -0
- package/package.json +18 -5
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
@import './shared.css';
|
|
2
|
+
|
|
1
3
|
/* =====================
|
|
2
4
|
Editor-specific Variables
|
|
3
5
|
===================== */
|
|
@@ -228,13 +230,6 @@
|
|
|
228
230
|
outline: none;
|
|
229
231
|
}
|
|
230
232
|
|
|
231
|
-
.notra-editor .tiptap-button .tiptap-button-icon {
|
|
232
|
-
width: 1rem;
|
|
233
|
-
height: 1rem;
|
|
234
|
-
flex-shrink: 0;
|
|
235
|
-
color: inherit;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
233
|
.notra-editor .tiptap-button:hover:not([disabled]) {
|
|
239
234
|
background-color: var(--tt-button-hover-bg-color);
|
|
240
235
|
color: var(--tt-button-hover-icon-color);
|
|
@@ -261,19 +256,6 @@
|
|
|
261
256
|
/* Dropdown menu */
|
|
262
257
|
--tt-dropdown-menu-bg-color: var(--white);
|
|
263
258
|
--tt-dropdown-menu-text-color: var(--tt-gray-light-a-600);
|
|
264
|
-
|
|
265
|
-
/* Popover */
|
|
266
|
-
--tt-popover-bg-color: var(--white);
|
|
267
|
-
--tt-popover-border-color: var(--tt-gray-light-a-100);
|
|
268
|
-
|
|
269
|
-
/* Card */
|
|
270
|
-
--tiptap-card-bg-color: var(--white);
|
|
271
|
-
--tiptap-card-border-color: var(--tt-gray-light-a-100);
|
|
272
|
-
|
|
273
|
-
/* Input */
|
|
274
|
-
--tt-input-placeholder: var(--tt-gray-light-a-400);
|
|
275
|
-
--tt-input-border: var(--tt-gray-light-a-200);
|
|
276
|
-
--tt-input-border-focus: var(--tt-gray-light-a-300);
|
|
277
259
|
}
|
|
278
260
|
|
|
279
261
|
/* =====================
|
|
@@ -332,99 +314,3 @@
|
|
|
332
314
|
transform: translateX(-50%) scale(1) translateY(0);
|
|
333
315
|
}
|
|
334
316
|
}
|
|
335
|
-
|
|
336
|
-
/* =====================
|
|
337
|
-
Popover
|
|
338
|
-
===================== */
|
|
339
|
-
.notra-editor .tiptap-popover-content {
|
|
340
|
-
z-index: 9999;
|
|
341
|
-
transform: translateX(-50%);
|
|
342
|
-
animation: popover-in 150ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
@keyframes popover-in {
|
|
346
|
-
from {
|
|
347
|
-
opacity: 0;
|
|
348
|
-
transform: translateX(-50%) scale(0.95) translateY(-0.25rem);
|
|
349
|
-
}
|
|
350
|
-
to {
|
|
351
|
-
opacity: 1;
|
|
352
|
-
transform: translateX(-50%) scale(1) translateY(0);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
/* =====================
|
|
357
|
-
Card
|
|
358
|
-
===================== */
|
|
359
|
-
.notra-editor .tiptap-card {
|
|
360
|
-
display: flex;
|
|
361
|
-
flex-direction: column;
|
|
362
|
-
border-radius: calc(0.375rem + var(--tt-radius-lg));
|
|
363
|
-
box-shadow: var(--tt-shadow-elevated-md);
|
|
364
|
-
background-color: var(--tiptap-card-bg-color);
|
|
365
|
-
border: 1px solid var(--tiptap-card-border-color);
|
|
366
|
-
outline: none;
|
|
367
|
-
min-width: 0;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
.notra-editor .tiptap-card-body {
|
|
371
|
-
padding: 0.375rem;
|
|
372
|
-
flex: 1 1 auto;
|
|
373
|
-
overflow-y: auto;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
.notra-editor .tiptap-card-item-group {
|
|
377
|
-
position: relative;
|
|
378
|
-
display: flex;
|
|
379
|
-
vertical-align: middle;
|
|
380
|
-
min-width: max-content;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
.notra-editor .tiptap-card-item-group[data-orientation='vertical'] {
|
|
384
|
-
flex-direction: column;
|
|
385
|
-
justify-content: center;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
.notra-editor .tiptap-card-item-group[data-orientation='horizontal'] {
|
|
389
|
-
flex-direction: row;
|
|
390
|
-
align-items: center;
|
|
391
|
-
gap: 0.25rem;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
/* =====================
|
|
395
|
-
Input
|
|
396
|
-
===================== */
|
|
397
|
-
.notra-editor .tiptap-input {
|
|
398
|
-
width: 100%;
|
|
399
|
-
min-width: 0;
|
|
400
|
-
height: 2rem;
|
|
401
|
-
padding: 0.25rem 0.625rem;
|
|
402
|
-
border-radius: var(--tt-radius-md);
|
|
403
|
-
border: 1px solid var(--tt-input-border);
|
|
404
|
-
background: transparent;
|
|
405
|
-
font-size: 0.875rem;
|
|
406
|
-
outline: none;
|
|
407
|
-
transition: border-color 150ms;
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
.notra-editor .tiptap-input::placeholder {
|
|
411
|
-
color: var(--tt-input-placeholder);
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
.notra-editor .tiptap-input:focus-visible {
|
|
415
|
-
border-color: var(--tt-input-border-focus);
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
.notra-editor .tiptap-link-input {
|
|
419
|
-
font-size: 0.875rem;
|
|
420
|
-
border: none;
|
|
421
|
-
min-width: 12rem;
|
|
422
|
-
padding-right: 0;
|
|
423
|
-
text-overflow: ellipsis;
|
|
424
|
-
white-space: nowrap;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
.notra-editor .tiptap-link-input:focus {
|
|
428
|
-
text-overflow: clip;
|
|
429
|
-
overflow: visible;
|
|
430
|
-
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var markdown_to_json_exports = {};
|
|
20
|
+
__export(markdown_to_json_exports, {
|
|
21
|
+
markdownToJSON: () => markdownToJSON
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(markdown_to_json_exports);
|
|
24
|
+
var import_core = require("@tiptap/core");
|
|
25
|
+
var import_tiptap_markdown = require("tiptap-markdown");
|
|
26
|
+
var import_extensions = require("../extensions");
|
|
27
|
+
const parserExtensions = [
|
|
28
|
+
...import_extensions.sharedExtensions,
|
|
29
|
+
import_tiptap_markdown.Markdown.configure({ html: false })
|
|
30
|
+
];
|
|
31
|
+
let parserEditor = null;
|
|
32
|
+
function getParserEditor() {
|
|
33
|
+
if (!parserEditor) {
|
|
34
|
+
parserEditor = new import_core.Editor({
|
|
35
|
+
extensions: parserExtensions,
|
|
36
|
+
content: ""
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return parserEditor;
|
|
40
|
+
}
|
|
41
|
+
function markdownToJSON(markdown) {
|
|
42
|
+
const editor = getParserEditor();
|
|
43
|
+
editor.commands.setContent(markdown);
|
|
44
|
+
return editor.getJSON();
|
|
45
|
+
}
|
|
46
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
+
0 && (module.exports = {
|
|
48
|
+
markdownToJSON
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=markdown-to-json.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/markdown-to-json.ts"],"sourcesContent":["import { Editor } from '@tiptap/core';\nimport { Markdown } from 'tiptap-markdown';\n\nimport { sharedExtensions } from '../extensions';\n\n// Parser needs shared content model + Markdown for markdown→JSON conversion\n// No clipboard features needed (transformPastedText/transformCopiedText are editor-only)\nconst parserExtensions = [\n\t...sharedExtensions,\n\tMarkdown.configure({ html: false })\n];\n\nlet parserEditor: Editor | null = null;\n\nfunction getParserEditor(): Editor {\n\tif (!parserEditor) {\n\t\tparserEditor = new Editor({\n\t\t\textensions: parserExtensions,\n\t\t\tcontent: ''\n\t\t});\n\t}\n\n\treturn parserEditor;\n}\n\n/**\n * Convert a Markdown string to Tiptap-compatible JSON (ProseMirror document).\n * Uses a singleton headless Tiptap editor for parsing.\n */\nexport function markdownToJSON(markdown: string): Record<string, unknown> {\n\tconst editor = getParserEditor();\n\n\teditor.commands.setContent(markdown);\n\n\treturn editor.getJSON() as Record<string, unknown>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAuB;AACvB,6BAAyB;AAEzB,wBAAiC;AAIjC,MAAM,mBAAmB;AAAA,EACxB,GAAG;AAAA,EACH,gCAAS,UAAU,EAAE,MAAM,MAAM,CAAC;AACnC;AAEA,IAAI,eAA8B;AAElC,SAAS,kBAA0B;AAClC,MAAI,CAAC,cAAc;AAClB,mBAAe,IAAI,mBAAO;AAAA,MACzB,YAAY;AAAA,MACZ,SAAS;AAAA,IACV,CAAC;AAAA,EACF;AAEA,SAAO;AACR;AAMO,SAAS,eAAe,UAA2C;AACzE,QAAM,SAAS,gBAAgB;AAE/B,SAAO,SAAS,WAAW,QAAQ;AAEnC,SAAO,OAAO,QAAQ;AACvB;","names":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Editor } from "@tiptap/core";
|
|
2
|
+
import { Markdown } from "tiptap-markdown";
|
|
3
|
+
import { sharedExtensions } from "../extensions";
|
|
4
|
+
const parserExtensions = [
|
|
5
|
+
...sharedExtensions,
|
|
6
|
+
Markdown.configure({ html: false })
|
|
7
|
+
];
|
|
8
|
+
let parserEditor = null;
|
|
9
|
+
function getParserEditor() {
|
|
10
|
+
if (!parserEditor) {
|
|
11
|
+
parserEditor = new Editor({
|
|
12
|
+
extensions: parserExtensions,
|
|
13
|
+
content: ""
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return parserEditor;
|
|
17
|
+
}
|
|
18
|
+
function markdownToJSON(markdown) {
|
|
19
|
+
const editor = getParserEditor();
|
|
20
|
+
editor.commands.setContent(markdown);
|
|
21
|
+
return editor.getJSON();
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
markdownToJSON
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=markdown-to-json.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/markdown-to-json.ts"],"sourcesContent":["import { Editor } from '@tiptap/core';\nimport { Markdown } from 'tiptap-markdown';\n\nimport { sharedExtensions } from '../extensions';\n\n// Parser needs shared content model + Markdown for markdown→JSON conversion\n// No clipboard features needed (transformPastedText/transformCopiedText are editor-only)\nconst parserExtensions = [\n\t...sharedExtensions,\n\tMarkdown.configure({ html: false })\n];\n\nlet parserEditor: Editor | null = null;\n\nfunction getParserEditor(): Editor {\n\tif (!parserEditor) {\n\t\tparserEditor = new Editor({\n\t\t\textensions: parserExtensions,\n\t\t\tcontent: ''\n\t\t});\n\t}\n\n\treturn parserEditor;\n}\n\n/**\n * Convert a Markdown string to Tiptap-compatible JSON (ProseMirror document).\n * Uses a singleton headless Tiptap editor for parsing.\n */\nexport function markdownToJSON(markdown: string): Record<string, unknown> {\n\tconst editor = getParserEditor();\n\n\teditor.commands.setContent(markdown);\n\n\treturn editor.getJSON() as Record<string, unknown>;\n}\n"],"mappings":"AAAA,SAAS,cAAc;AACvB,SAAS,gBAAgB;AAEzB,SAAS,wBAAwB;AAIjC,MAAM,mBAAmB;AAAA,EACxB,GAAG;AAAA,EACH,SAAS,UAAU,EAAE,MAAM,MAAM,CAAC;AACnC;AAEA,IAAI,eAA8B;AAElC,SAAS,kBAA0B;AAClC,MAAI,CAAC,cAAc;AAClB,mBAAe,IAAI,OAAO;AAAA,MACzB,YAAY;AAAA,MACZ,SAAS;AAAA,IACV,CAAC;AAAA,EACF;AAEA,SAAO;AACR;AAMO,SAAS,eAAe,UAA2C;AACzE,QAAM,SAAS,gBAAgB;AAE/B,SAAO,SAAS,WAAW,QAAQ;AAEnC,SAAO,OAAO,QAAQ;AACvB;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "notra-editor",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.0",
|
|
5
5
|
"description": "A Markdown-first rich text editor for React",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
},
|
|
26
26
|
"./themes/default/shared.css": "./dist/themes/default/shared.css",
|
|
27
27
|
"./themes/default/editor.css": "./dist/themes/default/editor.css",
|
|
28
|
-
"./themes/default/reader.css": "./dist/themes/default/reader.css"
|
|
28
|
+
"./themes/default/reader.css": "./dist/themes/default/reader.css",
|
|
29
|
+
"./styles/globals.css": "./dist/styles/globals.css"
|
|
29
30
|
},
|
|
30
31
|
"main": "./dist/index.cjs",
|
|
31
32
|
"module": "./dist/index.mjs",
|
|
@@ -34,33 +35,45 @@
|
|
|
34
35
|
"dist"
|
|
35
36
|
],
|
|
36
37
|
"peerDependencies": {
|
|
37
|
-
"react": "^
|
|
38
|
-
"react-dom": "^
|
|
38
|
+
"react": "^19.0.0",
|
|
39
|
+
"react-dom": "^19.0.0"
|
|
39
40
|
},
|
|
40
41
|
"dependencies": {
|
|
42
|
+
"@radix-ui/react-slot": "^1.2.4",
|
|
41
43
|
"@tiptap/core": "^3.22.4",
|
|
44
|
+
"@tiptap/extension-code-block": "^3.22.4",
|
|
42
45
|
"@tiptap/extension-link": "^3.22.4",
|
|
43
46
|
"@tiptap/extension-list": "^3.22.4",
|
|
44
47
|
"@tiptap/pm": "^3.22.4",
|
|
45
48
|
"@tiptap/react": "^3.22.4",
|
|
46
49
|
"@tiptap/starter-kit": "^3.22.4",
|
|
47
50
|
"@tiptap/static-renderer": "^3.22.4",
|
|
51
|
+
"class-variance-authority": "^0.7.1",
|
|
52
|
+
"clsx": "^2.1.1",
|
|
53
|
+
"lucide-react": "^1.9.0",
|
|
54
|
+
"radix-ui": "^1.4.3",
|
|
55
|
+
"tailwind-merge": "^3.5.0",
|
|
48
56
|
"tiptap-markdown": "^0.8.10"
|
|
49
57
|
},
|
|
50
58
|
"devDependencies": {
|
|
59
|
+
"@tailwindcss/postcss": "^4.2.4",
|
|
51
60
|
"@testing-library/jest-dom": "^6.6.3",
|
|
52
61
|
"@testing-library/react": "^16.3.0",
|
|
53
62
|
"@types/react": "19.2.2",
|
|
54
63
|
"@types/react-dom": "19.2.2",
|
|
55
64
|
"jsdom": "^26.1.0",
|
|
65
|
+
"postcss": "^8.5.10",
|
|
66
|
+
"postcss-cli": "^11.0.1",
|
|
56
67
|
"react": "^19.2.0",
|
|
57
68
|
"react-dom": "^19.2.0",
|
|
69
|
+
"tailwindcss": "^4.2.4",
|
|
58
70
|
"tsup": "^8.4.0",
|
|
59
71
|
"typescript": "^5.8.0",
|
|
60
72
|
"vitest": "^4.0.18"
|
|
61
73
|
},
|
|
62
74
|
"scripts": {
|
|
63
|
-
"build": "tsup",
|
|
75
|
+
"build": "tsup && pnpm build:css",
|
|
76
|
+
"build:css": "postcss src/styles/globals.css -o dist/styles/globals.css",
|
|
64
77
|
"dev": "tsup --watch",
|
|
65
78
|
"test": "vitest run --passWithNoTests",
|
|
66
79
|
"test:watch": "vitest",
|