autumnnote 1.7.0 → 1.8.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/dist/autumnnote.es.js +161 -15
- package/dist/autumnnote.es.js.map +1 -1
- package/dist/autumnnote.umd.js +239 -76
- package/dist/autumnnote.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/js/Context.js +26 -1
- package/src/js/i18n/de.js +7 -0
- package/src/js/i18n/en.js +8 -0
- package/src/js/i18n/es.js +7 -0
- package/src/js/i18n/fr.js +8 -1
- package/src/js/i18n/ja.js +7 -0
- package/src/js/i18n/ko.js +7 -0
- package/src/js/i18n/vi.js +7 -0
- package/src/js/i18n/zh.js +7 -0
- package/src/js/index.js +5 -2
- package/src/js/module/Buttons.js +49 -0
- package/src/js/module/Clipboard.js +12 -0
- package/src/js/module/FindReplace.js +24 -5
- package/src/js/module/ImageResizer.js +8 -7
- package/src/js/module/Mention.js +4 -1
- package/types/index.d.ts +82 -1
package/dist/autumnnote.umd.js
CHANGED
|
@@ -968,6 +968,13 @@
|
|
|
968
968
|
}
|
|
969
969
|
};
|
|
970
970
|
var removeFormatBtn = btn("removeFormat", "remove-format", "Remove Format", () => execCommand("removeFormat"));
|
|
971
|
+
var directionBtn = btn("direction", "direction", "Toggle Text Direction (LTR / RTL)", (ctx) => {
|
|
972
|
+
const editable = ctx.layoutInfo.editable;
|
|
973
|
+
const next = (editable.getAttribute("dir") || "ltr") === "ltr" ? "rtl" : "ltr";
|
|
974
|
+
editable.setAttribute("dir", next);
|
|
975
|
+
editable.style.textAlign = next === "rtl" ? "right" : "left";
|
|
976
|
+
ctx.invoke("editor.afterCommand");
|
|
977
|
+
});
|
|
971
978
|
/** @type {DropdownDef} */
|
|
972
979
|
var fontFamilyBtn = {
|
|
973
980
|
name: "fontFamily",
|
|
@@ -1090,9 +1097,122 @@
|
|
|
1090
1097
|
var fullscreenBtn = btn("fullscreen", "expand", "Fullscreen", (ctx) => ctx.invoke("fullscreen.toggle"), (ctx) => ctx.invoke("fullscreen.isActive"));
|
|
1091
1098
|
var shortcutsBtn = btn("shortcuts", "keyboard", "Keyboard Shortcuts (Ctrl+Shift+/)", (ctx) => ctx.invoke("shortcutsDialog.show"));
|
|
1092
1099
|
var findBtn = btn("find", "search", "Find (Ctrl+F)", (ctx) => ctx.invoke("findReplace.show", "find"));
|
|
1100
|
+
var findReplaceBtn = btn("findReplace", "find-replace", "Find & Replace (Ctrl+H)", (ctx) => ctx.invoke("findReplace.show", "replace"));
|
|
1093
1101
|
var inlineCodeBtn = btn("inlineCode", "inline-code", "Inline Code (Ctrl+`)", (ctx) => ctx.invoke("editor.inlineCode"), () => isInlineCode());
|
|
1094
1102
|
var checklistBtn = btn("checklist", "checklist", "Checklist", (ctx) => ctx.invoke("editor.toggleChecklist"), () => isInChecklist());
|
|
1095
1103
|
var printBtn = btn("print", "print", "Print", (ctx) => ctx.invoke("editor.print"));
|
|
1104
|
+
/** @type {{ name: string, type: 'colorpicker', icon: string, tooltip: string, defaultColor: string, action: Function }} */
|
|
1105
|
+
var foreColorBtn = {
|
|
1106
|
+
name: "foreColor",
|
|
1107
|
+
type: "colorpicker",
|
|
1108
|
+
icon: "foreColor",
|
|
1109
|
+
tooltip: "Text Color",
|
|
1110
|
+
defaultColor: "#e11d48",
|
|
1111
|
+
action: (ctx, color) => foreColor(color)
|
|
1112
|
+
};
|
|
1113
|
+
/** @type {{ name: string, type: 'colorpicker', icon: string, tooltip: string, defaultColor: string, action: Function }} */
|
|
1114
|
+
var backColorBtn = {
|
|
1115
|
+
name: "backColor",
|
|
1116
|
+
type: "colorpicker",
|
|
1117
|
+
icon: "backColor",
|
|
1118
|
+
tooltip: "Highlight Color",
|
|
1119
|
+
defaultColor: "#fbbf24",
|
|
1120
|
+
action: (ctx, color) => backColor(color)
|
|
1121
|
+
};
|
|
1122
|
+
/**
|
|
1123
|
+
* The default toolbar button groups.
|
|
1124
|
+
* Each sub-array is a button group (separated by a divider).
|
|
1125
|
+
*/
|
|
1126
|
+
var defaultToolbar = [
|
|
1127
|
+
[
|
|
1128
|
+
paragraphStyleBtn,
|
|
1129
|
+
fontFamilyBtn,
|
|
1130
|
+
fontSizeBtn,
|
|
1131
|
+
lineHeightBtn
|
|
1132
|
+
],
|
|
1133
|
+
[undoBtn, redoBtn],
|
|
1134
|
+
[
|
|
1135
|
+
boldBtn,
|
|
1136
|
+
italicBtn,
|
|
1137
|
+
underlineBtn,
|
|
1138
|
+
strikeBtn,
|
|
1139
|
+
inlineCodeBtn
|
|
1140
|
+
],
|
|
1141
|
+
[superscriptBtn, subscriptBtn],
|
|
1142
|
+
[foreColorBtn, backColorBtn],
|
|
1143
|
+
[
|
|
1144
|
+
alignLeftBtn,
|
|
1145
|
+
alignCenterBtn,
|
|
1146
|
+
alignRightBtn,
|
|
1147
|
+
alignJustifyBtn
|
|
1148
|
+
],
|
|
1149
|
+
[
|
|
1150
|
+
ulBtn,
|
|
1151
|
+
olBtn,
|
|
1152
|
+
checklistBtn,
|
|
1153
|
+
indentBtn,
|
|
1154
|
+
outdentBtn
|
|
1155
|
+
],
|
|
1156
|
+
[
|
|
1157
|
+
hrBtn,
|
|
1158
|
+
linkBtn,
|
|
1159
|
+
imageBtn,
|
|
1160
|
+
videoBtn,
|
|
1161
|
+
tableBtn,
|
|
1162
|
+
emojiBtn,
|
|
1163
|
+
iconBtn
|
|
1164
|
+
],
|
|
1165
|
+
[
|
|
1166
|
+
removeFormatBtn,
|
|
1167
|
+
codeviewBtn,
|
|
1168
|
+
fullscreenBtn,
|
|
1169
|
+
findBtn,
|
|
1170
|
+
printBtn,
|
|
1171
|
+
shortcutsBtn
|
|
1172
|
+
]
|
|
1173
|
+
];
|
|
1174
|
+
var buttons = {
|
|
1175
|
+
boldBtn,
|
|
1176
|
+
italicBtn,
|
|
1177
|
+
underlineBtn,
|
|
1178
|
+
strikeBtn,
|
|
1179
|
+
superscriptBtn,
|
|
1180
|
+
subscriptBtn,
|
|
1181
|
+
alignLeftBtn,
|
|
1182
|
+
alignCenterBtn,
|
|
1183
|
+
alignRightBtn,
|
|
1184
|
+
alignJustifyBtn,
|
|
1185
|
+
ulBtn,
|
|
1186
|
+
olBtn,
|
|
1187
|
+
indentBtn,
|
|
1188
|
+
outdentBtn,
|
|
1189
|
+
undoBtn,
|
|
1190
|
+
redoBtn,
|
|
1191
|
+
hrBtn,
|
|
1192
|
+
linkBtn,
|
|
1193
|
+
imageBtn,
|
|
1194
|
+
videoBtn,
|
|
1195
|
+
emojiBtn,
|
|
1196
|
+
iconBtn,
|
|
1197
|
+
tableBtn,
|
|
1198
|
+
fontSizeBtn,
|
|
1199
|
+
removeFormatBtn,
|
|
1200
|
+
directionBtn,
|
|
1201
|
+
fontFamilyBtn,
|
|
1202
|
+
paragraphStyleBtn,
|
|
1203
|
+
lineHeightBtn,
|
|
1204
|
+
codeviewBtn,
|
|
1205
|
+
fullscreenBtn,
|
|
1206
|
+
shortcutsBtn,
|
|
1207
|
+
findBtn,
|
|
1208
|
+
findReplaceBtn,
|
|
1209
|
+
inlineCodeBtn,
|
|
1210
|
+
checklistBtn,
|
|
1211
|
+
printBtn,
|
|
1212
|
+
foreColorBtn,
|
|
1213
|
+
backColorBtn,
|
|
1214
|
+
defaultToolbar
|
|
1215
|
+
};
|
|
1096
1216
|
//#endregion
|
|
1097
1217
|
//#region src/js/settings.js
|
|
1098
1218
|
/**
|
|
@@ -1166,68 +1286,7 @@
|
|
|
1166
1286
|
maxHeight: 0,
|
|
1167
1287
|
focus: false,
|
|
1168
1288
|
resizable: true,
|
|
1169
|
-
toolbar:
|
|
1170
|
-
[
|
|
1171
|
-
paragraphStyleBtn,
|
|
1172
|
-
fontFamilyBtn,
|
|
1173
|
-
fontSizeBtn,
|
|
1174
|
-
lineHeightBtn
|
|
1175
|
-
],
|
|
1176
|
-
[undoBtn, redoBtn],
|
|
1177
|
-
[
|
|
1178
|
-
boldBtn,
|
|
1179
|
-
italicBtn,
|
|
1180
|
-
underlineBtn,
|
|
1181
|
-
strikeBtn,
|
|
1182
|
-
inlineCodeBtn
|
|
1183
|
-
],
|
|
1184
|
-
[superscriptBtn, subscriptBtn],
|
|
1185
|
-
[{
|
|
1186
|
-
name: "foreColor",
|
|
1187
|
-
type: "colorpicker",
|
|
1188
|
-
icon: "foreColor",
|
|
1189
|
-
tooltip: "Text Color",
|
|
1190
|
-
defaultColor: "#e11d48",
|
|
1191
|
-
action: (ctx, color) => foreColor(color)
|
|
1192
|
-
}, {
|
|
1193
|
-
name: "backColor",
|
|
1194
|
-
type: "colorpicker",
|
|
1195
|
-
icon: "backColor",
|
|
1196
|
-
tooltip: "Highlight Color",
|
|
1197
|
-
defaultColor: "#fbbf24",
|
|
1198
|
-
action: (ctx, color) => backColor(color)
|
|
1199
|
-
}],
|
|
1200
|
-
[
|
|
1201
|
-
alignLeftBtn,
|
|
1202
|
-
alignCenterBtn,
|
|
1203
|
-
alignRightBtn,
|
|
1204
|
-
alignJustifyBtn
|
|
1205
|
-
],
|
|
1206
|
-
[
|
|
1207
|
-
ulBtn,
|
|
1208
|
-
olBtn,
|
|
1209
|
-
checklistBtn,
|
|
1210
|
-
indentBtn,
|
|
1211
|
-
outdentBtn
|
|
1212
|
-
],
|
|
1213
|
-
[
|
|
1214
|
-
hrBtn,
|
|
1215
|
-
linkBtn,
|
|
1216
|
-
imageBtn,
|
|
1217
|
-
videoBtn,
|
|
1218
|
-
tableBtn,
|
|
1219
|
-
emojiBtn,
|
|
1220
|
-
iconBtn
|
|
1221
|
-
],
|
|
1222
|
-
[
|
|
1223
|
-
removeFormatBtn,
|
|
1224
|
-
codeviewBtn,
|
|
1225
|
-
fullscreenBtn,
|
|
1226
|
-
findBtn,
|
|
1227
|
-
printBtn,
|
|
1228
|
-
shortcutsBtn
|
|
1229
|
-
]
|
|
1230
|
-
],
|
|
1289
|
+
toolbar: defaultToolbar,
|
|
1231
1290
|
useBootstrap: false,
|
|
1232
1291
|
toolbarButtonClass: "btn btn-sm btn-light",
|
|
1233
1292
|
useFontAwesome: true,
|
|
@@ -1448,6 +1507,7 @@
|
|
|
1448
1507
|
findPlaceholder: "Find…",
|
|
1449
1508
|
searchAriaLabel: "Search text",
|
|
1450
1509
|
caseSensitive: "\xA0Case sensitive",
|
|
1510
|
+
wholeWord: "Whole Word",
|
|
1451
1511
|
prevBtn: "← Prev",
|
|
1452
1512
|
nextBtn: "Next →",
|
|
1453
1513
|
replacePlaceholder: "Replace with…",
|
|
@@ -1458,6 +1518,12 @@
|
|
|
1458
1518
|
useRegex: "Use Regular Expression",
|
|
1459
1519
|
close: "×"
|
|
1460
1520
|
},
|
|
1521
|
+
autoSaveRestore: {
|
|
1522
|
+
found: "Draft found. Restore?",
|
|
1523
|
+
foundAt: "Draft from {date}. Restore?",
|
|
1524
|
+
restore: "Restore",
|
|
1525
|
+
discard: "Discard"
|
|
1526
|
+
},
|
|
1461
1527
|
shortcutsDialog: {
|
|
1462
1528
|
title: "Keyboard Shortcuts",
|
|
1463
1529
|
ariaLabel: "Keyboard Shortcuts",
|
|
@@ -2020,6 +2086,12 @@
|
|
|
2020
2086
|
errors: {
|
|
2021
2087
|
imageFormat: (type) => `Định dạng "${type}" không được hỗ trợ hiển thị trên trình duyệt. Vui lòng chuyển đổi sang JPEG, PNG hoặc WebP.`,
|
|
2022
2088
|
imageSize: (maxSize) => `Tệp hình ảnh quá lớn. Kích thước tối đa cho phép là ${maxSize} MB.`
|
|
2089
|
+
},
|
|
2090
|
+
autoSaveRestore: {
|
|
2091
|
+
found: "Tìm thấy bản nháp. Khôi phục?",
|
|
2092
|
+
foundAt: "Bản nháp từ {date}. Khôi phục?",
|
|
2093
|
+
restore: "Khôi phục",
|
|
2094
|
+
discard: "Bỏ qua"
|
|
2023
2095
|
}
|
|
2024
2096
|
},
|
|
2025
2097
|
ja: {
|
|
@@ -2358,6 +2430,12 @@
|
|
|
2358
2430
|
errors: {
|
|
2359
2431
|
imageFormat: (type) => `形式 "${type}" はブラウザでの表示をサポートしていません。JPEG、PNG、または WebP に変換してください。`,
|
|
2360
2432
|
imageSize: (maxSize) => `画像ファイルが大きすぎます。最大許容サイズは ${maxSize} MB です。`
|
|
2433
|
+
},
|
|
2434
|
+
autoSaveRestore: {
|
|
2435
|
+
found: "下書きが見つかりました。復元しますか?",
|
|
2436
|
+
foundAt: "{date} の下書きが見つかりました。復元しますか?",
|
|
2437
|
+
restore: "復元",
|
|
2438
|
+
discard: "破棄"
|
|
2361
2439
|
}
|
|
2362
2440
|
},
|
|
2363
2441
|
zh: {
|
|
@@ -2696,6 +2774,12 @@
|
|
|
2696
2774
|
errors: {
|
|
2697
2775
|
imageFormat: (type) => `格式 "${type}" 不支持在浏览器中显示。请转换为 JPEG、PNG 或 WebP。`,
|
|
2698
2776
|
imageSize: (maxSize) => `图片文件过大。最大允许大小为 ${maxSize} MB。`
|
|
2777
|
+
},
|
|
2778
|
+
autoSaveRestore: {
|
|
2779
|
+
found: "找到草稿。是否恢复?",
|
|
2780
|
+
foundAt: "发现 {date} 的草稿。是否恢复?",
|
|
2781
|
+
restore: "恢复",
|
|
2782
|
+
discard: "放弃"
|
|
2699
2783
|
}
|
|
2700
2784
|
},
|
|
2701
2785
|
fr: {
|
|
@@ -3034,6 +3118,12 @@
|
|
|
3034
3118
|
errors: {
|
|
3035
3119
|
imageFormat: (type) => `Le format "${type}" n'est pas pris en charge par le navigateur. Veuillez le convertir en JPEG, PNG ou WebP.`,
|
|
3036
3120
|
imageSize: (maxSize) => `Le fichier image est trop volumineux. La taille maximale autorisée est de ${maxSize}\u00a0Mo.`
|
|
3121
|
+
},
|
|
3122
|
+
autoSaveRestore: {
|
|
3123
|
+
found: "Brouillon trouvé. Restaurer ?",
|
|
3124
|
+
foundAt: "Brouillon du {date}. Restaurer ?",
|
|
3125
|
+
restore: "Restaurer",
|
|
3126
|
+
discard: "Ignorer"
|
|
3037
3127
|
}
|
|
3038
3128
|
},
|
|
3039
3129
|
de: {
|
|
@@ -3372,6 +3462,12 @@
|
|
|
3372
3462
|
errors: {
|
|
3373
3463
|
imageFormat: (type) => `Das Format „${type}" wird in Webbrowsern nicht unterstützt. Bitte konvertieren Sie es zuerst in JPEG, PNG oder WebP.`,
|
|
3374
3464
|
imageSize: (maxSize) => `Die Bilddatei ist zu groß. Die maximal zulässige Größe beträgt ${maxSize} MB.`
|
|
3465
|
+
},
|
|
3466
|
+
autoSaveRestore: {
|
|
3467
|
+
found: "Entwurf gefunden. Wiederherstellen?",
|
|
3468
|
+
foundAt: "Entwurf vom {date}. Wiederherstellen?",
|
|
3469
|
+
restore: "Wiederherstellen",
|
|
3470
|
+
discard: "Verwerfen"
|
|
3375
3471
|
}
|
|
3376
3472
|
},
|
|
3377
3473
|
es: {
|
|
@@ -3710,6 +3806,12 @@
|
|
|
3710
3806
|
errors: {
|
|
3711
3807
|
imageFormat: (type) => `El formato "${type}" no es compatible con los navegadores web. Por favor, conviértalo primero a JPEG, PNG o WebP.`,
|
|
3712
3808
|
imageSize: (maxSize) => `El archivo de imagen es demasiado grande. El tamaño máximo permitido es ${maxSize} MB.`
|
|
3809
|
+
},
|
|
3810
|
+
autoSaveRestore: {
|
|
3811
|
+
found: "Borrador encontrado. ¿Restaurar?",
|
|
3812
|
+
foundAt: "Borrador del {date}. ¿Restaurar?",
|
|
3813
|
+
restore: "Restaurar",
|
|
3814
|
+
discard: "Descartar"
|
|
3713
3815
|
}
|
|
3714
3816
|
},
|
|
3715
3817
|
ko: {
|
|
@@ -4048,6 +4150,12 @@
|
|
|
4048
4150
|
errors: {
|
|
4049
4151
|
imageFormat: (type) => `"${type}" 형식은 웹 브라우저에서 지원되지 않습니다. JPEG, PNG 또는 WebP로 변환해 주세요.`,
|
|
4050
4152
|
imageSize: (maxSize) => `이미지 파일이 너무 큽니다. 최대 허용 크기는 ${maxSize} MB입니다.`
|
|
4153
|
+
},
|
|
4154
|
+
autoSaveRestore: {
|
|
4155
|
+
found: "초안을 찾았습니다. 복원하시겠습니까?",
|
|
4156
|
+
foundAt: "{date}의 초안을 찾았습니다. 복원하시겠습니까?",
|
|
4157
|
+
restore: "복원",
|
|
4158
|
+
discard: "삭제"
|
|
4051
4159
|
}
|
|
4052
4160
|
}
|
|
4053
4161
|
};
|
|
@@ -6673,6 +6781,15 @@
|
|
|
6673
6781
|
if (!clipboardData) return;
|
|
6674
6782
|
const forcePlain = this._forcePlain;
|
|
6675
6783
|
this._forcePlain = false;
|
|
6784
|
+
const maxBytes = (this.options.maxPasteSize ?? 5) * 1024 * 1024;
|
|
6785
|
+
if (maxBytes > 0) {
|
|
6786
|
+
const text = clipboardData.getData("text/plain") || "";
|
|
6787
|
+
const html = clipboardData.getData("text/html") || "";
|
|
6788
|
+
if (Math.max(text.length, html.length) > maxBytes) {
|
|
6789
|
+
event.preventDefault();
|
|
6790
|
+
return;
|
|
6791
|
+
}
|
|
6792
|
+
}
|
|
6676
6793
|
if (clipboardData.items) {
|
|
6677
6794
|
const imageItems = Array.from(clipboardData.items).filter((item) => item.kind === "file" && item.type.startsWith("image/"));
|
|
6678
6795
|
if (imageItems.length > 0) {
|
|
@@ -7795,6 +7912,7 @@
|
|
|
7795
7912
|
const aspectRatio = startW / (startH || 1);
|
|
7796
7913
|
const isCorner = pos.length === 2;
|
|
7797
7914
|
const editable = this.context.layoutInfo.editable;
|
|
7915
|
+
const minSz = this.context.options?.minImageSize ?? 20;
|
|
7798
7916
|
let _raf = null;
|
|
7799
7917
|
const onMove = (me) => {
|
|
7800
7918
|
if (_raf !== null) return;
|
|
@@ -7807,15 +7925,15 @@
|
|
|
7807
7925
|
const maxW = editable.clientWidth || Infinity;
|
|
7808
7926
|
let newW = startW;
|
|
7809
7927
|
let newH = startH;
|
|
7810
|
-
if (pos.includes("e")) newW = Math.max(
|
|
7811
|
-
if (pos.includes("w")) newW = Math.max(
|
|
7812
|
-
if (pos.includes("s")) newH = Math.max(
|
|
7813
|
-
if (pos.includes("n")) newH = Math.max(
|
|
7928
|
+
if (pos.includes("e")) newW = Math.max(minSz, startW + dx);
|
|
7929
|
+
if (pos.includes("w")) newW = Math.max(minSz, startW - dx);
|
|
7930
|
+
if (pos.includes("s")) newH = Math.max(minSz, startH + dy);
|
|
7931
|
+
if (pos.includes("n")) newH = Math.max(minSz, startH - dy);
|
|
7814
7932
|
newW = Math.min(newW, maxW);
|
|
7815
|
-
if (isCorner) if (Math.abs(dx) >= Math.abs(dy)) newH = Math.max(
|
|
7933
|
+
if (isCorner) if (Math.abs(dx) >= Math.abs(dy)) newH = Math.max(minSz, Math.round(newW / aspectRatio));
|
|
7816
7934
|
else {
|
|
7817
|
-
newW = Math.min(Math.max(
|
|
7818
|
-
newH = Math.max(
|
|
7935
|
+
newW = Math.min(Math.max(minSz, Math.round(newH * aspectRatio)), maxW);
|
|
7936
|
+
newH = Math.max(minSz, Math.round(newW / aspectRatio));
|
|
7819
7937
|
}
|
|
7820
7938
|
img.style.width = `${newW}px`;
|
|
7821
7939
|
img.style.height = `${newH}px`;
|
|
@@ -14258,6 +14376,7 @@
|
|
|
14258
14376
|
this._currentIndex = -1;
|
|
14259
14377
|
this._caseSensitive = false;
|
|
14260
14378
|
this._useRegex = false;
|
|
14379
|
+
this._wholeWord = false;
|
|
14261
14380
|
/** @type {'find'|'replace'} */
|
|
14262
14381
|
this._mode = "find";
|
|
14263
14382
|
/** Cached compiled regex — reused when query and case-sensitivity are unchanged */
|
|
@@ -14265,6 +14384,7 @@
|
|
|
14265
14384
|
this._lastQuery = null;
|
|
14266
14385
|
this._lastCaseSensitive = null;
|
|
14267
14386
|
this._lastUseRegex = null;
|
|
14387
|
+
this._lastWholeWord = null;
|
|
14268
14388
|
this._focusTimer = null;
|
|
14269
14389
|
}
|
|
14270
14390
|
destroy() {
|
|
@@ -14375,6 +14495,13 @@
|
|
|
14375
14495
|
"aria-label": L.useRegex
|
|
14376
14496
|
});
|
|
14377
14497
|
regexBtn.textContent = ".*";
|
|
14498
|
+
const wholeWordBtn = createElement("button", {
|
|
14499
|
+
type: "button",
|
|
14500
|
+
class: "an-fr-icon-btn",
|
|
14501
|
+
title: L.wholeWord,
|
|
14502
|
+
"aria-label": L.wholeWord
|
|
14503
|
+
});
|
|
14504
|
+
wholeWordBtn.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="7" width="18" height="10" rx="2"/><line x1="7" y1="21" x2="7" y2="17"/><line x1="17" y1="21" x2="17" y2="17"/></svg>`;
|
|
14378
14505
|
const prevBtn = createElement("button", {
|
|
14379
14506
|
type: "button",
|
|
14380
14507
|
class: "an-fr-icon-btn",
|
|
@@ -14391,7 +14518,7 @@
|
|
|
14391
14518
|
nextBtn.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg>`;
|
|
14392
14519
|
const counter = createElement("span", { class: "an-fr-counter" });
|
|
14393
14520
|
this._counterEl = counter;
|
|
14394
|
-
searchBar.append(findInput, caseCheckbox, caseBtn, regexBtn, prevBtn, nextBtn, counter);
|
|
14521
|
+
searchBar.append(findInput, caseCheckbox, caseBtn, regexBtn, wholeWordBtn, prevBtn, nextBtn, counter);
|
|
14395
14522
|
box.appendChild(searchBar);
|
|
14396
14523
|
const replaceRow = createElement("div", { class: "an-fr-replace-row" });
|
|
14397
14524
|
replaceRow.style.display = "none";
|
|
@@ -14459,7 +14586,14 @@
|
|
|
14459
14586
|
this._lastQuery = null;
|
|
14460
14587
|
this._onSearch();
|
|
14461
14588
|
});
|
|
14462
|
-
|
|
14589
|
+
const dWholeWord = on(wholeWordBtn, "click", () => {
|
|
14590
|
+
this._wholeWord = !this._wholeWord;
|
|
14591
|
+
wholeWordBtn.classList.toggle("an-fr-icon-btn--active", this._wholeWord);
|
|
14592
|
+
this._queryRegex = null;
|
|
14593
|
+
this._lastQuery = null;
|
|
14594
|
+
this._onSearch();
|
|
14595
|
+
});
|
|
14596
|
+
this._disposers.push(d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, dRegex, dWholeWord);
|
|
14463
14597
|
return overlay;
|
|
14464
14598
|
}
|
|
14465
14599
|
_onSearch() {
|
|
@@ -14517,10 +14651,11 @@
|
|
|
14517
14651
|
*/
|
|
14518
14652
|
_findRawMatches(query, root) {
|
|
14519
14653
|
const results = [];
|
|
14520
|
-
if (this._lastQuery !== query || this._lastCaseSensitive !== this._caseSensitive || this._lastUseRegex !== this._useRegex) {
|
|
14654
|
+
if (this._lastQuery !== query || this._lastCaseSensitive !== this._caseSensitive || this._lastUseRegex !== this._useRegex || this._lastWholeWord !== this._wholeWord) {
|
|
14521
14655
|
const flags = this._caseSensitive ? "g" : "gi";
|
|
14522
14656
|
try {
|
|
14523
|
-
|
|
14657
|
+
let pattern = this._useRegex ? query : query.replace(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`);
|
|
14658
|
+
if (this._wholeWord) pattern = `\\b${pattern}\\b`;
|
|
14524
14659
|
this._queryRegex = new RegExp(pattern, flags);
|
|
14525
14660
|
} catch (_) {
|
|
14526
14661
|
this._queryRegex = null;
|
|
@@ -14528,6 +14663,7 @@
|
|
|
14528
14663
|
this._lastQuery = query;
|
|
14529
14664
|
this._lastCaseSensitive = this._caseSensitive;
|
|
14530
14665
|
this._lastUseRegex = this._useRegex;
|
|
14666
|
+
this._lastWholeWord = this._wholeWord;
|
|
14531
14667
|
}
|
|
14532
14668
|
if (!this._queryRegex) return results;
|
|
14533
14669
|
const re = this._queryRegex;
|
|
@@ -16074,7 +16210,10 @@
|
|
|
16074
16210
|
this._showDropdown();
|
|
16075
16211
|
};
|
|
16076
16212
|
const result = this._cfg.onSearch(this._query, cb);
|
|
16077
|
-
if (result && typeof result.then === "function") result.then(cb).catch(() =>
|
|
16213
|
+
if (result && typeof result.then === "function") result.then(cb).catch((err) => {
|
|
16214
|
+
this._hideDropdown();
|
|
16215
|
+
if (typeof this._cfg.onError === "function") this._cfg.onError(err);
|
|
16216
|
+
});
|
|
16078
16217
|
}, this._cfg.debounce);
|
|
16079
16218
|
}
|
|
16080
16219
|
_onKeydown(e) {
|
|
@@ -16342,10 +16481,13 @@
|
|
|
16342
16481
|
}
|
|
16343
16482
|
/**
|
|
16344
16483
|
* Returns the current HTML content of the editor.
|
|
16484
|
+
* Zero-width spaces (U+200B) inserted by inline editing helpers are stripped
|
|
16485
|
+
* from the output so they don't leak into the consumer's HTML.
|
|
16345
16486
|
* @returns {string}
|
|
16346
16487
|
*/
|
|
16347
16488
|
getHTML() {
|
|
16348
|
-
|
|
16489
|
+
const html = this.invoke("editor.getHTML");
|
|
16490
|
+
return typeof html === "string" ? html.replace(//g, "") : html;
|
|
16349
16491
|
}
|
|
16350
16492
|
/**
|
|
16351
16493
|
* Sets the HTML content of the editor.
|
|
@@ -16516,6 +16658,25 @@
|
|
|
16516
16658
|
}));
|
|
16517
16659
|
}
|
|
16518
16660
|
/**
|
|
16661
|
+
* Moves focus into the editable area.
|
|
16662
|
+
*/
|
|
16663
|
+
focus() {
|
|
16664
|
+
this.layoutInfo.editable.focus();
|
|
16665
|
+
}
|
|
16666
|
+
/**
|
|
16667
|
+
* Removes focus from the editable area.
|
|
16668
|
+
*/
|
|
16669
|
+
blur() {
|
|
16670
|
+
this.layoutInfo.editable.blur();
|
|
16671
|
+
}
|
|
16672
|
+
/**
|
|
16673
|
+
* Returns true when the editor is currently in fullscreen mode.
|
|
16674
|
+
* @returns {boolean}
|
|
16675
|
+
*/
|
|
16676
|
+
isFullscreen() {
|
|
16677
|
+
return this.invoke("fullscreen.isActive") === true;
|
|
16678
|
+
}
|
|
16679
|
+
/**
|
|
16519
16680
|
* Sets whether the editor is disabled (readonly).
|
|
16520
16681
|
* @param {boolean} disabled
|
|
16521
16682
|
*/
|
|
@@ -16685,8 +16846,10 @@
|
|
|
16685
16846
|
registerButton(btnDef);
|
|
16686
16847
|
return this;
|
|
16687
16848
|
},
|
|
16849
|
+
/** All pre-built button definitions — accessible in every module format including UMD/CJS. */
|
|
16850
|
+
buttons,
|
|
16688
16851
|
/** Library version */
|
|
16689
|
-
version: "1.
|
|
16852
|
+
version: "1.8.0"
|
|
16690
16853
|
};
|
|
16691
16854
|
/**
|
|
16692
16855
|
* @param {string|Element|NodeList|Element[]} selector
|