tiptap-editor-custom-stg 1.0.6 → 1.0.8
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/index.css +1 -1
- package/dist/index.js +122 -74
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +105 -57
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.tiptap-editor-wrapper{border:1px solid #e5e7eb;border-radius:.75rem;overflow:hidden;font-size:15px;font-family:"Inter",-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif;background:#fff;box-shadow:0 1px 3px 0 rgba(0,0,0,.05),0 1px 2px -1px rgba(0,0,0,.05)}.tiptap-editor-wrapper .tiptap-toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:.25rem;padding:.35rem .75rem;background:#fff;border-bottom:1px solid #f3f4f6}.tiptap-editor-wrapper .tiptap-toolbar button{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;padding:0;border:none;border-radius:.375rem;background:rgba(0,0,0,0);cursor:pointer;color:#4b5563;font-size:14px;font-weight:500;transition:all .15s ease;line-height:1}.tiptap-editor-wrapper .tiptap-toolbar button:hover:not(:disabled){background:#f3f4f6;color:#111827}.tiptap-editor-wrapper .tiptap-toolbar button.is-active{background:#e5e7eb;color:#111827}.tiptap-editor-wrapper .tiptap-toolbar button:disabled{opacity:.4;cursor:not-allowed}.tiptap-editor-wrapper .tiptap-toolbar button.toolbar-button-dropdown{width:30px;padding:0 2px 0 4px;gap:1px}.tiptap-editor-wrapper .tiptap-toolbar button.toolbar-button-dropdown .dropdown-arrow{width:9px;height:9px;opacity:.6;margin-left:-2px}.tiptap-editor-wrapper .tiptap-toolbar button svg{width:18px;height:18px}.tiptap-editor-wrapper .tiptap-toolbar .toolbar-divider{width:1px;height:20px;background:#e5e7eb;margin:0 .5rem;flex-shrink:0}.tiptap-editor-wrapper .tiptap-toolbar .toolbar-select-wrapper{position:relative;display:inline-flex;align-items:center}.tiptap-editor-wrapper .tiptap-toolbar .toolbar-select{appearance:none;height:32px;border:none;border-radius:.375rem;background:rgba(0,0,0,0);font-size:14.5px;cursor:pointer;padding:0 1.5rem 0 .5rem;color:#4b5563;font-family:inherit;font-weight:500;transition:all .15s ease}.tiptap-editor-wrapper .tiptap-toolbar .toolbar-select:hover{background:#f3f4f6;color:#111827}.tiptap-editor-wrapper .tiptap-toolbar .toolbar-select:focus{outline:none;box-shadow:0 0 0 2px rgba(15,98,254,.2)}.tiptap-editor-wrapper .tiptap-toolbar .select-caret{position:absolute;right:.5rem;pointer-events:none;width:16px;height:16px;fill:#6b7280}.tiptap-editor-wrapper .tiptap-highlight-menu{position:absolute;top:110%;left:50%;transform:translateX(-50%);background:#fff;border:1px solid #e5e7eb;border-radius:9999px;padding:4px;display:flex;gap:6px;box-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -1px rgba(0,0,0,.06);z-index:100}.tiptap-editor-wrapper .tiptap-highlight-menu .color-swatch{width:18px !important;height:18px !important;min-width:18px !important;min-height:18px !important;border-radius:50% !important;border:1px solid rgba(0,0,0,.1) !important;cursor:pointer;padding:0 !important;background-color:#fff;display:flex;align-items:center;justify-content:center;transition:transform .1s ease}.tiptap-editor-wrapper .tiptap-highlight-menu .color-swatch:hover{transform:scale(1.2)}.tiptap-editor-wrapper .tiptap-highlight-menu .color-swatch.clear-swatch{background-color:rgba(0,0,0,0) !important;border:1px solid #d1d5db !important}.tiptap-editor-wrapper .tiptap-highlight-menu .color-swatch svg{width:12px;height:12px;color:#6b7280}.tiptap-editor-wrapper .tiptap-font-menu{position:absolute;top:110%;left:0;background:#fff;border:1px solid #e5e7eb;border-radius:8px;padding:4px;box-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -2px rgba(0,0,0,.05);z-index:100;min-width:180px;max-height:300px;overflow-y:auto}.tiptap-editor-wrapper .tiptap-font-menu .font-option{width:100%;text-align:left;padding:8px 12px;border-radius:4px;background:none;border:none;font-size:14px;color:#374151;cursor:pointer;transition:all .15s ease}.tiptap-editor-wrapper .tiptap-font-menu .font-option:hover:not(.is-active){background:#f3f4f6;color:#111827}.tiptap-editor-wrapper .tiptap-font-menu .font-option.is-active{background:#0062ff;color:#fff;font-weight:500}.tiptap-editor-wrapper .tiptap-heading-menu{position:absolute;top:110%;left:0;background:#fff;border:1px solid #e5e7eb;border-radius:8px;padding:4px;box-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -2px rgba(0,0,0,.05);z-index:100;min-width:140px}.tiptap-editor-wrapper .tiptap-heading-menu .heading-option{width:100%;text-align:left;padding:6px 12px;border-radius:4px;background:none;border:none;font-size:14px;color:#374151;cursor:pointer;transition:all .15s ease}.tiptap-editor-wrapper .tiptap-heading-menu .heading-option:hover{background:#f3f4f6;color:#111827}.tiptap-editor-wrapper .tiptap-heading-menu .heading-option.is-active{background:#eff6ff;color:#2563eb;font-weight:600}.tiptap-editor-wrapper .tiptap-heading-menu .heading-option.h1{font-size:1.35rem;font-weight:700}.tiptap-editor-wrapper .tiptap-heading-menu .heading-option.h2{font-size:1.25rem;font-weight:600}.tiptap-editor-wrapper .tiptap-heading-menu .heading-option.h3{font-size:1.15rem;font-weight:600}.tiptap-editor-wrapper .tiptap-heading-menu .heading-option.h4{font-size:1.05rem;font-weight:600}.tiptap-editor-wrapper .tiptap-heading-menu .heading-option.h5{font-size:1rem;font-weight:600}.tiptap-editor-wrapper .tiptap-heading-menu .heading-option.h6{font-size:.9rem;font-weight:600}.tiptap-editor-wrapper .tiptap-color-picker{position:absolute;top:110%;left:50%;transform:translateX(-50%);background:#fff;border:1px solid #e5e7eb;border-radius:10px;padding:10px;box-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -2px rgba(0,0,0,.05);z-index:100;width:160px}.tiptap-editor-wrapper .tiptap-color-picker .color-remove-btn{width:100%;display:flex;align-items:center;justify-content:center;gap:8px;padding:8px;margin-bottom:8px;background:#fdfdfd;border:1px solid #e5e7eb;border-radius:6px;font-size:13px;color:#4b5563;cursor:pointer;transition:all .15s ease}.tiptap-editor-wrapper .tiptap-color-picker .color-remove-btn:hover{background:#f3f4f6;border-color:#d1d5db;color:#111827}.tiptap-editor-wrapper .tiptap-color-picker .color-remove-btn svg{width:14px;height:14px}.tiptap-editor-wrapper .tiptap-color-picker .color-grid{display:grid;grid-template-columns:repeat(5, 1fr);gap:4px}.tiptap-editor-wrapper .tiptap-color-picker .color-grid .color-swatch{width:24px !important;height:24px !important;min-width:24px !important;min-height:24px !important;border-radius:4px !important;border:1px solid rgba(0,0,0,.08) !important;padding:0 !important;cursor:pointer;transition:transform .15s ease,border-color .15s ease}.tiptap-editor-wrapper .tiptap-color-picker .color-grid .color-swatch:hover{transform:scale(1.15);border-color:rgba(0,0,0,.2) !important;z-index:2}.tiptap-editor-wrapper .tiptap-link-menu{position:absolute;top:110%;left:50%;transform:translateX(-50%);background:#fff;border:1px solid #e5e7eb;border-radius:8px;padding:4px;display:flex;align-items:center;gap:2px;box-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -1px rgba(0,0,0,.06);z-index:100;width:300px}.tiptap-editor-wrapper .tiptap-link-menu input{flex:1;border:1px solid #d1d5db;border-radius:4px;padding:4px 8px;font-size:14px;outline:none;transition:border-color .15s ease}.tiptap-editor-wrapper .tiptap-link-menu input:focus{border-color:#3b82f6;box-shadow:0 0 0 1px #3b82f6}.tiptap-editor-wrapper .tiptap-link-menu button{width:28px !important;height:28px !important;padding:0 !important;min-width:28px !important;border-radius:4px !important;display:flex;align-items:center;justify-content:center}.tiptap-editor-wrapper .tiptap-link-menu button svg{width:14px;height:14px}.tiptap-editor-wrapper .tiptap-link-menu button.link-submit-btn{color:#22c55e}.tiptap-editor-wrapper .tiptap-link-menu button.link-submit-btn:hover{background:#dcfce7}.tiptap-editor-wrapper .tiptap-link-menu button.link-clear-btn{color:#ef4444}.tiptap-editor-wrapper .tiptap-link-menu button.link-clear-btn:hover{background:#fee2e2}.tiptap-editor-wrapper .tiptap-table-menu{position:absolute;top:110%;left:0;background:#fff;border:1px solid #e5e7eb;border-radius:8px;padding:8px;box-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -2px rgba(0,0,0,.05);z-index:100;min-width:200px}.tiptap-editor-wrapper .tiptap-table-menu .table-grid-picker-wrapper{padding:4px;background:#fff}.tiptap-editor-wrapper .tiptap-table-menu .table-grid-picker-wrapper .table-grid-picker{display:flex;flex-direction:column;gap:2px;padding-bottom:8px}.tiptap-editor-wrapper .tiptap-table-menu .table-grid-picker-wrapper .grid-row{display:flex;gap:2px}.tiptap-editor-wrapper .tiptap-table-menu .table-grid-picker-wrapper .grid-cell{width:16px;height:16px;border:1px solid #d1d5db;border-radius:1px;cursor:pointer;transition:background-color .1s,border-color .1s}.tiptap-editor-wrapper .tiptap-table-menu .table-grid-picker-wrapper .grid-cell:hover{border-color:#3b82f6}.tiptap-editor-wrapper .tiptap-table-menu .table-grid-picker-wrapper .grid-cell.is-active{background-color:#bfdbfe;border-color:#3b82f6}.tiptap-editor-wrapper .tiptap-table-menu .table-grid-picker-wrapper .table-grid-label{text-align:center;font-size:13px;color:#4b5563;font-weight:500;border-top:1px solid #f3f4f6;padding-top:8px;margin-top:2px}.tiptap-editor-wrapper .tiptap-table-menu .table-menu-item{width:100%;display:flex;align-items:center;gap:8px;padding:8px 12px;border-radius:4px;background:none;border:none;font-size:13px;color:#374151;transition:background .15s ease;white-space:nowrap;cursor:pointer}.tiptap-editor-wrapper .tiptap-table-menu .table-menu-item:hover{background:#f3f4f6}.tiptap-editor-wrapper .tiptap-table-menu .table-menu-item svg{width:16px;height:16px;color:#6b7280}.tiptap-editor-wrapper .tiptap-table-menu .table-menu-grid{display:grid;grid-template-columns:repeat(3, 1fr);gap:6px}.tiptap-editor-wrapper .tiptap-table-menu .table-menu-grid button{width:32px !important;height:32px !important;padding:0 !important;min-width:32px !important;display:flex;align-items:center;justify-content:center;border-radius:4px;background:#f9fafb !important;border:1px solid #e5e7eb !important;color:#4b5563 !important;cursor:pointer}.tiptap-editor-wrapper .tiptap-table-menu .table-menu-grid button:hover{background:#f3f4f6 !important;border-color:#d1d5db !important}.tiptap-editor-wrapper .tiptap-table-menu .table-menu-grid button.danger{color:#ef4444 !important}.tiptap-editor-wrapper .tiptap-table-menu .table-menu-grid button.danger:hover{background:#fee2e2 !important;border-color:#fca5a5 !important}.tiptap-editor-wrapper .tiptap-table-menu .table-menu-grid button svg{width:16px;height:16px}.tiptap-editor-wrapper .ProseMirror{min-height:300px;padding:1.5rem;color:#1f2937;outline:none;line-height:1.7}.tiptap-editor-wrapper .ProseMirror p.is-editor-empty:first-child::before{color:#9ca3af;content:attr(data-placeholder);float:left;height:0;pointer-events:none}.tiptap-editor-wrapper .ProseMirror h1,.tiptap-editor-wrapper .ProseMirror h2,.tiptap-editor-wrapper .ProseMirror h3,.tiptap-editor-wrapper .ProseMirror h4{line-height:1.2;color:#111827}.tiptap-editor-wrapper .ProseMirror h1{font-size:2.25rem;font-weight:700;margin:1em 0 .5em}.tiptap-editor-wrapper .ProseMirror h2{font-size:1.875rem;font-weight:600;margin:1em 0 .5em}.tiptap-editor-wrapper .ProseMirror h3{font-size:1.5rem;font-weight:600;margin:1em 0 .5em}.tiptap-editor-wrapper .ProseMirror h4{font-size:1.25rem;font-weight:600;margin:1em 0 .5em}.tiptap-editor-wrapper .ProseMirror [style*="font-size: 0.7em"],.tiptap-editor-wrapper .ProseMirror .text-tiny{font-size:.7em}.tiptap-editor-wrapper .ProseMirror [style*="font-size: 0.85em"],.tiptap-editor-wrapper .ProseMirror .text-small{font-size:.85em}.tiptap-editor-wrapper .ProseMirror [style*="font-size: 1.4em"],.tiptap-editor-wrapper .ProseMirror .text-big{font-size:1.4em}.tiptap-editor-wrapper .ProseMirror [style*="font-size: 1.8em"],.tiptap-editor-wrapper .ProseMirror .text-huge{font-size:1.8em}.tiptap-editor-wrapper .ProseMirror p:nth-child(1){margin:0 0}.tiptap-editor-wrapper .ProseMirror p{margin:.5em 0}.tiptap-editor-wrapper .ProseMirror ul{list-style-type:disc;padding-left:1.5rem;margin:.5em 0}.tiptap-editor-wrapper .ProseMirror ol{list-style-type:decimal;padding-left:1.5rem;margin:.5em 0}.tiptap-editor-wrapper .ProseMirror blockquote{border-left:4px solid #e5e7eb;padding-left:1rem;margin:1em 0;color:#4b5563;font-style:italic}.tiptap-editor-wrapper .ProseMirror code{background:#f3f4f6;border-radius:4px;padding:.2rem .4rem;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:.875em}.tiptap-editor-wrapper .ProseMirror pre{background:#111827;color:#f3f4f6;border-radius:.5rem;padding:1rem;overflow-x:auto;margin:1em 0}.tiptap-editor-wrapper .ProseMirror pre code{background:none;padding:0;color:inherit}.tiptap-editor-wrapper .ProseMirror img{max-width:100%;height:auto;display:block;margin:1rem 0;border-radius:.375rem;box-shadow:0 1px 3px 0 rgba(0,0,0,.1)}.tiptap-editor-wrapper .ProseMirror a{color:#2563eb;text-decoration:underline;text-underline-offset:2px;font-weight:500;cursor:pointer}.tiptap-editor-wrapper .ProseMirror a:hover{color:#1d4ed8}.tiptap-editor-wrapper .ProseMirror a[data-attachment=true]{display:inline-flex;align-items:center;gap:.375rem;padding:.25rem .6rem;background:#f3f4f6;border:1px solid #e5e7eb;border-radius:.375rem;font-size:14px;text-decoration:none;color:#111827;font-weight:500;transition:all .15s ease}.tiptap-editor-wrapper .ProseMirror a[data-attachment=true]::before{content:"📎";font-size:13px;opacity:.7}.tiptap-editor-wrapper .ProseMirror a[data-attachment=true]:hover{background:#e5e7eb;border-color:#d1d5db}.tiptap-editor-wrapper .ProseMirror mark{background-color:#fde047;border-radius:.125rem;padding:.125rem .25rem;color:#854d0e}.tiptap-editor-wrapper .ProseMirror sup{vertical-align:super;font-size:.75em}.tiptap-editor-wrapper .ProseMirror sub{vertical-align:sub;font-size:.75em}.tiptap-editor-wrapper .ProseMirror table{border-collapse:collapse;table-layout:fixed;width:100%;margin:1.5rem 0;overflow:hidden}.tiptap-editor-wrapper .ProseMirror table td,.tiptap-editor-wrapper .ProseMirror table th{min-width:1em;border:1px solid #ced4da;padding:8px 12px;vertical-align:top;box-sizing:border-box;position:relative}.tiptap-editor-wrapper .ProseMirror table td>*,.tiptap-editor-wrapper .ProseMirror table th>*{margin-bottom:0}.tiptap-editor-wrapper .ProseMirror table th{font-weight:bold;text-align:left;background-color:#f8f9fa}.tiptap-editor-wrapper .ProseMirror table .selectedCell:after{z-index:2;position:absolute;content:"";left:0;right:0;top:0;bottom:0;background:rgba(200,200,255,.4);pointer-events:none}.tiptap-editor-wrapper .ProseMirror table .column-resize-handle{position:absolute;right:-2px;top:0;bottom:-2px;width:4px;background-color:#adf;pointer-events:none}.tiptap-editor-wrapper .ProseMirror .tableWrapper{overflow-x:auto;margin:1.5rem 0}.tiptap-editor-wrapper.read-only .tiptap-toolbar{background:#f3f3f3;pointer-events:none}.tiptap-editor-wrapper.read-only .tiptap-toolbar button,.tiptap-editor-wrapper.read-only .tiptap-toolbar .toolbar-select{opacity:.5;filter:grayscale(1)}.tiptap-editor-wrapper.read-only .ProseMirror{background:#f3f3f3;color:#6b7280;cursor:default;min-height:300px}.tiptap-editor-wrapper .tiptap-toolbar.toolbar-disabled{background:#f3f3f3;border-bottom-color:#e5e7eb}.tiptap-editor-wrapper .tiptap-toolbar.toolbar-disabled *{cursor:not-allowed !important}.tiptap-editor-wrapper .tiptap-loading-bar{height:3px;background:linear-gradient(90deg, #0f62fe 0%, #4589ff 50%, #0f62fe 100%);background-size:200% 100%;animation:tiptap-loading-anim 1.2s linear infinite;border-radius:0}@keyframes tiptap-loading-anim{0%{background-position:200% 0}100%{background-position:-200% 0}}.tiptap-hidden-input{display:none !important}
|
|
1
|
+
.tiptap-editor-wrapper{border:1px solid #e5e7eb;border-radius:.75rem;overflow:hidden;font-size:15px;font-family:"Inter",-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif;background:#fff;box-shadow:0 1px 3px 0 rgba(0,0,0,.05),0 1px 2px -1px rgba(0,0,0,.05)}.tiptap-editor-wrapper .tiptap-toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:.25rem;padding:.35rem .75rem;background:#fff;border-bottom:1px solid #f3f4f6}.tiptap-editor-wrapper .tiptap-toolbar button{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;padding:0;border:none;border-radius:.375rem;background:rgba(0,0,0,0);cursor:pointer;color:#4b5563;font-size:14px;font-weight:500;transition:all .15s ease;line-height:1}.tiptap-editor-wrapper .tiptap-toolbar button:hover:not(:disabled){background:#f3f4f6;color:#111827}.tiptap-editor-wrapper .tiptap-toolbar button.is-active{background:#e5e7eb;color:#111827}.tiptap-editor-wrapper .tiptap-toolbar button:disabled{opacity:.4;cursor:not-allowed}.tiptap-editor-wrapper .tiptap-toolbar button.toolbar-button-dropdown{width:30px;padding:0 2px 0 4px;gap:1px}.tiptap-editor-wrapper .tiptap-toolbar button.toolbar-button-dropdown .dropdown-arrow{width:9px;height:9px;opacity:.6;margin-left:-2px}.tiptap-editor-wrapper .tiptap-toolbar button svg{width:18px;height:18px}.tiptap-editor-wrapper .tiptap-toolbar .toolbar-divider{width:1px;height:20px;background:#e5e7eb;margin:0 .5rem;flex-shrink:0}.tiptap-editor-wrapper .tiptap-toolbar .toolbar-select-wrapper{position:relative;display:inline-flex;align-items:center}.tiptap-editor-wrapper .tiptap-toolbar .toolbar-select{appearance:none;height:32px;border:none;border-radius:.375rem;background:rgba(0,0,0,0);font-size:14.5px;cursor:pointer;padding:0 1.5rem 0 .5rem;color:#4b5563;font-family:inherit;font-weight:500;transition:all .15s ease}.tiptap-editor-wrapper .tiptap-toolbar .toolbar-select:hover{background:#f3f4f6;color:#111827}.tiptap-editor-wrapper .tiptap-toolbar .toolbar-select:focus{outline:none;box-shadow:0 0 0 2px rgba(15,98,254,.2)}.tiptap-editor-wrapper .tiptap-toolbar .select-caret{position:absolute;right:.5rem;pointer-events:none;width:16px;height:16px;fill:#6b7280}.tiptap-editor-wrapper .tiptap-highlight-menu{position:absolute;top:110%;left:50%;transform:translateX(-50%);background:#fff;border:1px solid #e5e7eb;border-radius:9999px;padding:4px;display:flex;gap:6px;box-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -1px rgba(0,0,0,.06);z-index:100}.tiptap-editor-wrapper .tiptap-highlight-menu .color-swatch{width:18px !important;height:18px !important;min-width:18px !important;min-height:18px !important;border-radius:50% !important;border:1px solid rgba(0,0,0,.1) !important;cursor:pointer;padding:0 !important;background-color:#fff;display:flex;align-items:center;justify-content:center;transition:transform .1s ease}.tiptap-editor-wrapper .tiptap-highlight-menu .color-swatch:hover{transform:scale(1.2)}.tiptap-editor-wrapper .tiptap-highlight-menu .color-swatch.clear-swatch{background-color:rgba(0,0,0,0) !important;border:1px solid #d1d5db !important}.tiptap-editor-wrapper .tiptap-highlight-menu .color-swatch svg{width:12px;height:12px;color:#6b7280}.tiptap-editor-wrapper .tiptap-font-menu{position:absolute;top:110%;left:0;background:#fff;border:1px solid #e5e7eb;border-radius:8px;padding:4px;box-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -2px rgba(0,0,0,.05);z-index:100;min-width:180px;max-height:300px;overflow-y:auto}.tiptap-editor-wrapper .tiptap-font-menu .font-option{width:100%;text-align:left;padding:8px 12px;border-radius:4px;background:none;border:none;font-size:14px;color:#374151;cursor:pointer;transition:all .15s ease}.tiptap-editor-wrapper .tiptap-font-menu .font-option:hover:not(.is-active){background:#f3f4f6;color:#111827}.tiptap-editor-wrapper .tiptap-font-menu .font-option.is-active{background:#0062ff;color:#fff;font-weight:500}.tiptap-editor-wrapper .tiptap-heading-menu{position:absolute;top:110%;left:0;background:#fff;border:1px solid #e5e7eb;border-radius:8px;padding:4px;box-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -2px rgba(0,0,0,.05);z-index:100;min-width:140px}.tiptap-editor-wrapper .tiptap-heading-menu .heading-option{width:100%;text-align:left;padding:6px 12px;border-radius:4px;background:none;border:none;font-size:14px;color:#374151;cursor:pointer;transition:all .15s ease}.tiptap-editor-wrapper .tiptap-heading-menu .heading-option:hover{background:#f3f4f6;color:#111827}.tiptap-editor-wrapper .tiptap-heading-menu .heading-option.is-active{background:#eff6ff;color:#2563eb;font-weight:600}.tiptap-editor-wrapper .tiptap-heading-menu .heading-option.h1{font-size:1.35rem;font-weight:700}.tiptap-editor-wrapper .tiptap-heading-menu .heading-option.h2{font-size:1.25rem;font-weight:600}.tiptap-editor-wrapper .tiptap-heading-menu .heading-option.h3{font-size:1.15rem;font-weight:600}.tiptap-editor-wrapper .tiptap-heading-menu .heading-option.h4{font-size:1.05rem;font-weight:600}.tiptap-editor-wrapper .tiptap-heading-menu .heading-option.h5{font-size:1rem;font-weight:600}.tiptap-editor-wrapper .tiptap-heading-menu .heading-option.h6{font-size:.9rem;font-weight:600}.tiptap-editor-wrapper .tiptap-color-picker{position:absolute;top:110%;left:50%;transform:translateX(-50%);background:#fff;border:1px solid #e5e7eb;border-radius:10px;padding:10px;box-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -2px rgba(0,0,0,.05);z-index:100;width:160px}.tiptap-editor-wrapper .tiptap-color-picker .color-remove-btn{width:100%;display:flex;align-items:center;justify-content:center;gap:8px;padding:8px;margin-bottom:8px;background:#fdfdfd;border:1px solid #e5e7eb;border-radius:6px;font-size:13px;color:#4b5563;cursor:pointer;transition:all .15s ease}.tiptap-editor-wrapper .tiptap-color-picker .color-remove-btn:hover{background:#f3f4f6;border-color:#d1d5db;color:#111827}.tiptap-editor-wrapper .tiptap-color-picker .color-remove-btn svg{width:14px;height:14px}.tiptap-editor-wrapper .tiptap-color-picker .color-grid{display:grid;grid-template-columns:repeat(5, 1fr);gap:4px}.tiptap-editor-wrapper .tiptap-color-picker .color-grid .color-swatch{width:24px !important;height:24px !important;min-width:24px !important;min-height:24px !important;border-radius:4px !important;border:1px solid rgba(0,0,0,.08) !important;padding:0 !important;cursor:pointer;transition:transform .15s ease,border-color .15s ease}.tiptap-editor-wrapper .tiptap-color-picker .color-grid .color-swatch:hover{transform:scale(1.15);border-color:rgba(0,0,0,.2) !important;z-index:2}.tiptap-editor-wrapper .tiptap-link-menu{position:absolute;top:110%;left:50%;transform:translateX(-50%);box-sizing:border-box;background:#fff;border:1px solid #e5e7eb;border-radius:8px;padding:4px;display:flex;align-items:center;gap:2px;box-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -1px rgba(0,0,0,.06);z-index:100;width:300px;max-width:calc(100vw - 32px)}.tiptap-editor-wrapper .tiptap-link-menu.align-start{left:0;transform:none}.tiptap-editor-wrapper .tiptap-link-menu.align-end{right:0;left:auto;transform:none}.tiptap-editor-wrapper .tiptap-link-menu input{flex:1;min-width:0;border:1px solid #d1d5db;border-radius:4px;padding:4px 8px;font-size:14px;outline:none;transition:border-color .15s ease}.tiptap-editor-wrapper .tiptap-link-menu input:focus{border-color:#3b82f6;box-shadow:0 0 0 1px #3b82f6}.tiptap-editor-wrapper .tiptap-link-menu button{width:28px !important;height:28px !important;padding:0 !important;min-width:28px !important;border-radius:4px !important;display:flex;align-items:center;justify-content:center}.tiptap-editor-wrapper .tiptap-link-menu button svg{width:14px;height:14px}.tiptap-editor-wrapper .tiptap-link-menu button.link-submit-btn{color:#22c55e}.tiptap-editor-wrapper .tiptap-link-menu button.link-submit-btn:hover{background:#dcfce7}.tiptap-editor-wrapper .tiptap-link-menu button.link-clear-btn{color:#ef4444}.tiptap-editor-wrapper .tiptap-link-menu button.link-clear-btn:hover{background:#fee2e2}.tiptap-editor-wrapper .tiptap-table-menu{position:absolute;top:110%;left:0;background:#fff;border:1px solid #e5e7eb;border-radius:8px;padding:8px;box-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -2px rgba(0,0,0,.05);z-index:100;min-width:200px}.tiptap-editor-wrapper .tiptap-table-menu .table-grid-picker-wrapper{padding:4px;background:#fff}.tiptap-editor-wrapper .tiptap-table-menu .table-grid-picker-wrapper .table-grid-picker{display:flex;flex-direction:column;gap:2px;padding-bottom:8px}.tiptap-editor-wrapper .tiptap-table-menu .table-grid-picker-wrapper .grid-row{display:flex;gap:2px}.tiptap-editor-wrapper .tiptap-table-menu .table-grid-picker-wrapper .grid-cell{width:16px;height:16px;border:1px solid #d1d5db;border-radius:1px;cursor:pointer;transition:background-color .1s,border-color .1s}.tiptap-editor-wrapper .tiptap-table-menu .table-grid-picker-wrapper .grid-cell:hover{border-color:#3b82f6}.tiptap-editor-wrapper .tiptap-table-menu .table-grid-picker-wrapper .grid-cell.is-active{background-color:#bfdbfe;border-color:#3b82f6}.tiptap-editor-wrapper .tiptap-table-menu .table-grid-picker-wrapper .table-grid-label{text-align:center;font-size:13px;color:#4b5563;font-weight:500;border-top:1px solid #f3f4f6;padding-top:8px;margin-top:2px}.tiptap-editor-wrapper .tiptap-table-menu .table-menu-item{width:100%;display:flex;align-items:center;gap:8px;padding:8px 12px;border-radius:4px;background:none;border:none;font-size:13px;color:#374151;transition:background .15s ease;white-space:nowrap;cursor:pointer}.tiptap-editor-wrapper .tiptap-table-menu .table-menu-item:hover{background:#f3f4f6}.tiptap-editor-wrapper .tiptap-table-menu .table-menu-item svg{width:16px;height:16px;color:#6b7280}.tiptap-editor-wrapper .tiptap-table-menu .table-menu-grid{display:grid;grid-template-columns:repeat(3, 1fr);gap:6px}.tiptap-editor-wrapper .tiptap-table-menu .table-menu-grid button{width:32px !important;height:32px !important;padding:0 !important;min-width:32px !important;display:flex;align-items:center;justify-content:center;border-radius:4px;background:#f9fafb !important;border:1px solid #e5e7eb !important;color:#4b5563 !important;cursor:pointer}.tiptap-editor-wrapper .tiptap-table-menu .table-menu-grid button:hover{background:#f3f4f6 !important;border-color:#d1d5db !important}.tiptap-editor-wrapper .tiptap-table-menu .table-menu-grid button.danger{color:#ef4444 !important}.tiptap-editor-wrapper .tiptap-table-menu .table-menu-grid button.danger:hover{background:#fee2e2 !important;border-color:#fca5a5 !important}.tiptap-editor-wrapper .tiptap-table-menu .table-menu-grid button svg{width:16px;height:16px}.tiptap-editor-wrapper .ProseMirror{min-height:300px;padding:1.5rem;color:#1f2937;outline:none;line-height:1.7}.tiptap-editor-wrapper .ProseMirror p.is-editor-empty:first-child::before{color:#9ca3af;content:attr(data-placeholder);float:left;height:0;pointer-events:none}.tiptap-editor-wrapper .ProseMirror h1,.tiptap-editor-wrapper .ProseMirror h2,.tiptap-editor-wrapper .ProseMirror h3,.tiptap-editor-wrapper .ProseMirror h4{line-height:1.2;color:#111827}.tiptap-editor-wrapper .ProseMirror h1{font-size:2.25rem;font-weight:700;margin:1em 0 .5em}.tiptap-editor-wrapper .ProseMirror h2{font-size:1.875rem;font-weight:600;margin:1em 0 .5em}.tiptap-editor-wrapper .ProseMirror h3{font-size:1.5rem;font-weight:600;margin:1em 0 .5em}.tiptap-editor-wrapper .ProseMirror h4{font-size:1.25rem;font-weight:600;margin:1em 0 .5em}.tiptap-editor-wrapper .ProseMirror [style*="font-size: 0.7em"],.tiptap-editor-wrapper .ProseMirror .text-tiny{font-size:.7em}.tiptap-editor-wrapper .ProseMirror [style*="font-size: 0.85em"],.tiptap-editor-wrapper .ProseMirror .text-small{font-size:.85em}.tiptap-editor-wrapper .ProseMirror [style*="font-size: 1.4em"],.tiptap-editor-wrapper .ProseMirror .text-big{font-size:1.4em}.tiptap-editor-wrapper .ProseMirror [style*="font-size: 1.8em"],.tiptap-editor-wrapper .ProseMirror .text-huge{font-size:1.8em}.tiptap-editor-wrapper .ProseMirror p:nth-child(1){margin:0 0}.tiptap-editor-wrapper .ProseMirror p{margin:.5em 0}.tiptap-editor-wrapper .ProseMirror ul{list-style-type:disc;padding-left:1.5rem;margin:.5em 0}.tiptap-editor-wrapper .ProseMirror ol{list-style-type:decimal;padding-left:1.5rem;margin:.5em 0}.tiptap-editor-wrapper .ProseMirror blockquote{border-left:4px solid #e5e7eb;padding-left:1rem;margin:1em 0;color:#4b5563;font-style:italic}.tiptap-editor-wrapper .ProseMirror code{background:#f3f4f6;border-radius:4px;padding:.2rem .4rem;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:.875em}.tiptap-editor-wrapper .ProseMirror pre{background:#111827;color:#f3f4f6;border-radius:.5rem;padding:1rem;overflow-x:auto;margin:1em 0}.tiptap-editor-wrapper .ProseMirror pre code{background:none;padding:0;color:inherit}.tiptap-editor-wrapper .ProseMirror img{max-width:100%;height:auto;display:block;margin:1rem 0;border-radius:.375rem;box-shadow:0 1px 3px 0 rgba(0,0,0,.1)}.tiptap-editor-wrapper .ProseMirror a{color:#2563eb;text-decoration:underline;text-underline-offset:2px;font-weight:500;cursor:pointer}.tiptap-editor-wrapper .ProseMirror a:hover{color:#1d4ed8}.tiptap-editor-wrapper .ProseMirror a[data-attachment=true]{display:inline-flex;align-items:center;gap:.375rem;padding:.25rem .6rem;background:#f3f4f6;border:1px solid #e5e7eb;border-radius:.375rem;font-size:14px;text-decoration:none;color:#111827;font-weight:500;transition:all .15s ease}.tiptap-editor-wrapper .ProseMirror a[data-attachment=true]::before{content:"📎";font-size:13px;opacity:.7}.tiptap-editor-wrapper .ProseMirror a[data-attachment=true]:hover{background:#e5e7eb;border-color:#d1d5db}.tiptap-editor-wrapper .ProseMirror mark{background-color:#fde047;border-radius:.125rem;padding:.125rem .25rem;color:#854d0e}.tiptap-editor-wrapper .ProseMirror sup{vertical-align:super;font-size:.75em}.tiptap-editor-wrapper .ProseMirror sub{vertical-align:sub;font-size:.75em}.tiptap-editor-wrapper .ProseMirror table{border-collapse:collapse;table-layout:fixed;width:100%;margin:1.5rem 0;overflow:hidden}.tiptap-editor-wrapper .ProseMirror table td,.tiptap-editor-wrapper .ProseMirror table th{min-width:1em;border:1px solid #ced4da;padding:8px 12px;vertical-align:top;box-sizing:border-box;position:relative}.tiptap-editor-wrapper .ProseMirror table td>*,.tiptap-editor-wrapper .ProseMirror table th>*{margin-bottom:0}.tiptap-editor-wrapper .ProseMirror table th{font-weight:bold;text-align:left;background-color:#f8f9fa}.tiptap-editor-wrapper .ProseMirror table .selectedCell:after{z-index:2;position:absolute;content:"";left:0;right:0;top:0;bottom:0;background:rgba(200,200,255,.4);pointer-events:none}.tiptap-editor-wrapper .ProseMirror table .column-resize-handle{position:absolute;right:-2px;top:0;bottom:-2px;width:4px;background-color:#adf;pointer-events:none}.tiptap-editor-wrapper .ProseMirror .tableWrapper{overflow-x:auto;margin:1.5rem 0}.tiptap-editor-wrapper.read-only .tiptap-toolbar{background:#f3f3f3;pointer-events:none}.tiptap-editor-wrapper.read-only .tiptap-toolbar button,.tiptap-editor-wrapper.read-only .tiptap-toolbar .toolbar-select{opacity:.5;filter:grayscale(1)}.tiptap-editor-wrapper.read-only .ProseMirror{background:#f3f3f3;color:#6b7280;cursor:default;min-height:300px}.tiptap-editor-wrapper .tiptap-toolbar.toolbar-disabled{background:#f3f3f3;border-bottom-color:#e5e7eb}.tiptap-editor-wrapper .tiptap-toolbar.toolbar-disabled *{cursor:not-allowed !important}.tiptap-editor-wrapper .tiptap-loading-bar{height:3px;background:linear-gradient(90deg, #0f62fe 0%, #4589ff 50%, #0f62fe 100%);background-size:200% 100%;animation:tiptap-loading-anim 1.2s linear infinite;border-radius:0}@keyframes tiptap-loading-anim{0%{background-position:200% 0}100%{background-position:-200% 0}}.tiptap-hidden-input{display:none !important}
|
package/dist/index.js
CHANGED
|
@@ -42,8 +42,8 @@ __export(index_exports, {
|
|
|
42
42
|
module.exports = __toCommonJS(index_exports);
|
|
43
43
|
|
|
44
44
|
// src/TiptapEditor.tsx
|
|
45
|
-
var
|
|
46
|
-
var
|
|
45
|
+
var import_react2 = __toESM(require("react"));
|
|
46
|
+
var import_react3 = require("@tiptap/react");
|
|
47
47
|
|
|
48
48
|
// src/extensions.ts
|
|
49
49
|
var import_starter_kit = __toESM(require("@tiptap/starter-kit"));
|
|
@@ -246,6 +246,9 @@ var IMAGE_MIME_TYPES = [
|
|
|
246
246
|
"image/bmp"
|
|
247
247
|
];
|
|
248
248
|
|
|
249
|
+
// src/ToolbarGroups.tsx
|
|
250
|
+
var import_react = __toESM(require("react"));
|
|
251
|
+
|
|
249
252
|
// src/Icons.tsx
|
|
250
253
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
251
254
|
var LucideSvg = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", xmlns: "http://www.w3.org/2000/svg", children });
|
|
@@ -768,49 +771,75 @@ var InlineGroup = ({ editor, isReadOnly }) => /* @__PURE__ */ (0, import_jsx_run
|
|
|
768
771
|
}
|
|
769
772
|
)
|
|
770
773
|
] });
|
|
771
|
-
var
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
}
|
|
798
|
-
),
|
|
799
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { onClick: onSubmit, title: "Apply", className: "link-submit-btn", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SubmitIcon, {}) }),
|
|
774
|
+
var getLinkMenuPlacement = (triggerEl) => {
|
|
775
|
+
if (!triggerEl || typeof document === "undefined") return "center";
|
|
776
|
+
const boundaryEl = triggerEl.closest(".tiptap-editor-wrapper");
|
|
777
|
+
const boundaryRect = (boundaryEl == null ? void 0 : boundaryEl.getBoundingClientRect()) || document.documentElement.getBoundingClientRect();
|
|
778
|
+
const triggerRect = triggerEl.getBoundingClientRect();
|
|
779
|
+
const menuWidth = 300;
|
|
780
|
+
const edgePadding = 8;
|
|
781
|
+
const centeredLeft = triggerRect.left + triggerRect.width / 2 - menuWidth / 2;
|
|
782
|
+
const centeredRight = centeredLeft + menuWidth;
|
|
783
|
+
if (centeredLeft < boundaryRect.left + edgePadding) return "start";
|
|
784
|
+
if (centeredRight > boundaryRect.right - edgePadding) return "end";
|
|
785
|
+
return "center";
|
|
786
|
+
};
|
|
787
|
+
var LinkGroup = ({ editor, isReadOnly, showMenu, onToggle, onClose, linkUrl, onLinkUrlChange, onSubmit }) => {
|
|
788
|
+
const triggerRef = import_react.default.useRef(null);
|
|
789
|
+
const [menuPlacement, setMenuPlacement] = import_react.default.useState("center");
|
|
790
|
+
import_react.default.useEffect(() => {
|
|
791
|
+
if (!showMenu || isReadOnly) return;
|
|
792
|
+
const updatePlacement = () => {
|
|
793
|
+
setMenuPlacement(getLinkMenuPlacement(triggerRef.current));
|
|
794
|
+
};
|
|
795
|
+
updatePlacement();
|
|
796
|
+
window.addEventListener("resize", updatePlacement);
|
|
797
|
+
return () => window.removeEventListener("resize", updatePlacement);
|
|
798
|
+
}, [showMenu, isReadOnly]);
|
|
799
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { ref: triggerRef, style: { position: "relative", display: "inline-flex" }, children: [
|
|
800
800
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
801
801
|
"button",
|
|
802
802
|
{
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
803
|
+
title: "Insert link",
|
|
804
|
+
onClick: onToggle,
|
|
805
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
806
|
+
disabled: isReadOnly,
|
|
807
|
+
className: editor.isActive("link") ? "is-active" : "",
|
|
808
|
+
"aria-label": "Insert link",
|
|
809
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LinkIcon, {})
|
|
810
810
|
}
|
|
811
|
-
)
|
|
812
|
-
|
|
813
|
-
|
|
811
|
+
),
|
|
812
|
+
showMenu && !isReadOnly && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: `tiptap-link-menu align-${menuPlacement}`, children: [
|
|
813
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
814
|
+
"input",
|
|
815
|
+
{
|
|
816
|
+
type: "url",
|
|
817
|
+
placeholder: "Paste a link...",
|
|
818
|
+
value: linkUrl,
|
|
819
|
+
onChange: (e) => onLinkUrlChange(e.target.value),
|
|
820
|
+
onKeyDown: (e) => {
|
|
821
|
+
if (e.key === "Enter") onSubmit();
|
|
822
|
+
if (e.key === "Escape") onClose();
|
|
823
|
+
},
|
|
824
|
+
autoFocus: true
|
|
825
|
+
}
|
|
826
|
+
),
|
|
827
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { onClick: onSubmit, title: "Apply", className: "link-submit-btn", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SubmitIcon, {}) }),
|
|
828
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
829
|
+
"button",
|
|
830
|
+
{
|
|
831
|
+
onClick: () => {
|
|
832
|
+
editor.chain().focus().extendMarkRange("link").unsetLink().run();
|
|
833
|
+
onClose();
|
|
834
|
+
},
|
|
835
|
+
title: "Unlink",
|
|
836
|
+
className: "link-clear-btn",
|
|
837
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ClearIcon, {})
|
|
838
|
+
}
|
|
839
|
+
)
|
|
840
|
+
] })
|
|
841
|
+
] });
|
|
842
|
+
};
|
|
814
843
|
var AlignmentGroup = ({ editor, isReadOnly }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
815
844
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
816
845
|
"button",
|
|
@@ -929,6 +958,25 @@ var InsertGroup = ({ isReadOnly, onImageClick, onAttachClick }) => /* @__PURE__
|
|
|
929
958
|
|
|
930
959
|
// src/TiptapEditor.tsx
|
|
931
960
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
961
|
+
var MEANINGFUL_NODE_SELECTOR = "img, table, a[href], iframe, video, audio, object, embed, hr";
|
|
962
|
+
var normalizeInvisibleText = (text) => text.replace(/\u00a0/g, " ").replace(/[\u200B-\u200D\uFEFF]/g, "").trim();
|
|
963
|
+
var isEmptyRichTextHtml = (html) => {
|
|
964
|
+
const raw = (html || "").trim();
|
|
965
|
+
if (!raw) return true;
|
|
966
|
+
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
967
|
+
const text2 = raw.replace(/<br\s*\/?>/gi, "").replace(/<\/?[^>]+>/g, "").replace(/ /gi, " ");
|
|
968
|
+
return normalizeInvisibleText(text2) === "";
|
|
969
|
+
}
|
|
970
|
+
const parser = new DOMParser();
|
|
971
|
+
const doc = parser.parseFromString(raw, "text/html");
|
|
972
|
+
const text = normalizeInvisibleText(doc.body.textContent || "");
|
|
973
|
+
if (text) return false;
|
|
974
|
+
return !doc.body.querySelector(MEANINGFUL_NODE_SELECTOR);
|
|
975
|
+
};
|
|
976
|
+
var getNormalizedEditorHtml = (editor) => {
|
|
977
|
+
const html = editor.getHTML();
|
|
978
|
+
return isEmptyRichTextHtml(html) ? "" : html;
|
|
979
|
+
};
|
|
932
980
|
var TiptapEditor = ({
|
|
933
981
|
elementId,
|
|
934
982
|
content,
|
|
@@ -948,23 +996,23 @@ var TiptapEditor = ({
|
|
|
948
996
|
const loadingChangeFn = onLoadingChange || (() => {
|
|
949
997
|
});
|
|
950
998
|
const isReadOnly = !editMode;
|
|
951
|
-
const containerRef = (0,
|
|
952
|
-
const imageInputRef = (0,
|
|
953
|
-
const attachInputRef = (0,
|
|
954
|
-
const [showHighlightMenu, setShowHighlightMenu] =
|
|
955
|
-
const [showTextColorMenu, setShowTextColorMenu] =
|
|
956
|
-
const [showFontMenu, setShowFontMenu] =
|
|
957
|
-
const [showFontSizeMenu, setShowFontSizeMenu] =
|
|
958
|
-
const [showHeadingMenu, setShowHeadingMenu] =
|
|
959
|
-
const [showLinkMenu, setShowLinkMenu] =
|
|
960
|
-
const [showTableMenu, setShowTableMenu] =
|
|
961
|
-
const [tableHoverSize, setTableHoverSize] =
|
|
962
|
-
const [linkUrl, setLinkUrl] =
|
|
963
|
-
const initializedRef = (0,
|
|
964
|
-
const lastEmittedContentRef = (0,
|
|
965
|
-
const lastUpdateTimestampRef = (0,
|
|
966
|
-
const activeUploadsRef = (0,
|
|
967
|
-
const closeAllMenus =
|
|
999
|
+
const containerRef = (0, import_react2.useRef)(null);
|
|
1000
|
+
const imageInputRef = (0, import_react2.useRef)(null);
|
|
1001
|
+
const attachInputRef = (0, import_react2.useRef)(null);
|
|
1002
|
+
const [showHighlightMenu, setShowHighlightMenu] = import_react2.default.useState(false);
|
|
1003
|
+
const [showTextColorMenu, setShowTextColorMenu] = import_react2.default.useState(false);
|
|
1004
|
+
const [showFontMenu, setShowFontMenu] = import_react2.default.useState(false);
|
|
1005
|
+
const [showFontSizeMenu, setShowFontSizeMenu] = import_react2.default.useState(false);
|
|
1006
|
+
const [showHeadingMenu, setShowHeadingMenu] = import_react2.default.useState(false);
|
|
1007
|
+
const [showLinkMenu, setShowLinkMenu] = import_react2.default.useState(false);
|
|
1008
|
+
const [showTableMenu, setShowTableMenu] = import_react2.default.useState(false);
|
|
1009
|
+
const [tableHoverSize, setTableHoverSize] = import_react2.default.useState({ rows: 0, cols: 0 });
|
|
1010
|
+
const [linkUrl, setLinkUrl] = import_react2.default.useState("");
|
|
1011
|
+
const initializedRef = (0, import_react2.useRef)(false);
|
|
1012
|
+
const lastEmittedContentRef = (0, import_react2.useRef)(content || "");
|
|
1013
|
+
const lastUpdateTimestampRef = (0, import_react2.useRef)(0);
|
|
1014
|
+
const activeUploadsRef = (0, import_react2.useRef)(0);
|
|
1015
|
+
const closeAllMenus = import_react2.default.useCallback(() => {
|
|
968
1016
|
setShowHighlightMenu(false);
|
|
969
1017
|
setShowTextColorMenu(false);
|
|
970
1018
|
setShowFontMenu(false);
|
|
@@ -973,7 +1021,7 @@ var TiptapEditor = ({
|
|
|
973
1021
|
setShowLinkMenu(false);
|
|
974
1022
|
setShowTableMenu(false);
|
|
975
1023
|
}, []);
|
|
976
|
-
|
|
1024
|
+
import_react2.default.useEffect(() => {
|
|
977
1025
|
const handleClickOutside = (event) => {
|
|
978
1026
|
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
979
1027
|
closeAllMenus();
|
|
@@ -984,7 +1032,7 @@ var TiptapEditor = ({
|
|
|
984
1032
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
985
1033
|
};
|
|
986
1034
|
}, [closeAllMenus]);
|
|
987
|
-
const editor = (0,
|
|
1035
|
+
const editor = (0, import_react3.useEditor)({
|
|
988
1036
|
immediatelyRender: false,
|
|
989
1037
|
extensions: createTiptapExtensions(placeholder),
|
|
990
1038
|
content: content || "",
|
|
@@ -1037,8 +1085,8 @@ var TiptapEditor = ({
|
|
|
1037
1085
|
activeUploadsRef.current -= 1;
|
|
1038
1086
|
loadingChangeFn(false);
|
|
1039
1087
|
if (activeUploadsRef.current === 0) {
|
|
1040
|
-
|
|
1041
|
-
|
|
1088
|
+
if (editor) {
|
|
1089
|
+
const html = getNormalizedEditorHtml(editor);
|
|
1042
1090
|
lastEmittedContentRef.current = html;
|
|
1043
1091
|
receiveData && receiveData(elementId, html);
|
|
1044
1092
|
}
|
|
@@ -1050,7 +1098,7 @@ var TiptapEditor = ({
|
|
|
1050
1098
|
}
|
|
1051
1099
|
},
|
|
1052
1100
|
onUpdate: ({ editor: editor2 }) => {
|
|
1053
|
-
const html = editor2
|
|
1101
|
+
const html = getNormalizedEditorHtml(editor2);
|
|
1054
1102
|
lastEmittedContentRef.current = html;
|
|
1055
1103
|
lastUpdateTimestampRef.current = Date.now();
|
|
1056
1104
|
if (activeUploadsRef.current === 0) {
|
|
@@ -1058,7 +1106,7 @@ var TiptapEditor = ({
|
|
|
1058
1106
|
}
|
|
1059
1107
|
}
|
|
1060
1108
|
});
|
|
1061
|
-
(0,
|
|
1109
|
+
(0, import_react2.useEffect)(() => {
|
|
1062
1110
|
if (!editor) return;
|
|
1063
1111
|
if (!initializedRef.current) {
|
|
1064
1112
|
initializedRef.current = true;
|
|
@@ -1082,11 +1130,11 @@ var TiptapEditor = ({
|
|
|
1082
1130
|
lastEmittedContentRef.current = content || "";
|
|
1083
1131
|
}
|
|
1084
1132
|
}, [content, editor]);
|
|
1085
|
-
(0,
|
|
1133
|
+
(0, import_react2.useEffect)(() => {
|
|
1086
1134
|
if (!editor) return;
|
|
1087
1135
|
editor.setEditable(editMode);
|
|
1088
1136
|
}, [editMode, editor]);
|
|
1089
|
-
(0,
|
|
1137
|
+
(0, import_react2.useEffect)(() => {
|
|
1090
1138
|
if (!editor || !onRegisterReset) return;
|
|
1091
1139
|
const handleReset = (newContent) => {
|
|
1092
1140
|
editor.commands.setContent(newContent || "", false);
|
|
@@ -1096,7 +1144,7 @@ var TiptapEditor = ({
|
|
|
1096
1144
|
unregister && unregister();
|
|
1097
1145
|
};
|
|
1098
1146
|
}, [editor, onRegisterReset]);
|
|
1099
|
-
const handleImageFileChange = (0,
|
|
1147
|
+
const handleImageFileChange = (0, import_react2.useCallback)(
|
|
1100
1148
|
async (e) => {
|
|
1101
1149
|
const files = Array.from(e.target.files || []);
|
|
1102
1150
|
if (files.length === 0 || !editor) return;
|
|
@@ -1139,7 +1187,7 @@ var TiptapEditor = ({
|
|
|
1139
1187
|
activeUploadsRef.current -= 1;
|
|
1140
1188
|
loadingChangeFn(false);
|
|
1141
1189
|
if (activeUploadsRef.current === 0) {
|
|
1142
|
-
const html = editor
|
|
1190
|
+
const html = getNormalizedEditorHtml(editor);
|
|
1143
1191
|
lastEmittedContentRef.current = html;
|
|
1144
1192
|
receiveData && receiveData(elementId, html);
|
|
1145
1193
|
}
|
|
@@ -1147,7 +1195,7 @@ var TiptapEditor = ({
|
|
|
1147
1195
|
},
|
|
1148
1196
|
[editor, docNum, receiveStatus, elementId, receiveData, onUploadFile, alertFn, loadingChangeFn, customValidationFn]
|
|
1149
1197
|
);
|
|
1150
|
-
const handleAttachFileChange = (0,
|
|
1198
|
+
const handleAttachFileChange = (0, import_react2.useCallback)(
|
|
1151
1199
|
async (e) => {
|
|
1152
1200
|
const files = Array.from(e.target.files || []);
|
|
1153
1201
|
if (files.length === 0 || !editor) return;
|
|
@@ -1189,7 +1237,7 @@ var TiptapEditor = ({
|
|
|
1189
1237
|
activeUploadsRef.current -= 1;
|
|
1190
1238
|
loadingChangeFn(false);
|
|
1191
1239
|
if (activeUploadsRef.current === 0) {
|
|
1192
|
-
const html = editor
|
|
1240
|
+
const html = getNormalizedEditorHtml(editor);
|
|
1193
1241
|
lastEmittedContentRef.current = html;
|
|
1194
1242
|
receiveData && receiveData(elementId, html);
|
|
1195
1243
|
}
|
|
@@ -1197,7 +1245,7 @@ var TiptapEditor = ({
|
|
|
1197
1245
|
},
|
|
1198
1246
|
[editor, docNum, receiveStatus, elementId, receiveData, onUploadFile, alertFn, loadingChangeFn, customValidationFn]
|
|
1199
1247
|
);
|
|
1200
|
-
const handleLinkClick = (0,
|
|
1248
|
+
const handleLinkClick = (0, import_react2.useCallback)(() => {
|
|
1201
1249
|
if (!editor || isReadOnly) return;
|
|
1202
1250
|
const nextState = !showLinkMenu;
|
|
1203
1251
|
closeAllMenus();
|
|
@@ -1207,7 +1255,7 @@ var TiptapEditor = ({
|
|
|
1207
1255
|
}
|
|
1208
1256
|
setShowLinkMenu(nextState);
|
|
1209
1257
|
}, [editor, isReadOnly, showLinkMenu, closeAllMenus]);
|
|
1210
|
-
const submitLink = (0,
|
|
1258
|
+
const submitLink = (0, import_react2.useCallback)(() => {
|
|
1211
1259
|
if (!editor) return;
|
|
1212
1260
|
if (linkUrl === null || linkUrl.trim() === "") {
|
|
1213
1261
|
editor.chain().focus().extendMarkRange("link").unsetLink().run();
|
|
@@ -1385,7 +1433,7 @@ var TiptapEditor = ({
|
|
|
1385
1433
|
const component = toolbarComponents[group];
|
|
1386
1434
|
if (!component) return null;
|
|
1387
1435
|
const divider = showDividers && index > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "toolbar-divider" }) : null;
|
|
1388
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1436
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react2.default.Fragment, { children: [
|
|
1389
1437
|
divider,
|
|
1390
1438
|
component
|
|
1391
1439
|
] }, group);
|
|
@@ -1403,7 +1451,7 @@ var TiptapEditor = ({
|
|
|
1403
1451
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { id: elementId, className: `tiptap-editor-wrapper${isReadOnly ? " read-only" : ""}`, ref: containerRef, children: [
|
|
1404
1452
|
getHiddenInputs(),
|
|
1405
1453
|
getToolbar(),
|
|
1406
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { onMouseDown: closeAllMenus, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1454
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { onMouseDown: closeAllMenus, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react3.EditorContent, { editor }) })
|
|
1407
1455
|
] });
|
|
1408
1456
|
};
|
|
1409
1457
|
var TiptapEditor_default = TiptapEditor;
|