@airalogy/aimd-editor 1.15.0 → 1.16.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 +2 -0
- package/README.zh-CN.md +2 -0
- package/dist/{AimdEditorTopBar.vue_vue_type_script_setup_true_lang-Bn17A3TY.js → AimdEditorTopBar.vue_vue_type_script_setup_true_lang-DqlyxLJI.js} +958 -950
- package/dist/AimdSourceEditor.vue_vue_type_script_setup_true_lang-DdjWUzYX.js +495 -0
- package/dist/{AimdWysiwygEditor.vue_vue_type_script_setup_true_lang-DAnR-8Ny.js → AimdWysiwygEditor.vue_vue_type_script_setup_true_lang-DuOq6WfS.js} +4130 -4034
- package/dist/aimd-editor.css +1 -1
- package/dist/embedded.js +2 -2
- package/dist/index.js +3 -3
- package/dist/vue.js +3 -3
- package/dist/wysiwyg.js +1 -1
- package/package.json +2 -2
- package/src/__tests__/embedded-images.test.ts +65 -0
- package/src/vue/AimdSourceEditor.vue +8 -0
- package/src/vue/AimdWysiwygEditor.vue +2 -0
- package/src/vue/embeddedImages.css +23 -0
- package/src/vue/embeddedImages.ts +61 -0
- package/src/vue/locales.ts +18 -0
- package/src/vue/milkdown-embedded-images.ts +77 -0
- package/src/vue/monaco-embedded-images.ts +113 -0
- package/src/vue/useEditorContent.ts +24 -5
- package/dist/AimdSourceEditor.vue_vue_type_script_setup_true_lang-DTu36rqy.js +0 -424
package/dist/aimd-editor.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.ProseMirror .tableWrapper{overflow-x:auto}.ProseMirror table{border-collapse:collapse;table-layout:fixed;width:100%;overflow:hidden}.ProseMirror td,.ProseMirror th{vertical-align:top;box-sizing:border-box;position:relative}.ProseMirror td:not([data-colwidth]):not(.column-resize-dragging),.ProseMirror th:not([data-colwidth]):not(.column-resize-dragging){min-width:var(--default-cell-min-width)}.ProseMirror .column-resize-handle{position:absolute;right:-2px;top:0;bottom:0;width:4px;z-index:20;background-color:#adf;pointer-events:none}.ProseMirror.resize-cursor{cursor:ew-resize;cursor:col-resize}.ProseMirror .selectedCell:after{z-index:2;position:absolute;content:"";inset:0;background:#c8c8ff66;pointer-events:none}label[data-v-be127780]{display:flex;flex-direction:column;gap:6px;margin:12px 0}input[data-v-be127780],select[data-v-be127780]{box-sizing:border-box;width:100%;min-width:0;padding:8px;border:1px solid #cbd5e1;border-radius:4px;background:#fff;color:inherit;font:inherit}:is(input[data-v-be127780],select[data-v-be127780]):focus-visible{outline:2px solid #1769d2;outline-offset:2px}.aimd-dialog-overlay{position:fixed;inset:0;background:#00000059;display:flex;align-items:center;justify-content:center;z-index:10000;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)}.aimd-dialog{background:#fff;border-radius:12px;box-shadow:0 20px 60px #0003;width:520px;max-width:90vw;max-height:85vh;display:flex;flex-direction:column;overflow:hidden}.aimd-dialog-header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid #f0f0f0}.aimd-dialog-title{font-size:16px;font-weight:600;color:#1a1a2e;display:flex;align-items:center;gap:8px}.aimd-dialog-icon{display:flex;align-items:center}.aimd-dialog-icon svg{width:20px;height:20px}.aimd-dialog-close{width:32px;height:32px;border:none;background:transparent;cursor:pointer;font-size:22px;color:#999;border-radius:6px;display:flex;align-items:center;justify-content:center}.aimd-dialog-close:hover{background:#f0f2f5;color:#333}.aimd-dialog-type-tabs{display:flex;flex-wrap:wrap;align-items:center;border-bottom:1px solid #f0f0f0;padding:10px 12px;gap:8px}.aimd-type-tab{display:inline-flex;align-items:center;gap:6px;padding:7px 10px;border:1px solid #e5e7eb;border-radius:999px;background:#fff;cursor:pointer;font-size:12px;color:#6b7280;white-space:nowrap;transition:all .15s}.aimd-type-tab:hover{color:#374151;border-color:#d1d5db;background:#f8fafc}.aimd-type-tab-icon{display:inline-flex;align-items:center;vertical-align:middle}.aimd-type-tab-icon svg{width:14px;height:14px}.aimd-type-tab.active{font-weight:600}.aimd-dialog-body{padding:20px;display:flex;flex-direction:column;gap:14px;overflow-y:auto}.aimd-field-row{display:flex;flex-direction:column;gap:4px}.aimd-field-label{font-size:13px;font-weight:500;color:#444}.aimd-field-label em{color:#dc2626;font-style:normal}.aimd-field-input{padding:8px 12px;border:1px solid #e0e0e0;border-radius:6px;font-size:14px;outline:none;transition:border-color .2s;font-family:inherit}.aimd-field-input:focus{border-color:#1a73e8;box-shadow:0 0 0 2px #1a73e81a}.aimd-field-textarea{min-height:72px;resize:vertical}.aimd-field-hint{font-size:11px;color:#999}.aimd-var-type-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:8px}.aimd-var-type-card{display:flex;flex-direction:column;align-items:flex-start;gap:4px;padding:10px 12px;border:1px solid #e5e7eb;border-radius:10px;background:#fff;cursor:pointer;text-align:left;transition:border-color .15s,box-shadow .15s,background .15s,transform .15s}.aimd-var-type-card:hover{border-color:#93c5fd;background:#f8fbff;transform:translateY(-1px)}.aimd-var-type-card:focus-visible{outline:none;border-color:#2563eb;box-shadow:0 0 0 3px #2563eb26}.aimd-var-type-card.active{border-color:#2563eb;background:#eff6ff;box-shadow:0 0 0 2px #2563eb1f}.aimd-var-type-card-title{font-size:13px;font-weight:600;color:#1f2937}.aimd-var-type-card-desc{font-size:12px;line-height:1.4;color:#6b7280}.aimd-collection-editor{display:flex;flex-direction:column;gap:8px}.aimd-collection-row{display:grid;grid-template-columns:90px 1fr auto;gap:8px;align-items:center}.aimd-option-row{grid-template-columns:26px 60px 1fr 80px auto}.aimd-option-row-dragover{background:#eff6ff;border-radius:6px}.aimd-option-answer-toggle{display:flex;align-items:center;gap:6px;color:#4b5563;font-size:12px;-webkit-user-select:none;user-select:none}.aimd-option-answer-toggle input{margin:0}.aimd-drag-handle{color:#9ca3af;cursor:grab;-webkit-user-select:none;user-select:none;text-align:center;font-size:14px;line-height:1}.aimd-drag-handle:active{cursor:grabbing}.aimd-mini-btn{border:1px solid #d8dee8;background:#fff;color:#4b5563;border-radius:6px;padding:6px 10px;font-size:12px;cursor:pointer}.aimd-mini-btn:hover{background:#f8fafc}.aimd-mini-btn:disabled{opacity:.5;cursor:not-allowed}.aimd-mini-btn-add{align-self:flex-start}.aimd-dialog-preview{padding:12px 14px;background:#f8f9fa;border-radius:6px;border:1px solid #e8e8e8;display:flex;flex-direction:column;align-items:stretch;gap:10px}.aimd-preview-header{display:block;font-size:12px;color:#6b7280;font-weight:600;letter-spacing:.04em}.aimd-preview-panel{display:block;width:100%;margin:0;padding:10px 12px;border-radius:6px;border:1px solid #dbe3ef;background:#fff;overflow:auto;max-height:280px;line-height:1.5}.aimd-preview-code{display:block;font-family:SF Mono,Fira Code,monospace;font-size:13px;color:#2563eb;word-break:break-word;white-space:pre-wrap}.aimd-dialog-error{padding:10px 12px;border:1px solid #fecaca;background:#fef2f2;color:#b91c1c;border-radius:6px;font-size:12px;line-height:1.5}.aimd-dialog-footer{display:flex;justify-content:flex-end;gap:8px;padding:14px 20px;border-top:1px solid #f0f0f0}.aimd-btn{padding:8px 20px;border-radius:6px;font-size:13px;font-weight:500;cursor:pointer;transition:all .15s}.aimd-btn-cancel{border:1px solid #e0e0e0;background:#fff;color:#666}.aimd-btn-cancel:hover{background:#f5f5f5}.aimd-btn-primary{border:none;background:#1a73e8;color:#fff}.aimd-btn-primary:hover{background:#1557b0}.aimd-input-dialog[data-v-e4307a72]{position:fixed;inset:0;margin:auto;width:min(420px,calc(100vw - 32px));max-height:calc(100dvh - 32px);box-sizing:border-box;padding:20px;border:1px solid #d1d5db;border-radius:8px;background:#fff;color:#24292f;font:14px/1.5 system-ui,sans-serif;overflow:auto}.aimd-input-dialog[data-v-e4307a72]::backdrop{background:#00000040}h2[data-v-e4307a72]{font-size:18px;margin:0 0 16px}label[data-v-e4307a72]{display:flex;flex-direction:column;gap:6px;margin:12px 0}input[data-v-e4307a72],select[data-v-e4307a72],textarea[data-v-e4307a72]{box-sizing:border-box;width:100%;min-width:0;padding:8px;border:1px solid #cbd5e1;border-radius:4px;background:#fff;color:inherit;font:inherit}summary[data-v-e4307a72]{cursor:pointer;padding:8px 0;color:#57606a}.aimd-input-dialog__required[data-v-e4307a72]{flex-direction:row;align-items:center;justify-content:space-between;min-height:32px;cursor:pointer}.aimd-input-dialog__required input[data-v-e4307a72]{appearance:none;width:32px;height:18px;border-radius:12px;padding:2px;background:#64748b;cursor:pointer}.aimd-input-dialog__required input[data-v-e4307a72]:before{content:"";display:block;width:12px;height:12px;border-radius:50%;background:#fff}.aimd-input-dialog__required input[data-v-e4307a72]:checked{background:#1769d2;border-color:#1769d2}.aimd-input-dialog__required input[data-v-e4307a72]:checked:before{transform:translate(13px)}@media(forced-colors:active){.aimd-input-dialog__required input[data-v-e4307a72]{appearance:auto}}footer[data-v-e4307a72]{display:flex;justify-content:flex-end;gap:8px;margin-top:20px}button[data-v-e4307a72]{padding:7px 16px;border:1px solid #cbd5e1;border-radius:4px;background:#fff;cursor:pointer;font:inherit}.aimd-input-dialog__save[data-v-e4307a72]{background:#1769d2;border-color:#1769d2;color:#fff}.aimd-input-dialog__error[data-v-e4307a72]{color:#b42318}:is(input[data-v-e4307a72],select[data-v-e4307a72],textarea[data-v-e4307a72],button[data-v-e4307a72],summary[data-v-e4307a72]):focus-visible{outline:2px solid #1769d2;outline-offset:2px}.aimd-step-dialog[data-v-fc5a778d]{position:fixed;inset:0;margin:auto;width:min(420px,calc(100vw - 32px));max-height:calc(100dvh - 32px);box-sizing:border-box;padding:20px;border:1px solid #d1d5db;border-radius:8px;background:#fff;color:#24292f;font:14px/1.5 system-ui,sans-serif;overflow:auto}.aimd-step-dialog[data-v-fc5a778d]::backdrop{background:#00000040}h2[data-v-fc5a778d]{font-size:18px;margin:0 0 16px}label[data-v-fc5a778d]{display:flex;flex-direction:column;gap:6px;margin:12px 0}input[data-v-fc5a778d],select[data-v-fc5a778d]{box-sizing:border-box;width:100%;min-width:0;padding:8px;border:1px solid #cbd5e1;border-radius:4px;background:#fff;color:inherit;font:inherit}input[readonly][data-v-fc5a778d]{background:#f6f8fa;color:#57606a}.aimd-step-dialog__check[data-v-fc5a778d]{flex-direction:row;align-items:center}input[type=checkbox][data-v-fc5a778d]{width:16px;height:16px}summary[data-v-fc5a778d]{cursor:pointer;padding:8px 0;color:#57606a}footer[data-v-fc5a778d]{display:flex;justify-content:flex-end;gap:8px;margin-top:20px}button[data-v-fc5a778d]{padding:7px 16px;border:1px solid #cbd5e1;border-radius:4px;background:#fff;cursor:pointer;font:inherit}.aimd-step-dialog__save[data-v-fc5a778d]{background:#1769d2;border-color:#1769d2;color:#fff}p[role=alert][data-v-fc5a778d]{color:#b42318}:is(input[data-v-fc5a778d],select[data-v-fc5a778d],button[data-v-fc5a778d],summary[data-v-fc5a778d]):focus-visible{outline:2px solid #1769d2;outline-offset:2px}.aimd-input-tools[data-v-4f8b17e2]{display:flex;flex:0 0 100%;flex-wrap:wrap;align-items:center;gap:4px;min-width:0;padding-top:6px;border-top:1px solid #e0e5eb}button[data-v-4f8b17e2]{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:32px;box-sizing:border-box;padding:5px 9px;border:1px solid transparent;border-radius:4px;background:transparent;color:inherit;font:inherit;font-size:13px;line-height:20px;white-space:nowrap;cursor:pointer}button[data-v-4f8b17e2]:hover,.aimd-input-tools__more[aria-expanded=true][data-v-4f8b17e2]{background:#eaf2fc;color:#1769d2}button[data-v-4f8b17e2]:focus-visible{outline:2px solid #1769d2;outline-offset:1px}svg[data-v-4f8b17e2]{flex-shrink:0}.aimd-input-tools__menu[data-v-4f8b17e2]{position:fixed;top:0;left:0;visibility:hidden;z-index:1100;overflow-y:auto;overscroll-behavior:contain;display:flex;flex-direction:column;box-sizing:border-box;width:190px;max-width:calc(100vw - 16px);padding:4px;border:1px solid #d0d7de;border-radius:6px;background:#fff;color:#24292f;box-shadow:0 4px 14px #0000001f}.aimd-input-tools__menu button[data-v-4f8b17e2]{flex:none;justify-content:flex-start}@media(max-width:480px){button[data-v-4f8b17e2]{padding-inline:7px}}.aimd-input-chip{display:inline-flex;align-items:center;min-width:100px;max-width:100%;min-height:30px;padding:2px 10px;margin:0 3px;border:1px solid #a8bfd8;border-radius:4px;background:#f7fafc;color:#56697c;font:inherit;font-size:14px;text-align:left;vertical-align:baseline;overflow-wrap:anywhere;cursor:pointer}.aimd-input-chip:hover{border-color:#1769d2;background:#eef5ff}.aimd-input-chip:focus-visible{outline:2px solid #1769d2;outline-offset:2px}.aimd-input-chip--detailed{font-family:monospace;font-size:13px;color:#2563eb}:is(.aimd-step-chip,.aimd-check-chip){gap:6px;flex-wrap:wrap;color:#24292f}:is(.aimd-step-chip,.aimd-check-chip)>small{font:12px/1.4 monospace;color:#667085}.aimd-editor{display:flex;flex-direction:column;min-height:0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;border:1px solid #e0e0e0;border-radius:8px;overflow:hidden}.aimd-editor-toolbar{display:flex;align-items:center;align-content:flex-start;gap:2px;row-gap:4px;padding:4px 8px;background:#fafbfc;border-bottom:1px solid #e0e0e0;overflow:visible;flex-wrap:wrap}.aimd-editor-mode-switch{display:flex;background:#eceef1;border-radius:5px;padding:2px;gap:1px;flex-shrink:0}.aimd-editor-mode-btn{display:flex;align-items:center;gap:4px;padding:4px 10px;border:none;border-radius:4px;background:transparent;cursor:pointer;font-size:12px;font-weight:500;color:#777;transition:all .15s;white-space:nowrap}.aimd-editor-mode-btn:hover{color:#444;background:#ffffff80}.aimd-editor-mode-btn.active{background:#fff;color:#1a73e8;box-shadow:0 1px 2px #00000014}.aimd-editor-mode-icon{display:flex;align-items:center}.aimd-editor-toolbar-sep{width:1px;height:20px;background:#ddd;margin:0 4px;flex-shrink:0}.aimd-editor-toolbar-divider{width:1px;height:22px;background:#ccc;margin:0 6px;flex-shrink:0}.aimd-editor-fmt-btn{width:28px;height:28px;border:1px solid transparent;border-radius:4px;background:transparent;cursor:pointer;color:#555;display:flex;align-items:center;justify-content:center;transition:all .12s;padding:0;flex-shrink:0}.aimd-editor-fmt-btn:hover{background:#eceef1;color:#222}.aimd-editor-fmt-btn:active{background:#dfe1e5}.aimd-editor-fmt-btn svg{width:16px;height:16px;display:block}.aimd-editor-aimd-btn{width:auto;gap:3px;padding:0 7px;border:1px solid color-mix(in srgb,var(--aimd-color, #2563eb) 18%,transparent);background:color-mix(in srgb,var(--aimd-color, #2563eb) 4%,transparent);border-radius:4px}.aimd-editor-aimd-btn:hover{background:color-mix(in srgb,var(--aimd-color, #2563eb) 12%,transparent);border-color:color-mix(in srgb,var(--aimd-color, #2563eb) 35%,transparent);color:var(--aimd-color, #2563eb)}.aimd-editor-aimd-btn-icon{display:flex;align-items:center}.aimd-editor-aimd-btn-icon svg{width:13px;height:13px}.aimd-editor-aimd-btn-label{font-size:11px;font-weight:500}.aimd-editor-panel{display:flex;flex:1 1 auto;min-height:0;background:#fff;overflow:hidden}.aimd-editor-mode-host{display:flex;flex:1 1 auto;min-width:0;min-height:0}.aimd-editor-source-mode{display:flex;flex:1 1 auto;min-width:0;overflow:hidden}.aimd-editor-container{flex:1 1 auto;min-height:0;height:auto}.aimd-editor-loading{padding:40px;text-align:center;color:#888}.aimd-editor-wysiwyg-mode{flex:1 1 auto;min-width:0}.aimd-editor-wysiwyg-mode .milkdown{height:100%}.aimd-editor-wysiwyg-mode .milkdown-editor-content{padding:0 20px 6px;min-height:100%;outline:none;font-size:15px;line-height:1.8}.aimd-editor-wysiwyg-mode .milkdown-editor-content .ProseMirror{outline:none}.aimd-editor-wysiwyg-mode h1{font-size:1.8em;margin:.6em 0 .3em;font-weight:700}.aimd-editor-wysiwyg-mode h2{font-size:1.4em;margin:.5em 0 .3em;color:#333;font-weight:600;border-bottom:1px solid #eee;padding-bottom:.2em}.aimd-editor-wysiwyg-mode h3{font-size:1.2em;margin:.4em 0 .2em;font-weight:600}.aimd-editor-wysiwyg-mode p{margin:.5em 0}.aimd-editor-wysiwyg-mode blockquote{border-left:4px solid #dfe2e5;padding:8px 16px;margin:8px 0;color:#666;background:#fafafa;border-radius:0 4px 4px 0}.aimd-editor-wysiwyg-mode ul,.aimd-editor-wysiwyg-mode ol{padding-left:24px;margin:4px 0}.aimd-editor-wysiwyg-mode code{background:#f0f2f5;padding:2px 6px;border-radius:3px;font-size:.9em;font-family:SF Mono,Fira Code,monospace}.aimd-editor-wysiwyg-mode pre{background:#1e1e2e;color:#cdd6f4;padding:16px;border-radius:8px;overflow-x:auto}.aimd-editor-wysiwyg-mode pre code{background:none;padding:0;color:inherit}.aimd-editor-wysiwyg-mode hr{border:none;border-top:2px solid #e8e8e8;margin:16px 0}.aimd-editor-wysiwyg-mode img{max-width:100%;border-radius:4px}.aimd-editor-wysiwyg-mode a{color:#1a73e8;text-decoration:none}.aimd-editor-wysiwyg-mode a:hover{text-decoration:underline}.aimd-editor-wysiwyg-mode li{margin:2px 0}.aimd-editor-wysiwyg-mode .tableWrapper{overflow-x:auto;margin:12px 0}.aimd-block-handle{position:absolute;z-index:10;transition:top .15s ease,left .15s ease}.aimd-block-handle[data-show=false]{opacity:0;pointer-events:none}.aimd-block-handle-btn{width:24px;height:24px;display:flex;align-items:center;justify-content:center;border-radius:4px;background:#fff;border:1px solid #e0e0e0;color:#aaa;cursor:pointer;transition:all .15s;box-shadow:0 1px 2px #0000000d}.aimd-block-handle-btn:hover{background:#f0f2f5;border-color:silver;color:#555}.aimd-block-add-menu{position:fixed;z-index:10000;background:#fff;border:1px solid #e0e0e0;border-radius:8px;box-shadow:0 4px 16px #0000001f;padding:4px;min-width:200px;max-height:400px;overflow-y:auto}.aimd-block-add-menu-group-label{padding:6px 12px 2px;font-size:11px;font-weight:600;color:#999;text-transform:uppercase;letter-spacing:.5px}.aimd-block-add-menu-divider{height:1px;background:#eee;margin:4px 8px}.aimd-block-add-menu-item{display:flex;align-items:center;gap:10px;width:100%;padding:8px 12px;border:none;background:none;border-radius:5px;cursor:pointer;font-size:13px;color:#333;text-align:left;transition:background .1s}.aimd-block-add-menu-item:hover{background:#f0f2f5}.aimd-block-add-menu-icon{width:24px;height:24px;display:flex;align-items:center;justify-content:center;border-radius:4px;background:#f0f2f5;color:#666;flex-shrink:0}.aimd-block-add-menu-icon svg{width:14px;height:14px}.milkdown-table-block{display:block;margin:4px 0}.milkdown-table-block table{margin:0!important;border-radius:0!important}.milkdown-table-block .handle{position:absolute;z-index:50;cursor:grab;font-size:14px}.milkdown-table-block .cell-handle{left:-999px;top:-999px;z-index:100;height:24px;transition:opacity .2s ease .2s;background-color:#a8d4ff;padding:0 8px;border-radius:8px;position:absolute}.milkdown-table-block .cell-handle[data-role=col-drag-handle]{transform:translateY(50%)}.milkdown-table-block .cell-handle[data-role=row-drag-handle]{transform:translate(50%)}.milkdown-table-block .cell-handle[data-show=false],.milkdown-table-block .line-handle[data-show=false]{opacity:0}.milkdown-table-block .handle:hover{opacity:1}.milkdown-table-block .cell-handle .button-group{position:absolute;height:30px;top:-32px;display:flex;transform:translate(-50%);left:50%;background-color:#fff;border:1px solid #ccc;border-radius:4px}.milkdown-table-block .cell-handle .button-group[data-show=false]{display:none}.milkdown-table-block .cell-handle .button-group button{padding-left:8px;padding-right:8px;width:max-content;border:none;background:none;cursor:pointer}.milkdown-table-block .cell-handle .button-group button:hover{background-color:#f0f0f0}.milkdown-table-block .line-handle{background-color:#a8d4ff;transition:opacity .2s ease-in-out}.milkdown-table-block .line-handle[data-role=x-line-drag-handle]{height:2px}.milkdown-table-block .line-handle[data-role=y-line-drag-handle]{width:2px}.milkdown-table-block .line-handle .add-button{color:#1a73e8;border:1px solid #a8d4ff;padding:0 4px;border-radius:8px;width:max-content;background:#fff;cursor:pointer}.milkdown-table-block .line-handle[data-role=x-line-drag-handle] .add-button{position:absolute;transform:translate(-100%);top:-12px;height:24px}.milkdown-table-block .line-handle[data-role=y-line-drag-handle] .add-button{position:absolute;transform:translate(-50%);top:-24px;height:24px}.milkdown-table-block .line-handle[data-display-type=indicator] .add-button{display:none}.milkdown-table-block .drag-preview{position:absolute;z-index:100;border:1px solid #ccc;opacity:.5;display:flex;flex-direction:column}.milkdown-table-block .drag-preview table{margin:0}.milkdown-table-block .drag-preview[data-show=false]{display:none}.aimd-editor-wysiwyg-mode th,.aimd-editor-wysiwyg-mode td{border:1px solid #ddd;padding:4px 16px;position:relative}.aimd-editor-wysiwyg-mode th{background:#f5f7fa;font-weight:600}.aimd-editor-wysiwyg-mode .ProseMirror-selectednode{outline:none!important}.milkdown-table-block .ProseMirror-selectednode{outline:none!important;background-color:transparent!important}.aimd-editor-wysiwyg-mode td:has(.ProseMirror-selectednode),.aimd-editor-wysiwyg-mode th:has(.ProseMirror-selectednode){outline:1px solid #a8a8a8;outline-offset:-1px}.aimd-editor-wysiwyg-mode .selectedCell{position:relative}.aimd-editor-wysiwyg-mode .selectedCell:after{content:"";position:absolute;inset:0;background-color:#d5d5d5;opacity:.4;pointer-events:none}.aimd-editor-wysiwyg-mode .selectedCell::selection{background:transparent}.milkdown-table-block .cell-handle .button-group button svg{width:18px;height:18px;fill:currentColor}.milkdown-table-block .cell-handle svg{width:14px;height:14px;fill:currentColor}.milkdown-table-block .line-handle .add-button svg{width:16px;height:16px;fill:currentColor}.aimd-placeholder{position:relative}.aimd-placeholder:before{content:attr(data-placeholder);position:absolute;color:#aaa;pointer-events:none;font-style:italic}.aimd-editor-wysiwyg-mode aimd-field{display:inline-flex;align-items:center;gap:3px;padding:1px 8px 1px 6px;border-radius:4px;font-size:13px;font-family:SF Mono,Fira Code,Consolas,monospace;line-height:1.6;vertical-align:baseline;border:1px solid rgba(37,99,235,.2);background:#2563eb0d;color:#2563eb}
|
|
1
|
+
.ProseMirror .tableWrapper{overflow-x:auto}.ProseMirror table{border-collapse:collapse;table-layout:fixed;width:100%;overflow:hidden}.ProseMirror td,.ProseMirror th{vertical-align:top;box-sizing:border-box;position:relative}.ProseMirror td:not([data-colwidth]):not(.column-resize-dragging),.ProseMirror th:not([data-colwidth]):not(.column-resize-dragging){min-width:var(--default-cell-min-width)}.ProseMirror .column-resize-handle{position:absolute;right:-2px;top:0;bottom:0;width:4px;z-index:20;background-color:#adf;pointer-events:none}.ProseMirror.resize-cursor{cursor:ew-resize;cursor:col-resize}.ProseMirror .selectedCell:after{z-index:2;position:absolute;content:"";inset:0;background:#c8c8ff66;pointer-events:none}.aimd-embedded-image{display:inline-flex;align-items:center;vertical-align:middle;flex-wrap:wrap;gap:.4em;padding:0 .45em;border:1px solid currentColor;border-radius:5px;font:12px/1.6 system-ui,sans-serif;max-width:100%;box-sizing:border-box}.aimd-embedded-image button{font:inherit;color:inherit;cursor:pointer;background:transparent;border:0;padding:2px;text-decoration:underline}.aimd-embedded-image button:focus-visible{outline:2px solid currentColor}.aimd-embedded-image-raw,.aimd-embedded-image textarea{flex-basis:100%;max-height:8em;overflow:auto;overflow-wrap:anywhere;white-space:pre-wrap}.aimd-source-image-line{font:13px/30px monospace;box-sizing:border-box;padding-inline:6px;white-space:pre;overflow:auto;color:var(--vscode-editor-foreground, inherit)}.aimd-source-image-line .aimd-embedded-image{flex-wrap:nowrap}.aimd-source-image-fallback{max-width:100%;overflow:auto}.aimd-source-image-layer{top:0;pointer-events:none;overflow:hidden}.aimd-source-image-layer .aimd-source-image-line{position:absolute;width:100%;height:36px;pointer-events:auto}label[data-v-be127780]{display:flex;flex-direction:column;gap:6px;margin:12px 0}input[data-v-be127780],select[data-v-be127780]{box-sizing:border-box;width:100%;min-width:0;padding:8px;border:1px solid #cbd5e1;border-radius:4px;background:#fff;color:inherit;font:inherit}:is(input[data-v-be127780],select[data-v-be127780]):focus-visible{outline:2px solid #1769d2;outline-offset:2px}.aimd-dialog-overlay{position:fixed;inset:0;background:#00000059;display:flex;align-items:center;justify-content:center;z-index:10000;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)}.aimd-dialog{background:#fff;border-radius:12px;box-shadow:0 20px 60px #0003;width:520px;max-width:90vw;max-height:85vh;display:flex;flex-direction:column;overflow:hidden}.aimd-dialog-header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid #f0f0f0}.aimd-dialog-title{font-size:16px;font-weight:600;color:#1a1a2e;display:flex;align-items:center;gap:8px}.aimd-dialog-icon{display:flex;align-items:center}.aimd-dialog-icon svg{width:20px;height:20px}.aimd-dialog-close{width:32px;height:32px;border:none;background:transparent;cursor:pointer;font-size:22px;color:#999;border-radius:6px;display:flex;align-items:center;justify-content:center}.aimd-dialog-close:hover{background:#f0f2f5;color:#333}.aimd-dialog-type-tabs{display:flex;flex-wrap:wrap;align-items:center;border-bottom:1px solid #f0f0f0;padding:10px 12px;gap:8px}.aimd-type-tab{display:inline-flex;align-items:center;gap:6px;padding:7px 10px;border:1px solid #e5e7eb;border-radius:999px;background:#fff;cursor:pointer;font-size:12px;color:#6b7280;white-space:nowrap;transition:all .15s}.aimd-type-tab:hover{color:#374151;border-color:#d1d5db;background:#f8fafc}.aimd-type-tab-icon{display:inline-flex;align-items:center;vertical-align:middle}.aimd-type-tab-icon svg{width:14px;height:14px}.aimd-type-tab.active{font-weight:600}.aimd-dialog-body{padding:20px;display:flex;flex-direction:column;gap:14px;overflow-y:auto}.aimd-field-row{display:flex;flex-direction:column;gap:4px}.aimd-field-label{font-size:13px;font-weight:500;color:#444}.aimd-field-label em{color:#dc2626;font-style:normal}.aimd-field-input{padding:8px 12px;border:1px solid #e0e0e0;border-radius:6px;font-size:14px;outline:none;transition:border-color .2s;font-family:inherit}.aimd-field-input:focus{border-color:#1a73e8;box-shadow:0 0 0 2px #1a73e81a}.aimd-field-textarea{min-height:72px;resize:vertical}.aimd-field-hint{font-size:11px;color:#999}.aimd-var-type-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:8px}.aimd-var-type-card{display:flex;flex-direction:column;align-items:flex-start;gap:4px;padding:10px 12px;border:1px solid #e5e7eb;border-radius:10px;background:#fff;cursor:pointer;text-align:left;transition:border-color .15s,box-shadow .15s,background .15s,transform .15s}.aimd-var-type-card:hover{border-color:#93c5fd;background:#f8fbff;transform:translateY(-1px)}.aimd-var-type-card:focus-visible{outline:none;border-color:#2563eb;box-shadow:0 0 0 3px #2563eb26}.aimd-var-type-card.active{border-color:#2563eb;background:#eff6ff;box-shadow:0 0 0 2px #2563eb1f}.aimd-var-type-card-title{font-size:13px;font-weight:600;color:#1f2937}.aimd-var-type-card-desc{font-size:12px;line-height:1.4;color:#6b7280}.aimd-collection-editor{display:flex;flex-direction:column;gap:8px}.aimd-collection-row{display:grid;grid-template-columns:90px 1fr auto;gap:8px;align-items:center}.aimd-option-row{grid-template-columns:26px 60px 1fr 80px auto}.aimd-option-row-dragover{background:#eff6ff;border-radius:6px}.aimd-option-answer-toggle{display:flex;align-items:center;gap:6px;color:#4b5563;font-size:12px;-webkit-user-select:none;user-select:none}.aimd-option-answer-toggle input{margin:0}.aimd-drag-handle{color:#9ca3af;cursor:grab;-webkit-user-select:none;user-select:none;text-align:center;font-size:14px;line-height:1}.aimd-drag-handle:active{cursor:grabbing}.aimd-mini-btn{border:1px solid #d8dee8;background:#fff;color:#4b5563;border-radius:6px;padding:6px 10px;font-size:12px;cursor:pointer}.aimd-mini-btn:hover{background:#f8fafc}.aimd-mini-btn:disabled{opacity:.5;cursor:not-allowed}.aimd-mini-btn-add{align-self:flex-start}.aimd-dialog-preview{padding:12px 14px;background:#f8f9fa;border-radius:6px;border:1px solid #e8e8e8;display:flex;flex-direction:column;align-items:stretch;gap:10px}.aimd-preview-header{display:block;font-size:12px;color:#6b7280;font-weight:600;letter-spacing:.04em}.aimd-preview-panel{display:block;width:100%;margin:0;padding:10px 12px;border-radius:6px;border:1px solid #dbe3ef;background:#fff;overflow:auto;max-height:280px;line-height:1.5}.aimd-preview-code{display:block;font-family:SF Mono,Fira Code,monospace;font-size:13px;color:#2563eb;word-break:break-word;white-space:pre-wrap}.aimd-dialog-error{padding:10px 12px;border:1px solid #fecaca;background:#fef2f2;color:#b91c1c;border-radius:6px;font-size:12px;line-height:1.5}.aimd-dialog-footer{display:flex;justify-content:flex-end;gap:8px;padding:14px 20px;border-top:1px solid #f0f0f0}.aimd-btn{padding:8px 20px;border-radius:6px;font-size:13px;font-weight:500;cursor:pointer;transition:all .15s}.aimd-btn-cancel{border:1px solid #e0e0e0;background:#fff;color:#666}.aimd-btn-cancel:hover{background:#f5f5f5}.aimd-btn-primary{border:none;background:#1a73e8;color:#fff}.aimd-btn-primary:hover{background:#1557b0}.aimd-input-dialog[data-v-e4307a72]{position:fixed;inset:0;margin:auto;width:min(420px,calc(100vw - 32px));max-height:calc(100dvh - 32px);box-sizing:border-box;padding:20px;border:1px solid #d1d5db;border-radius:8px;background:#fff;color:#24292f;font:14px/1.5 system-ui,sans-serif;overflow:auto}.aimd-input-dialog[data-v-e4307a72]::backdrop{background:#00000040}h2[data-v-e4307a72]{font-size:18px;margin:0 0 16px}label[data-v-e4307a72]{display:flex;flex-direction:column;gap:6px;margin:12px 0}input[data-v-e4307a72],select[data-v-e4307a72],textarea[data-v-e4307a72]{box-sizing:border-box;width:100%;min-width:0;padding:8px;border:1px solid #cbd5e1;border-radius:4px;background:#fff;color:inherit;font:inherit}summary[data-v-e4307a72]{cursor:pointer;padding:8px 0;color:#57606a}.aimd-input-dialog__required[data-v-e4307a72]{flex-direction:row;align-items:center;justify-content:space-between;min-height:32px;cursor:pointer}.aimd-input-dialog__required input[data-v-e4307a72]{appearance:none;width:32px;height:18px;border-radius:12px;padding:2px;background:#64748b;cursor:pointer}.aimd-input-dialog__required input[data-v-e4307a72]:before{content:"";display:block;width:12px;height:12px;border-radius:50%;background:#fff}.aimd-input-dialog__required input[data-v-e4307a72]:checked{background:#1769d2;border-color:#1769d2}.aimd-input-dialog__required input[data-v-e4307a72]:checked:before{transform:translate(13px)}@media(forced-colors:active){.aimd-input-dialog__required input[data-v-e4307a72]{appearance:auto}}footer[data-v-e4307a72]{display:flex;justify-content:flex-end;gap:8px;margin-top:20px}button[data-v-e4307a72]{padding:7px 16px;border:1px solid #cbd5e1;border-radius:4px;background:#fff;cursor:pointer;font:inherit}.aimd-input-dialog__save[data-v-e4307a72]{background:#1769d2;border-color:#1769d2;color:#fff}.aimd-input-dialog__error[data-v-e4307a72]{color:#b42318}:is(input[data-v-e4307a72],select[data-v-e4307a72],textarea[data-v-e4307a72],button[data-v-e4307a72],summary[data-v-e4307a72]):focus-visible{outline:2px solid #1769d2;outline-offset:2px}.aimd-step-dialog[data-v-fc5a778d]{position:fixed;inset:0;margin:auto;width:min(420px,calc(100vw - 32px));max-height:calc(100dvh - 32px);box-sizing:border-box;padding:20px;border:1px solid #d1d5db;border-radius:8px;background:#fff;color:#24292f;font:14px/1.5 system-ui,sans-serif;overflow:auto}.aimd-step-dialog[data-v-fc5a778d]::backdrop{background:#00000040}h2[data-v-fc5a778d]{font-size:18px;margin:0 0 16px}label[data-v-fc5a778d]{display:flex;flex-direction:column;gap:6px;margin:12px 0}input[data-v-fc5a778d],select[data-v-fc5a778d]{box-sizing:border-box;width:100%;min-width:0;padding:8px;border:1px solid #cbd5e1;border-radius:4px;background:#fff;color:inherit;font:inherit}input[readonly][data-v-fc5a778d]{background:#f6f8fa;color:#57606a}.aimd-step-dialog__check[data-v-fc5a778d]{flex-direction:row;align-items:center}input[type=checkbox][data-v-fc5a778d]{width:16px;height:16px}summary[data-v-fc5a778d]{cursor:pointer;padding:8px 0;color:#57606a}footer[data-v-fc5a778d]{display:flex;justify-content:flex-end;gap:8px;margin-top:20px}button[data-v-fc5a778d]{padding:7px 16px;border:1px solid #cbd5e1;border-radius:4px;background:#fff;cursor:pointer;font:inherit}.aimd-step-dialog__save[data-v-fc5a778d]{background:#1769d2;border-color:#1769d2;color:#fff}p[role=alert][data-v-fc5a778d]{color:#b42318}:is(input[data-v-fc5a778d],select[data-v-fc5a778d],button[data-v-fc5a778d],summary[data-v-fc5a778d]):focus-visible{outline:2px solid #1769d2;outline-offset:2px}.aimd-input-tools[data-v-4f8b17e2]{display:flex;flex:0 0 100%;flex-wrap:wrap;align-items:center;gap:4px;min-width:0;padding-top:6px;border-top:1px solid #e0e5eb}button[data-v-4f8b17e2]{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:32px;box-sizing:border-box;padding:5px 9px;border:1px solid transparent;border-radius:4px;background:transparent;color:inherit;font:inherit;font-size:13px;line-height:20px;white-space:nowrap;cursor:pointer}button[data-v-4f8b17e2]:hover,.aimd-input-tools__more[aria-expanded=true][data-v-4f8b17e2]{background:#eaf2fc;color:#1769d2}button[data-v-4f8b17e2]:focus-visible{outline:2px solid #1769d2;outline-offset:1px}svg[data-v-4f8b17e2]{flex-shrink:0}.aimd-input-tools__menu[data-v-4f8b17e2]{position:fixed;top:0;left:0;visibility:hidden;z-index:1100;overflow-y:auto;overscroll-behavior:contain;display:flex;flex-direction:column;box-sizing:border-box;width:190px;max-width:calc(100vw - 16px);padding:4px;border:1px solid #d0d7de;border-radius:6px;background:#fff;color:#24292f;box-shadow:0 4px 14px #0000001f}.aimd-input-tools__menu button[data-v-4f8b17e2]{flex:none;justify-content:flex-start}@media(max-width:480px){button[data-v-4f8b17e2]{padding-inline:7px}}.aimd-input-chip{display:inline-flex;align-items:center;min-width:100px;max-width:100%;min-height:30px;padding:2px 10px;margin:0 3px;border:1px solid #a8bfd8;border-radius:4px;background:#f7fafc;color:#56697c;font:inherit;font-size:14px;text-align:left;vertical-align:baseline;overflow-wrap:anywhere;cursor:pointer}.aimd-input-chip:hover{border-color:#1769d2;background:#eef5ff}.aimd-input-chip:focus-visible{outline:2px solid #1769d2;outline-offset:2px}.aimd-input-chip--detailed{font-family:monospace;font-size:13px;color:#2563eb}:is(.aimd-step-chip,.aimd-check-chip){gap:6px;flex-wrap:wrap;color:#24292f}:is(.aimd-step-chip,.aimd-check-chip)>small{font:12px/1.4 monospace;color:#667085}.aimd-editor{display:flex;flex-direction:column;min-height:0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;border:1px solid #e0e0e0;border-radius:8px;overflow:hidden}.aimd-editor-toolbar{display:flex;align-items:center;align-content:flex-start;gap:2px;row-gap:4px;padding:4px 8px;background:#fafbfc;border-bottom:1px solid #e0e0e0;overflow:visible;flex-wrap:wrap}.aimd-editor-mode-switch{display:flex;background:#eceef1;border-radius:5px;padding:2px;gap:1px;flex-shrink:0}.aimd-editor-mode-btn{display:flex;align-items:center;gap:4px;padding:4px 10px;border:none;border-radius:4px;background:transparent;cursor:pointer;font-size:12px;font-weight:500;color:#777;transition:all .15s;white-space:nowrap}.aimd-editor-mode-btn:hover{color:#444;background:#ffffff80}.aimd-editor-mode-btn.active{background:#fff;color:#1a73e8;box-shadow:0 1px 2px #00000014}.aimd-editor-mode-icon{display:flex;align-items:center}.aimd-editor-toolbar-sep{width:1px;height:20px;background:#ddd;margin:0 4px;flex-shrink:0}.aimd-editor-toolbar-divider{width:1px;height:22px;background:#ccc;margin:0 6px;flex-shrink:0}.aimd-editor-fmt-btn{width:28px;height:28px;border:1px solid transparent;border-radius:4px;background:transparent;cursor:pointer;color:#555;display:flex;align-items:center;justify-content:center;transition:all .12s;padding:0;flex-shrink:0}.aimd-editor-fmt-btn:hover{background:#eceef1;color:#222}.aimd-editor-fmt-btn:active{background:#dfe1e5}.aimd-editor-fmt-btn svg{width:16px;height:16px;display:block}.aimd-editor-aimd-btn{width:auto;gap:3px;padding:0 7px;border:1px solid color-mix(in srgb,var(--aimd-color, #2563eb) 18%,transparent);background:color-mix(in srgb,var(--aimd-color, #2563eb) 4%,transparent);border-radius:4px}.aimd-editor-aimd-btn:hover{background:color-mix(in srgb,var(--aimd-color, #2563eb) 12%,transparent);border-color:color-mix(in srgb,var(--aimd-color, #2563eb) 35%,transparent);color:var(--aimd-color, #2563eb)}.aimd-editor-aimd-btn-icon{display:flex;align-items:center}.aimd-editor-aimd-btn-icon svg{width:13px;height:13px}.aimd-editor-aimd-btn-label{font-size:11px;font-weight:500}.aimd-editor-panel{display:flex;flex:1 1 auto;min-height:0;background:#fff;overflow:hidden}.aimd-editor-mode-host{display:flex;flex:1 1 auto;min-width:0;min-height:0}.aimd-editor-source-mode{display:flex;flex:1 1 auto;min-width:0;overflow:hidden}.aimd-editor-container{flex:1 1 auto;min-height:0;height:auto}.aimd-editor-loading{padding:40px;text-align:center;color:#888}.aimd-editor-wysiwyg-mode{flex:1 1 auto;min-width:0}.aimd-editor-wysiwyg-mode .milkdown{height:100%}.aimd-editor-wysiwyg-mode .milkdown-editor-content{padding:0 20px 6px;min-height:100%;outline:none;font-size:15px;line-height:1.8}.aimd-editor-wysiwyg-mode .milkdown-editor-content .ProseMirror{outline:none}.aimd-editor-wysiwyg-mode h1{font-size:1.8em;margin:.6em 0 .3em;font-weight:700}.aimd-editor-wysiwyg-mode h2{font-size:1.4em;margin:.5em 0 .3em;color:#333;font-weight:600;border-bottom:1px solid #eee;padding-bottom:.2em}.aimd-editor-wysiwyg-mode h3{font-size:1.2em;margin:.4em 0 .2em;font-weight:600}.aimd-editor-wysiwyg-mode p{margin:.5em 0}.aimd-editor-wysiwyg-mode blockquote{border-left:4px solid #dfe2e5;padding:8px 16px;margin:8px 0;color:#666;background:#fafafa;border-radius:0 4px 4px 0}.aimd-editor-wysiwyg-mode ul,.aimd-editor-wysiwyg-mode ol{padding-left:24px;margin:4px 0}.aimd-editor-wysiwyg-mode code{background:#f0f2f5;padding:2px 6px;border-radius:3px;font-size:.9em;font-family:SF Mono,Fira Code,monospace}.aimd-editor-wysiwyg-mode pre{background:#1e1e2e;color:#cdd6f4;padding:16px;border-radius:8px;overflow-x:auto}.aimd-editor-wysiwyg-mode pre code{background:none;padding:0;color:inherit}.aimd-editor-wysiwyg-mode hr{border:none;border-top:2px solid #e8e8e8;margin:16px 0}.aimd-editor-wysiwyg-mode img{max-width:100%;border-radius:4px}.aimd-editor-wysiwyg-mode a{color:#1a73e8;text-decoration:none}.aimd-editor-wysiwyg-mode a:hover{text-decoration:underline}.aimd-editor-wysiwyg-mode li{margin:2px 0}.aimd-editor-wysiwyg-mode .tableWrapper{overflow-x:auto;margin:12px 0}.aimd-block-handle{position:absolute;z-index:10;transition:top .15s ease,left .15s ease}.aimd-block-handle[data-show=false]{opacity:0;pointer-events:none}.aimd-block-handle-btn{width:24px;height:24px;display:flex;align-items:center;justify-content:center;border-radius:4px;background:#fff;border:1px solid #e0e0e0;color:#aaa;cursor:pointer;transition:all .15s;box-shadow:0 1px 2px #0000000d}.aimd-block-handle-btn:hover{background:#f0f2f5;border-color:silver;color:#555}.aimd-block-add-menu{position:fixed;z-index:10000;background:#fff;border:1px solid #e0e0e0;border-radius:8px;box-shadow:0 4px 16px #0000001f;padding:4px;min-width:200px;max-height:400px;overflow-y:auto}.aimd-block-add-menu-group-label{padding:6px 12px 2px;font-size:11px;font-weight:600;color:#999;text-transform:uppercase;letter-spacing:.5px}.aimd-block-add-menu-divider{height:1px;background:#eee;margin:4px 8px}.aimd-block-add-menu-item{display:flex;align-items:center;gap:10px;width:100%;padding:8px 12px;border:none;background:none;border-radius:5px;cursor:pointer;font-size:13px;color:#333;text-align:left;transition:background .1s}.aimd-block-add-menu-item:hover{background:#f0f2f5}.aimd-block-add-menu-icon{width:24px;height:24px;display:flex;align-items:center;justify-content:center;border-radius:4px;background:#f0f2f5;color:#666;flex-shrink:0}.aimd-block-add-menu-icon svg{width:14px;height:14px}.milkdown-table-block{display:block;margin:4px 0}.milkdown-table-block table{margin:0!important;border-radius:0!important}.milkdown-table-block .handle{position:absolute;z-index:50;cursor:grab;font-size:14px}.milkdown-table-block .cell-handle{left:-999px;top:-999px;z-index:100;height:24px;transition:opacity .2s ease .2s;background-color:#a8d4ff;padding:0 8px;border-radius:8px;position:absolute}.milkdown-table-block .cell-handle[data-role=col-drag-handle]{transform:translateY(50%)}.milkdown-table-block .cell-handle[data-role=row-drag-handle]{transform:translate(50%)}.milkdown-table-block .cell-handle[data-show=false],.milkdown-table-block .line-handle[data-show=false]{opacity:0}.milkdown-table-block .handle:hover{opacity:1}.milkdown-table-block .cell-handle .button-group{position:absolute;height:30px;top:-32px;display:flex;transform:translate(-50%);left:50%;background-color:#fff;border:1px solid #ccc;border-radius:4px}.milkdown-table-block .cell-handle .button-group[data-show=false]{display:none}.milkdown-table-block .cell-handle .button-group button{padding-left:8px;padding-right:8px;width:max-content;border:none;background:none;cursor:pointer}.milkdown-table-block .cell-handle .button-group button:hover{background-color:#f0f0f0}.milkdown-table-block .line-handle{background-color:#a8d4ff;transition:opacity .2s ease-in-out}.milkdown-table-block .line-handle[data-role=x-line-drag-handle]{height:2px}.milkdown-table-block .line-handle[data-role=y-line-drag-handle]{width:2px}.milkdown-table-block .line-handle .add-button{color:#1a73e8;border:1px solid #a8d4ff;padding:0 4px;border-radius:8px;width:max-content;background:#fff;cursor:pointer}.milkdown-table-block .line-handle[data-role=x-line-drag-handle] .add-button{position:absolute;transform:translate(-100%);top:-12px;height:24px}.milkdown-table-block .line-handle[data-role=y-line-drag-handle] .add-button{position:absolute;transform:translate(-50%);top:-24px;height:24px}.milkdown-table-block .line-handle[data-display-type=indicator] .add-button{display:none}.milkdown-table-block .drag-preview{position:absolute;z-index:100;border:1px solid #ccc;opacity:.5;display:flex;flex-direction:column}.milkdown-table-block .drag-preview table{margin:0}.milkdown-table-block .drag-preview[data-show=false]{display:none}.aimd-editor-wysiwyg-mode th,.aimd-editor-wysiwyg-mode td{border:1px solid #ddd;padding:4px 16px;position:relative}.aimd-editor-wysiwyg-mode th{background:#f5f7fa;font-weight:600}.aimd-editor-wysiwyg-mode .ProseMirror-selectednode{outline:none!important}.milkdown-table-block .ProseMirror-selectednode{outline:none!important;background-color:transparent!important}.aimd-editor-wysiwyg-mode td:has(.ProseMirror-selectednode),.aimd-editor-wysiwyg-mode th:has(.ProseMirror-selectednode){outline:1px solid #a8a8a8;outline-offset:-1px}.aimd-editor-wysiwyg-mode .selectedCell{position:relative}.aimd-editor-wysiwyg-mode .selectedCell:after{content:"";position:absolute;inset:0;background-color:#d5d5d5;opacity:.4;pointer-events:none}.aimd-editor-wysiwyg-mode .selectedCell::selection{background:transparent}.milkdown-table-block .cell-handle .button-group button svg{width:18px;height:18px;fill:currentColor}.milkdown-table-block .cell-handle svg{width:14px;height:14px;fill:currentColor}.milkdown-table-block .line-handle .add-button svg{width:16px;height:16px;fill:currentColor}.aimd-placeholder{position:relative}.aimd-placeholder:before{content:attr(data-placeholder);position:absolute;color:#aaa;pointer-events:none;font-style:italic}.aimd-editor-wysiwyg-mode aimd-field{display:inline-flex;align-items:center;gap:3px;padding:1px 8px 1px 6px;border-radius:4px;font-size:13px;font-family:SF Mono,Fira Code,Consolas,monospace;line-height:1.6;vertical-align:baseline;border:1px solid rgba(37,99,235,.2);background:#2563eb0d;color:#2563eb}
|
package/dist/embedded.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as s } from "./AimdSourceEditor.vue_vue_type_script_setup_true_lang-
|
|
2
|
-
import { _ as i, D as d, i as o, j as t, k as A, r as m } from "./AimdWysiwygEditor.vue_vue_type_script_setup_true_lang-
|
|
1
|
+
import { _ as s } from "./AimdSourceEditor.vue_vue_type_script_setup_true_lang-DdjWUzYX.js";
|
|
2
|
+
import { _ as i, D as d, i as o, j as t, k as A, r as m } from "./AimdWysiwygEditor.vue_vue_type_script_setup_true_lang-DuOq6WfS.js";
|
|
3
3
|
export {
|
|
4
4
|
s as AimdSourceEditor,
|
|
5
5
|
i as AimdWysiwygEditor,
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { A as i, a as d, b as s, D as o, K as m, M as r, c as t, d as A, e as l, f as I, g as n, l as u, s as D } from "./theme-5__dt-6K.js";
|
|
2
2
|
import { A as c, a as p, c as E, b as T, n as _, p as g, s as f } from "./fig-oCdVp2EF.js";
|
|
3
3
|
import { A as k, c as x, a as O, u as S, b as L, d as b } from "./fields-CC93ner-.js";
|
|
4
|
-
import { _ as P, a as y, b as R, c as h, A as w, d as B, u as C } from "./AimdEditorTopBar.vue_vue_type_script_setup_true_lang-
|
|
5
|
-
import { _ as K } from "./AimdSourceEditor.vue_vue_type_script_setup_true_lang-
|
|
6
|
-
import { A as Y, a as j, _ as z, D as G, M as Q, b as U, c as W, d as q, e as H, f as J, g as X, h as Z, i as $, j as aa, k as ea, l as ia, m as da, n as sa, r as oa } from "./AimdWysiwygEditor.vue_vue_type_script_setup_true_lang-
|
|
4
|
+
import { _ as P, a as y, b as R, c as h, A as w, d as B, u as C } from "./AimdEditorTopBar.vue_vue_type_script_setup_true_lang-DqlyxLJI.js";
|
|
5
|
+
import { _ as K } from "./AimdSourceEditor.vue_vue_type_script_setup_true_lang-DdjWUzYX.js";
|
|
6
|
+
import { A as Y, a as j, _ as z, D as G, M as Q, b as U, c as W, d as q, e as H, f as J, g as X, h as Z, i as $, j as aa, k as ea, l as ia, m as da, n as sa, r as oa } from "./AimdWysiwygEditor.vue_vue_type_script_setup_true_lang-DuOq6WfS.js";
|
|
7
7
|
export {
|
|
8
8
|
k as AIMD_FIELD_ID_PATTERN,
|
|
9
9
|
Y as AIMD_FIELD_TYPES,
|
package/dist/vue.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { _ as d, a as e, b as s, c as o, A as r, d as t, u as m } from "./AimdEditorTopBar.vue_vue_type_script_setup_true_lang-
|
|
2
|
-
import { _ as l } from "./AimdSourceEditor.vue_vue_type_script_setup_true_lang-
|
|
3
|
-
import { A as I, a as D, _, D as T, M as F, b as u, c as M, d as g, e as n, f as c, g as p, h as L, i as O, j as S, k as y, l as b, m as f, n as x, r as N } from "./AimdWysiwygEditor.vue_vue_type_script_setup_true_lang-
|
|
1
|
+
import { _ as d, a as e, b as s, c as o, A as r, d as t, u as m } from "./AimdEditorTopBar.vue_vue_type_script_setup_true_lang-DqlyxLJI.js";
|
|
2
|
+
import { _ as l } from "./AimdSourceEditor.vue_vue_type_script_setup_true_lang-DdjWUzYX.js";
|
|
3
|
+
import { A as I, a as D, _, D as T, M as F, b as u, c as M, d as g, e as n, f as c, g as p, h as L, i as O, j as S, k as y, l as b, m as f, n as x, r as N } from "./AimdWysiwygEditor.vue_vue_type_script_setup_true_lang-DuOq6WfS.js";
|
|
4
4
|
export {
|
|
5
5
|
I as AIMD_FIELD_TYPES,
|
|
6
6
|
D as AIMD_FIELD_TYPE_DEFINITIONS,
|
package/dist/wysiwyg.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as a, D as r, i, j as d, k as t, r as A } from "./AimdWysiwygEditor.vue_vue_type_script_setup_true_lang-
|
|
1
|
+
import { _ as a, D as r, i, j as d, k as t, r as A } from "./AimdWysiwygEditor.vue_vue_type_script_setup_true_lang-DuOq6WfS.js";
|
|
2
2
|
export {
|
|
3
3
|
a as AimdWysiwygEditor,
|
|
4
4
|
r as DEFAULT_AIMD_EDITOR_LOCALE,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@airalogy/aimd-editor",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.16.0",
|
|
5
5
|
"description": "AIMD (Airalogy Markdown) editor with Monaco source mode and Milkdown WYSIWYG mode",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@milkdown/theme-nord": "^7.18.0",
|
|
67
67
|
"@milkdown/vue": "^7.18.0",
|
|
68
68
|
"@airalogy/aimd-core": "^2.19.0",
|
|
69
|
-
"@airalogy/aimd-renderer": "^2.17.
|
|
69
|
+
"@airalogy/aimd-renderer": "^2.17.1"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"monaco-editor": ">=0.50.0",
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
2
|
+
import { Editor, defaultValueCtx, editorViewCtx, rootCtx } from '@milkdown/kit/core'
|
|
3
|
+
import { commonmark } from '@milkdown/kit/preset/commonmark'
|
|
4
|
+
import { getMarkdown } from '@milkdown/kit/utils'
|
|
5
|
+
import { embeddedImages, imageControls } from '../vue/embeddedImages'
|
|
6
|
+
import { embeddedImagePlugin } from '../vue/milkdown-embedded-images'
|
|
7
|
+
import { createAimdEditorMessages } from '../vue/locales'
|
|
8
|
+
|
|
9
|
+
const url = 'data:image/png;base64,' + 'AB+/'.repeat(25000) + 'AA=='
|
|
10
|
+
const labels = createAimdEditorMessages('en-US').embeddedImage
|
|
11
|
+
|
|
12
|
+
describe('embedded image display', () => {
|
|
13
|
+
it('returns exact image ranges, including parameters and padding, without consuming neighboring markup', () => {
|
|
14
|
+
const text = `\n src: "${url.replace('png;', 'svg+xml;charset=utf-8;')}"\n caption: More`
|
|
15
|
+
const matches = embeddedImages(text)
|
|
16
|
+
expect(matches.map(image => text.slice(image.from, image.to))).toEqual([url, url.replace('png;', 'svg+xml;charset=utf-8;')])
|
|
17
|
+
expect(matches[0].bytes).toBe(75001)
|
|
18
|
+
expect(embeddedImages('data:text/plain;base64,' + 'A'.repeat(128))).toEqual([])
|
|
19
|
+
expect(embeddedImages('data:image/png;base64,AAAA')).toEqual([])
|
|
20
|
+
expect(embeddedImages(url + '%2F')).toEqual([])
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('keeps image attributes, the fig caption, source and undo history intact on display operations', async () => {
|
|
24
|
+
const host = document.createElement('div')
|
|
25
|
+
document.body.append(host)
|
|
26
|
+
const source = `\n\n\`\`\`fig\nid: sample\nsrc: ${url}\ncaption: Still visible\n\`\`\`\n`
|
|
27
|
+
const editor = await Editor.make().config(ctx => {
|
|
28
|
+
ctx.set(rootCtx, host)
|
|
29
|
+
ctx.set(defaultValueCtx, source)
|
|
30
|
+
}).use(commonmark).use(embeddedImagePlugin(() => labels)).create()
|
|
31
|
+
try {
|
|
32
|
+
const markdown = editor.action(getMarkdown())
|
|
33
|
+
const view = editor.action(ctx => ctx.get(editorViewCtx))
|
|
34
|
+
const original = view.state.doc
|
|
35
|
+
const buttons = host.querySelectorAll<HTMLButtonElement>('button[aria-expanded=false]')
|
|
36
|
+
expect(buttons).toHaveLength(2)
|
|
37
|
+
expect(host.querySelector('img')?.getAttribute('src')).toBe(url)
|
|
38
|
+
expect(host.querySelector('pre span[style*="display"]')?.textContent).toBe(url)
|
|
39
|
+
buttons[1].click()
|
|
40
|
+
expect(host.querySelector('pre span[style*="display"]')).toBeNull()
|
|
41
|
+
host.querySelector<HTMLButtonElement>('pre button[aria-expanded=true]')!.click()
|
|
42
|
+
expect(view.state.doc).toBe(original)
|
|
43
|
+
expect(editor.action(getMarkdown())).toBe(markdown)
|
|
44
|
+
expect(markdown.split(url)).toHaveLength(3)
|
|
45
|
+
expect(markdown).toContain('caption: Still visible')
|
|
46
|
+
} finally {
|
|
47
|
+
await editor.destroy()
|
|
48
|
+
host.remove()
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it('copies the full URL and offers selected text if clipboard access fails', async () => {
|
|
53
|
+
const write = vi.spyOn(navigator.clipboard, 'writeText').mockResolvedValue(undefined)
|
|
54
|
+
try {
|
|
55
|
+
const controls = imageControls(embeddedImages(url)[0], labels, false, () => {})
|
|
56
|
+
const copy = controls.querySelectorAll('button')[1]
|
|
57
|
+
copy.click()
|
|
58
|
+
await vi.waitFor(() => expect(controls.textContent).toContain(labels.copied))
|
|
59
|
+
expect(write).toHaveBeenCalledWith(url)
|
|
60
|
+
write.mockRejectedValue(new Error('Clipboard unavailable'))
|
|
61
|
+
copy.click()
|
|
62
|
+
await vi.waitFor(() => expect(controls.querySelector('textarea')?.value).toBe(url))
|
|
63
|
+
} finally { write.mockRestore() }
|
|
64
|
+
})
|
|
65
|
+
})
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { ref, onMounted, onBeforeUnmount, watch } from 'vue'
|
|
3
3
|
import type { AimdEditorMessages } from './locales'
|
|
4
|
+
import { installSourceImageFolds } from './monaco-embedded-images'
|
|
4
5
|
import { collectAimdDiagnostics } from './aimdDiagnostics'
|
|
5
6
|
|
|
6
7
|
const props = defineProps<{
|
|
@@ -28,6 +29,8 @@ const AIMD_DIAGNOSTIC_OWNER = 'airalogy-aimd'
|
|
|
28
29
|
|
|
29
30
|
const editorContainer = ref<HTMLElement | null>(null)
|
|
30
31
|
|
|
32
|
+
const imageFallback = ref<HTMLElement | null>(null)
|
|
33
|
+
let imageFolds: ReturnType<typeof installSourceImageFolds> | undefined
|
|
31
34
|
let monacoEditorInstance: any = null
|
|
32
35
|
let monacoModule: any = null
|
|
33
36
|
let aimdCodeActionProviderDisposable: any = null
|
|
@@ -328,6 +331,7 @@ function createEditor(monaco: any) {
|
|
|
328
331
|
readOnly: props.readonly,
|
|
329
332
|
...safeMonacoOptions,
|
|
330
333
|
})
|
|
334
|
+
if (imageFallback.value) imageFolds = installSourceImageFolds(monacoEditorInstance, imageFallback.value, () => props.resolvedMessages.embeddedImage)
|
|
331
335
|
registerAimdCodeActions(monaco)
|
|
332
336
|
monacoEditorInstance.onDidChangeModelContent(() => {
|
|
333
337
|
updateAimdDiagnostics()
|
|
@@ -353,6 +357,7 @@ onMounted(async () => {
|
|
|
353
357
|
})
|
|
354
358
|
|
|
355
359
|
onBeforeUnmount(() => {
|
|
360
|
+
imageFolds?.dispose()
|
|
356
361
|
clearAimdDiagnostics()
|
|
357
362
|
aimdCodeActionProviderDisposable?.dispose()
|
|
358
363
|
monacoEditorInstance?.dispose()
|
|
@@ -368,6 +373,8 @@ watch(() => props.content, (content) => {
|
|
|
368
373
|
isSyncing = false
|
|
369
374
|
})
|
|
370
375
|
|
|
376
|
+
watch(() => props.resolvedMessages, () => imageFolds?.refresh())
|
|
377
|
+
|
|
371
378
|
watch(() => props.theme, (theme) => {
|
|
372
379
|
if (monacoModule) monacoModule.editor.setTheme(theme)
|
|
373
380
|
})
|
|
@@ -429,6 +436,7 @@ defineExpose({
|
|
|
429
436
|
<template>
|
|
430
437
|
<div class="aimd-editor-source-mode" :style="{ minHeight: minHeight + 'px' }">
|
|
431
438
|
<div v-if="loading" class="aimd-editor-loading">{{ resolvedMessages.common.loadingEditor }}</div>
|
|
439
|
+
<div ref="imageFallback" class="aimd-source-image-fallback" hidden />
|
|
432
440
|
<div ref="editorContainer" class="aimd-editor-container" />
|
|
433
441
|
</div>
|
|
434
442
|
</template>
|
|
@@ -28,6 +28,7 @@ import '@milkdown/kit/prose/tables/style/tables.css'
|
|
|
28
28
|
import { aimdMilkdownPlugins, createAimdAuthoringPlugins, type AimdInputEditRequest } from './milkdown-aimd-plugin'
|
|
29
29
|
import { createProgrammaticMarkdownSyncGuard } from './programmaticMarkdownSyncGuard'
|
|
30
30
|
import { normalizeComparableAimdMarkdown } from './comparableAimdMarkdown'
|
|
31
|
+
import { embeddedImagePlugin } from './milkdown-embedded-images'
|
|
31
32
|
import { codeBlockMetadataSchema } from './milkdown-code-block-metadata'
|
|
32
33
|
import type { AimdFieldType } from './types'
|
|
33
34
|
import type { AimdEditorMessages } from './locales'
|
|
@@ -343,6 +344,7 @@ const MilkdownEditorInner = defineComponent({
|
|
|
343
344
|
.use(trailing)
|
|
344
345
|
.use(innerProps.milkdownPlugins ?? (props.editInputFields ? authoringPlugins : aimdMilkdownPlugins))
|
|
345
346
|
.use(tableBlock)
|
|
347
|
+
.use(embeddedImagePlugin(() => props.resolvedMessages.embeddedImage))
|
|
346
348
|
.use(placeholderPlugin)
|
|
347
349
|
.config((ctx) => {
|
|
348
350
|
ctx.update(tableBlockConfig.key, (defaultConfig) => ({
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
.aimd-embedded-image {
|
|
2
|
+
display: inline-flex; align-items: center; vertical-align: middle; flex-wrap: wrap;
|
|
3
|
+
gap: 0.4em; padding: 0 0.45em; border: 1px solid currentColor; border-radius: 5px;
|
|
4
|
+
font: 12px/1.6 system-ui, sans-serif; max-width: 100%; box-sizing: border-box;
|
|
5
|
+
}
|
|
6
|
+
.aimd-embedded-image button {
|
|
7
|
+
font: inherit; color: inherit; cursor: pointer; background: transparent;
|
|
8
|
+
border: 0; padding: 2px; text-decoration: underline;
|
|
9
|
+
}
|
|
10
|
+
.aimd-embedded-image button:focus-visible { outline: 2px solid currentColor; }
|
|
11
|
+
.aimd-embedded-image-raw, .aimd-embedded-image textarea {
|
|
12
|
+
flex-basis: 100%; max-height: 8em; overflow: auto; overflow-wrap: anywhere; white-space: pre-wrap;
|
|
13
|
+
}
|
|
14
|
+
.aimd-source-image-line {
|
|
15
|
+
font: 13px/30px monospace; box-sizing: border-box; padding-inline: 6px;
|
|
16
|
+
white-space: pre; overflow: auto; color: var(--vscode-editor-foreground, inherit);
|
|
17
|
+
}
|
|
18
|
+
.aimd-source-image-line .aimd-embedded-image { flex-wrap: nowrap; }
|
|
19
|
+
.aimd-source-image-fallback { max-width: 100%; overflow: auto; }
|
|
20
|
+
.aimd-source-image-layer { top: 0; pointer-events: none; overflow: hidden; }
|
|
21
|
+
.aimd-source-image-layer .aimd-source-image-line {
|
|
22
|
+
position: absolute; width: 100%; height: 36px; pointer-events: auto;
|
|
23
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import './embeddedImages.css'
|
|
2
|
+
import type { AimdEditorMessages } from './locales'
|
|
3
|
+
|
|
4
|
+
export type ImageLabels = AimdEditorMessages['embeddedImage']
|
|
5
|
+
export interface EmbeddedImage {
|
|
6
|
+
from: number
|
|
7
|
+
to: number
|
|
8
|
+
uri: string
|
|
9
|
+
format: string
|
|
10
|
+
bytes: number
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Match contiguous data URLs, leaving Markdown/YAML punctuation and neighboring text alone.
|
|
14
|
+
export function embeddedImages(text: string): EmbeddedImage[] {
|
|
15
|
+
if (!/data:image\//i.test(text)) return []
|
|
16
|
+
const pattern = /\bdata:image\/([\w.+-]+)(?:;[\w.-]+=[\w.%+-]+)*;base64,([a-z\d+/]{80,}={0,2})(?=$|[\s<>"'()\[\]`])/gi
|
|
17
|
+
return Array.from(text.matchAll(pattern), match => ({
|
|
18
|
+
from: match.index!,
|
|
19
|
+
to: match.index! + match[0].length,
|
|
20
|
+
uri: match[0],
|
|
21
|
+
format: match[1].toUpperCase(),
|
|
22
|
+
bytes: Math.floor(match[2].replace(/=+$/, '').length * 3 / 4),
|
|
23
|
+
}))
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function imageControls(image: EmbeddedImage, labels: ImageLabels, expanded: boolean, toggle: () => void) {
|
|
27
|
+
const controls = document.createElement('span')
|
|
28
|
+
controls.className = 'aimd-embedded-image'
|
|
29
|
+
controls.contentEditable = 'false'
|
|
30
|
+
const summary = document.createElement('span')
|
|
31
|
+
summary.textContent = labels.summary(image.format, image.bytes < 1024 ? image.bytes + ' B' : Math.ceil(image.bytes / 1024) + ' KiB')
|
|
32
|
+
const disclosure = document.createElement('button')
|
|
33
|
+
disclosure.type = 'button'
|
|
34
|
+
disclosure.textContent = expanded ? labels.collapse : labels.expand
|
|
35
|
+
disclosure.setAttribute('aria-expanded', String(expanded))
|
|
36
|
+
disclosure.onclick = toggle
|
|
37
|
+
const copy = document.createElement('button')
|
|
38
|
+
copy.type = 'button'
|
|
39
|
+
copy.textContent = labels.copy
|
|
40
|
+
const status = document.createElement('span')
|
|
41
|
+
status.setAttribute('role', 'status')
|
|
42
|
+
copy.onclick = async () => {
|
|
43
|
+
try {
|
|
44
|
+
await navigator.clipboard.writeText(image.uri)
|
|
45
|
+
status.textContent = labels.copied
|
|
46
|
+
} catch {
|
|
47
|
+
// Insecure origins and denied clipboard permissions still allow manual copy.
|
|
48
|
+
const raw = document.createElement('textarea')
|
|
49
|
+
raw.readOnly = true
|
|
50
|
+
raw.value = image.uri
|
|
51
|
+
raw.setAttribute('aria-label', labels.copy)
|
|
52
|
+
controls.querySelector('textarea')?.remove()
|
|
53
|
+
controls.append(raw)
|
|
54
|
+
raw.focus()
|
|
55
|
+
raw.select()
|
|
56
|
+
status.textContent = labels.manualCopy
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
controls.append(summary, disclosure, copy, status)
|
|
60
|
+
return controls
|
|
61
|
+
}
|
package/src/vue/locales.ts
CHANGED
|
@@ -72,6 +72,14 @@ export interface AimdEditorMessages {
|
|
|
72
72
|
wysiwyg: string
|
|
73
73
|
wysiwygTitle: string
|
|
74
74
|
}
|
|
75
|
+
embeddedImage: {
|
|
76
|
+
summary: (format: string, size: string) => string
|
|
77
|
+
expand: string
|
|
78
|
+
collapse: string
|
|
79
|
+
copy: string
|
|
80
|
+
copied: string
|
|
81
|
+
manualCopy: string
|
|
82
|
+
}
|
|
75
83
|
common: {
|
|
76
84
|
loadingEditor: string
|
|
77
85
|
preview: string
|
|
@@ -316,6 +324,11 @@ const EN_US_MESSAGES: AimdEditorMessages = {
|
|
|
316
324
|
wysiwyg: 'Visual',
|
|
317
325
|
wysiwygTitle: 'WYSIWYG Mode',
|
|
318
326
|
},
|
|
327
|
+
embeddedImage: {
|
|
328
|
+
summary: (format, size) => `Embedded ${format} · ${size}`,
|
|
329
|
+
expand: 'Expand', collapse: 'Collapse', copy: 'Copy data URL', copied: 'Copied',
|
|
330
|
+
manualCopy: 'Selected for manual copy',
|
|
331
|
+
},
|
|
319
332
|
common: {
|
|
320
333
|
loadingEditor: 'Loading Editor...',
|
|
321
334
|
preview: 'Preview',
|
|
@@ -542,6 +555,11 @@ const ZH_CN_MESSAGES: AimdEditorMessages = {
|
|
|
542
555
|
wysiwyg: '可视化',
|
|
543
556
|
wysiwygTitle: '所见即所得模式',
|
|
544
557
|
},
|
|
558
|
+
embeddedImage: {
|
|
559
|
+
summary: (format, size) => `内嵌 ${format} · ${size}`,
|
|
560
|
+
expand: '展开', collapse: '收起', copy: '复制图片编码', copied: '已复制',
|
|
561
|
+
manualCopy: '已选中,可手动复制',
|
|
562
|
+
},
|
|
545
563
|
common: {
|
|
546
564
|
loadingEditor: '正在加载编辑器...',
|
|
547
565
|
preview: '预览',
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { Node } from '@milkdown/kit/prose/model'
|
|
2
|
+
import { Plugin, PluginKey } from '@milkdown/kit/prose/state'
|
|
3
|
+
import { Decoration, DecorationSet } from '@milkdown/kit/prose/view'
|
|
4
|
+
import { $prose } from '@milkdown/kit/utils'
|
|
5
|
+
import { embeddedImages, imageControls, type EmbeddedImage, type ImageLabels } from './embeddedImages'
|
|
6
|
+
|
|
7
|
+
type Match = EmbeddedImage & { imageNode: boolean }
|
|
8
|
+
const key = new PluginKey<{ matches: Match[], expanded: Set<number>, decorations: DecorationSet }>('aimd-embedded-images')
|
|
9
|
+
|
|
10
|
+
// Unchanged ProseMirror nodes keep their identity across transactions.
|
|
11
|
+
const imageCache = new WeakMap<Node, EmbeddedImage[]>()
|
|
12
|
+
function scan(doc: Node) {
|
|
13
|
+
const matches: Match[] = []
|
|
14
|
+
doc.descendants((node, pos) => {
|
|
15
|
+
const imageNode = node.type.name === 'image'
|
|
16
|
+
const text = imageNode ? node.attrs.src : node.text
|
|
17
|
+
if (typeof text !== 'string') return
|
|
18
|
+
let images = imageCache.get(node)
|
|
19
|
+
if (!images) {
|
|
20
|
+
images = embeddedImages(text)
|
|
21
|
+
imageCache.set(node, images)
|
|
22
|
+
}
|
|
23
|
+
for (const image of images) {
|
|
24
|
+
matches.push({ ...image, imageNode, from: pos + (imageNode ? 0 : image.from), to: pos + (imageNode ? node.nodeSize : image.to) })
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
return matches
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function embeddedImagePlugin(labels: () => ImageLabels) {
|
|
31
|
+
function build(doc: Node, matches: Match[], expanded: Set<number>) {
|
|
32
|
+
const decorations: Decoration[] = []
|
|
33
|
+
for (const match of matches) {
|
|
34
|
+
const open = expanded.has(match.from)
|
|
35
|
+
if (!open && !match.imageNode)
|
|
36
|
+
decorations.push(Decoration.inline(match.from, match.to, { style: 'display:none' }))
|
|
37
|
+
decorations.push(Decoration.widget(match.imageNode ? match.to : match.from, (view) => {
|
|
38
|
+
const controls = imageControls(match, labels(), open, () => {
|
|
39
|
+
view.dispatch(view.state.tr.setMeta(key, match.from))
|
|
40
|
+
view.dom.querySelector<HTMLButtonElement>('[data-aimd-image-pos="' + match.from + '"] button')?.focus()
|
|
41
|
+
})
|
|
42
|
+
controls.dataset.aimdImagePos = String(match.from)
|
|
43
|
+
if (match.imageNode && open) {
|
|
44
|
+
const source = document.createElement('code')
|
|
45
|
+
source.className = 'aimd-embedded-image-raw'
|
|
46
|
+
source.textContent = match.uri
|
|
47
|
+
controls.append(source)
|
|
48
|
+
}
|
|
49
|
+
return controls
|
|
50
|
+
}, { side: match.imageNode ? 1 : -1, stopEvent: () => true, ignoreSelection: true }))
|
|
51
|
+
}
|
|
52
|
+
return { matches, expanded, decorations: DecorationSet.create(doc, decorations) }
|
|
53
|
+
}
|
|
54
|
+
return $prose(() => new Plugin({
|
|
55
|
+
key,
|
|
56
|
+
state: {
|
|
57
|
+
init: (_, state) => build(state.doc, scan(state.doc), new Set()),
|
|
58
|
+
apply(tr, previous) {
|
|
59
|
+
const toggle = tr.getMeta(key)
|
|
60
|
+
const matches = tr.docChanged ? scan(tr.doc) : previous.matches
|
|
61
|
+
const expanded = tr.docChanged
|
|
62
|
+
? new Set([...previous.expanded].map(pos => tr.mapping.map(pos)).filter(pos => matches.some(m => m.from === pos)))
|
|
63
|
+
: new Set(previous.expanded)
|
|
64
|
+
if (typeof toggle === 'number') {
|
|
65
|
+
if (expanded.has(toggle)) expanded.delete(toggle)
|
|
66
|
+
else expanded.add(toggle)
|
|
67
|
+
} else if (tr.selectionSet && tr.selection.empty) {
|
|
68
|
+
const inside = matches.find(m => !m.imageNode && m.from < tr.selection.from && tr.selection.from < m.to)
|
|
69
|
+
if (inside) expanded.add(inside.from)
|
|
70
|
+
}
|
|
71
|
+
if (!tr.docChanged && toggle === undefined && expanded.size === previous.expanded.size) return previous
|
|
72
|
+
return build(tr.doc, matches, expanded)
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
props: { decorations: state => key.getState(state)?.decorations },
|
|
76
|
+
}))
|
|
77
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { editor, IRange } from 'monaco-editor'
|
|
2
|
+
import { embeddedImages, imageControls, type EmbeddedImage, type ImageLabels } from './embeddedImages'
|
|
3
|
+
|
|
4
|
+
type FoldableEditor = editor.IStandaloneCodeEditor & { setHiddenAreas(ranges: IRange[], owner: object): void }
|
|
5
|
+
|
|
6
|
+
// Monaco folds logical lines. The zone keeps the Markdown/YAML on either side
|
|
7
|
+
// readable, while copy, search, edits and undo still address the original model.
|
|
8
|
+
export function installSourceImageFolds(editor: FoldableEditor, fallback: HTMLElement, labels: () => ImageLabels) {
|
|
9
|
+
const owner = {}
|
|
10
|
+
const expanded = editor.createDecorationsCollection()
|
|
11
|
+
const layer = document.createElement('div')
|
|
12
|
+
layer.className = 'aimd-source-image-layer'
|
|
13
|
+
const widget = { getId: () => 'aimd.embedded-images', getDomNode: () => layer, getPosition: () => null }
|
|
14
|
+
editor.addOverlayWidget(widget)
|
|
15
|
+
function positionLayer() {
|
|
16
|
+
const layout = editor.getLayoutInfo()
|
|
17
|
+
layer.style.left = layout.contentLeft + 'px'
|
|
18
|
+
layer.style.width = layout.contentWidth + 'px'
|
|
19
|
+
layer.style.height = layout.height + 'px'
|
|
20
|
+
}
|
|
21
|
+
positionLayer()
|
|
22
|
+
const layout = editor.onDidLayoutChange(positionLayer)
|
|
23
|
+
let zones: string[] = []
|
|
24
|
+
let previousRows = new Map<number, { text: string, images: EmbeddedImage[] }>()
|
|
25
|
+
const lineRange = (line: number): IRange => ({ startLineNumber: line, endLineNumber: line, startColumn: 1, endColumn: 1 })
|
|
26
|
+
function render(focusLine?: number) {
|
|
27
|
+
const model = editor.getModel()
|
|
28
|
+
const container = editor.getDomNode()
|
|
29
|
+
if (!model || !container) return
|
|
30
|
+
const open = new Set(expanded.getRanges().map(range => range.startLineNumber))
|
|
31
|
+
const rows: { line: number, text: string, images: EmbeddedImage[] }[] = []
|
|
32
|
+
for (let line = 1; line <= model.getLineCount(); line++) {
|
|
33
|
+
const text = model.getLineContent(line)
|
|
34
|
+
const previous = previousRows.get(line)
|
|
35
|
+
const images = previous?.text === text ? previous.images : embeddedImages(text)
|
|
36
|
+
if (images.length) rows.push({ line, text, images })
|
|
37
|
+
}
|
|
38
|
+
previousRows = new Map(rows.map(row => [row.line, row]))
|
|
39
|
+
if (!rows.length && !zones.length && !fallback.childElementCount) return
|
|
40
|
+
layer.replaceChildren()
|
|
41
|
+
const hidden = rows.filter(row => !open.has(row.line))
|
|
42
|
+
// Monaco requires one visible line. For an image-only document put the
|
|
43
|
+
// same summary beside the editor until the user opens a line.
|
|
44
|
+
const onlyImages = hidden.length === model.getLineCount()
|
|
45
|
+
fallback.hidden = !onlyImages
|
|
46
|
+
fallback.replaceChildren()
|
|
47
|
+
container.style.display = onlyImages ? 'none' : ''
|
|
48
|
+
editor.setHiddenAreas(onlyImages ? [] : hidden.map(row => lineRange(row.line)), owner)
|
|
49
|
+
editor.changeViewZones(accessor => {
|
|
50
|
+
for (const id of zones) accessor.removeZone(id)
|
|
51
|
+
zones = []
|
|
52
|
+
for (const { line, text, images } of rows) {
|
|
53
|
+
const row = document.createElement('div')
|
|
54
|
+
row.className = 'aimd-source-image-line'
|
|
55
|
+
row.dataset.imageLine = String(line)
|
|
56
|
+
let last = 0
|
|
57
|
+
for (const image of images) {
|
|
58
|
+
if (!open.has(line)) row.append(text.slice(last, image.from))
|
|
59
|
+
row.append(imageControls(image, labels(), open.has(line), () => {
|
|
60
|
+
if (open.has(line)) open.delete(line)
|
|
61
|
+
else open.add(line)
|
|
62
|
+
expanded.set([...open].map(n => ({ range: lineRange(n), options: {} })))
|
|
63
|
+
render(line)
|
|
64
|
+
}))
|
|
65
|
+
last = image.to
|
|
66
|
+
}
|
|
67
|
+
if (!open.has(line)) row.append(text.slice(last))
|
|
68
|
+
if (onlyImages) fallback.append(row)
|
|
69
|
+
else {
|
|
70
|
+
// Monaco marks its view-zone wrapper aria-hidden. Reserve the space
|
|
71
|
+
// there and put the interactive controls in its accessible overlay.
|
|
72
|
+
layer.append(row)
|
|
73
|
+
zones.push(accessor.addZone({
|
|
74
|
+
afterLineNumber: line - 1, heightInPx: 36, showInHiddenAreas: true,
|
|
75
|
+
domNode: document.createElement('div'),
|
|
76
|
+
onDomNodeTop(top) {
|
|
77
|
+
row.style.top = top + 'px'
|
|
78
|
+
row.hidden = top <= -36 || top >= editor.getLayoutInfo().height
|
|
79
|
+
},
|
|
80
|
+
}))
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
if (focusLine) {
|
|
85
|
+
editor.layout()
|
|
86
|
+
const root = onlyImages ? fallback : container
|
|
87
|
+
root.querySelector<HTMLButtonElement>(`[data-image-line="${focusLine}"] button`)?.focus({ preventScroll: true })
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
render()
|
|
91
|
+
const changes = editor.onDidChangeModelContent(event => {
|
|
92
|
+
if (event.isFlush) expanded.clear()
|
|
93
|
+
else if (event.changes.every(({ range, text }) =>
|
|
94
|
+
range.startLineNumber === range.endLineNumber && !/[\r\n]/.test(text)
|
|
95
|
+
&& !previousRows.has(range.startLineNumber)
|
|
96
|
+
&& !/data:image\//i.test(editor.getModel()!.getLineContent(range.startLineNumber)),
|
|
97
|
+
)) return
|
|
98
|
+
render()
|
|
99
|
+
})
|
|
100
|
+
const models = editor.onDidChangeModel(() => { expanded.clear(); render() })
|
|
101
|
+
return {
|
|
102
|
+
refresh: render,
|
|
103
|
+
dispose() {
|
|
104
|
+
layout.dispose()
|
|
105
|
+
editor.removeOverlayWidget(widget)
|
|
106
|
+
changes.dispose()
|
|
107
|
+
models.dispose()
|
|
108
|
+
expanded.clear()
|
|
109
|
+
editor.setHiddenAreas([], owner)
|
|
110
|
+
editor.changeViewZones(accessor => zones.forEach(id => accessor.removeZone(id)))
|
|
111
|
+
},
|
|
112
|
+
}
|
|
113
|
+
}
|