@8btc/mditor 0.0.12 → 0.0.14
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/css/content-theme/dark.css +24 -3
- package/dist/index.css +53 -10
- package/dist/index.js +430 -147
- package/dist/index.min.js +1 -1
- package/dist/method.d.ts +2 -0
- package/dist/method.js +402 -106
- package/dist/method.min.js +1 -1
- package/dist/ts/util/attachLineNumbers.d.ts +6 -5
- package/package.json +1 -1
- package/src/assets/less/_line-number.less +22 -10
- package/src/method.ts +4 -1
- package/src/ts/markdown/previewRender.ts +24 -22
- package/src/ts/util/attachLineNumbers.ts +382 -98
- package/src/ts/wysiwyg/index.ts +27 -21
package/src/ts/wysiwyg/index.ts
CHANGED
|
@@ -69,7 +69,7 @@ class WYSIWYG {
|
|
|
69
69
|
<div class="vditor-panel vditor-panel--none"></div>
|
|
70
70
|
<div class="vditor-selection-popover">
|
|
71
71
|
<div class="vditor-selection-popover__actions">
|
|
72
|
-
<button type="button" data-action="ai" aria-label="AI编辑" class="vditor-selection-popover__btn"
|
|
72
|
+
<button type="button" data-action="ai" aria-label="AI编辑" class="vditor-selection-popover__btn">✨ AI编辑</button>
|
|
73
73
|
<button type="button" data-action="cut" aria-label="剪切" class="vditor-selection-popover__btn">剪切</button>
|
|
74
74
|
<button type="button" data-action="copy" aria-label="复制" class="vditor-selection-popover__btn">复制</button>
|
|
75
75
|
</div>
|
|
@@ -109,12 +109,18 @@ class WYSIWYG {
|
|
|
109
109
|
}
|
|
110
110
|
this.hideSelectionPopover();
|
|
111
111
|
};
|
|
112
|
-
//
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
112
|
+
// 阻止点击 popover 内任何区域时导致编辑器失去焦点
|
|
113
|
+
// 但不影响 textarea 获取焦点和按钮点击
|
|
114
|
+
this.selectPopover.addEventListener("mousedown", (event) => {
|
|
115
|
+
const target = event.target as HTMLElement;
|
|
116
|
+
// 如果点击的是 textarea 或 button,允许默认行为
|
|
117
|
+
if (target.tagName === "TEXTAREA" || target.tagName === "BUTTON") {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
// 其他情况阻止默认行为,防止编辑器失去焦点
|
|
121
|
+
event.preventDefault();
|
|
122
|
+
event.stopPropagation();
|
|
123
|
+
});
|
|
118
124
|
|
|
119
125
|
// 输入验证
|
|
120
126
|
if (this.popoverInput) {
|
|
@@ -141,18 +147,18 @@ class WYSIWYG {
|
|
|
141
147
|
cutEvent(vditor, this.element, this.copy);
|
|
142
148
|
|
|
143
149
|
// 选择浮窗按钮事件绑定
|
|
144
|
-
const aiBtn = this.selectPopover.querySelector(
|
|
145
|
-
|
|
146
|
-
) as HTMLButtonElement | null;
|
|
147
|
-
if (aiBtn) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
150
|
+
// const aiBtn = this.selectPopover.querySelector(
|
|
151
|
+
// '[data-action="ai"]'
|
|
152
|
+
// ) as HTMLButtonElement | null;
|
|
153
|
+
// if (aiBtn) {
|
|
154
|
+
// /**
|
|
155
|
+
// * AI编辑按钮占位事件
|
|
156
|
+
// * - 当前仅输出日志,不执行编辑逻辑
|
|
157
|
+
// */
|
|
158
|
+
// aiBtn.onclick = () => {
|
|
159
|
+
// console.log("[Selection AI Edit] clicked");
|
|
160
|
+
// };
|
|
161
|
+
// }
|
|
156
162
|
const copyBtn = this.selectPopover.querySelector(
|
|
157
163
|
'[data-action="copy"]'
|
|
158
164
|
) as HTMLButtonElement | null;
|
|
@@ -224,8 +230,8 @@ class WYSIWYG {
|
|
|
224
230
|
item.getAttribute("data-block") === "0" &&
|
|
225
231
|
index === contents.childNodes.length - 1 &&
|
|
226
232
|
rangeClone.endOffset <
|
|
227
|
-
|
|
228
|
-
|
|
233
|
+
rangeClone.endContainer.textContent
|
|
234
|
+
.length
|
|
229
235
|
) {
|
|
230
236
|
item.innerHTML = `<span class="vditor-comment" data-cmtids="${id}">${item.innerHTML}</span>`;
|
|
231
237
|
blockEndElement = item;
|