@yltrcc/vditor 0.1.1 → 0.2.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/index.css +45 -6
- package/dist/index.js +22 -7
- package/dist/index.min.js +1 -1
- package/dist/method.js +3 -3
- package/dist/method.min.js +1 -1
- package/package.json +5 -2
- package/src/assets/less/_wysiwyg.less +51 -7
- package/src/ts/util/fixBrowserBehavior.ts +4 -3
- package/src/ts/wysiwyg/highlightToolbarWYSIWYG.ts +7 -0
- package/src/ts/wysiwyg/index.ts +2 -2
- package/src/ts/wysiwyg/showCode.ts +9 -0
package/dist/index.css
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Vditor v0.
|
|
2
|
+
* Vditor v0.2.0 - A markdown editor written in TypeScript.
|
|
3
3
|
*
|
|
4
4
|
* MIT License
|
|
5
5
|
*
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
*
|
|
26
26
|
*/
|
|
27
27
|
/*!
|
|
28
|
-
* Vditor v0.
|
|
28
|
+
* Vditor v0.2.0 - A markdown editor written in TypeScript.
|
|
29
29
|
*
|
|
30
30
|
* MIT License
|
|
31
31
|
*
|
|
@@ -1400,19 +1400,57 @@
|
|
|
1400
1400
|
position: relative;
|
|
1401
1401
|
}
|
|
1402
1402
|
.vditor-wysiwyg__block pre:first-child {
|
|
1403
|
-
margin-bottom: -1em;
|
|
1404
1403
|
display: none;
|
|
1404
|
+
position: relative;
|
|
1405
|
+
margin: 0;
|
|
1406
|
+
padding: 1em;
|
|
1407
|
+
background-color: rgba(0, 0, 0, 0.03);
|
|
1408
|
+
border-radius: 4px;
|
|
1409
|
+
overflow-x: auto;
|
|
1410
|
+
cursor: text;
|
|
1411
|
+
white-space: initial;
|
|
1412
|
+
min-height: 27px;
|
|
1413
|
+
background-size: 20px 20px;
|
|
1414
|
+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8AgMAAABHkjHhAAAACVBMVEWAgIBaWlo+Pj7rTFvWAAAAA3RSTlMHCAw+VhR4AAAA+klEQVQoz4WSMW7EQAhFPxKWNh2FCx+HkaZI6RRb5DYbyVfIJXLKDCFoMbaTKSw/8ZnPAPjaH2xgZcUNUDADD7D9LtDBCLZ45fbkvo/30K8yeI64pPwl6znd/3n/Oe93P3ho9qeh72btTFzqkz0rsJle8Zr81OLEwZ1dv/713uWqvu2pl+k0fy7MWtj9r/tN5q/02z89qa/L4Dc2LvM93kezPfXlME/O86EbY/V9GB9ePX8G1/6W+/9h1dq/HGfTfzT3j/xNo7522Bfnqe5jO/fvhVthlfk434v3iO9zG/UOphyPeinPl1J8Gtaa7xPTa/Dk+RIs4deMvwGvcGsmsCvJ0AAAAABJRU5ErkJggg==);
|
|
1405
1415
|
}
|
|
1406
1416
|
.vditor-wysiwyg__block pre:first-child code {
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1417
|
+
margin: 0;
|
|
1418
|
+
font-family: var(--code-font-family);
|
|
1419
|
+
font-size: var(--code-font-size);
|
|
1420
|
+
line-height: var(--code-line-height);
|
|
1421
|
+
padding: 0;
|
|
1422
|
+
background-color: transparent !important;
|
|
1423
|
+
border-radius: 0;
|
|
1424
|
+
display: inline;
|
|
1425
|
+
overflow: visible;
|
|
1426
|
+
white-space: pre;
|
|
1427
|
+
word-break: initial;
|
|
1428
|
+
word-wrap: normal;
|
|
1429
|
+
}
|
|
1430
|
+
.vditor-wysiwyg__block pre:first-child::before {
|
|
1431
|
+
content: attr(data-language);
|
|
1432
|
+
position: absolute;
|
|
1433
|
+
top: 0;
|
|
1434
|
+
right: 0;
|
|
1435
|
+
padding: 2px 8px;
|
|
1436
|
+
font-size: 12px;
|
|
1437
|
+
color: var(--second-color);
|
|
1438
|
+
background-color: var(--panel-background-color);
|
|
1439
|
+
border-radius: 0 4px 0 4px;
|
|
1440
|
+
z-index: 1;
|
|
1441
|
+
}
|
|
1442
|
+
.vditor-wysiwyg__block pre:first-child:hover {
|
|
1443
|
+
box-shadow: 0 0 0 2px var(--blurColor);
|
|
1444
|
+
}
|
|
1445
|
+
.vditor-wysiwyg__block pre:first-child:focus {
|
|
1446
|
+
outline: none;
|
|
1410
1447
|
}
|
|
1411
1448
|
.vditor-wysiwyg__block pre:last-child {
|
|
1412
1449
|
margin-bottom: 1em;
|
|
1413
1450
|
}
|
|
1414
1451
|
.vditor-wysiwyg__block--editing pre:first-child {
|
|
1415
1452
|
display: block;
|
|
1453
|
+
margin: 0;
|
|
1416
1454
|
}
|
|
1417
1455
|
.vditor-wysiwyg__block--editing .vditor-wysiwyg__preview {
|
|
1418
1456
|
display: none;
|
|
@@ -1434,6 +1472,7 @@
|
|
|
1434
1472
|
font-family: var(--code-font-family);
|
|
1435
1473
|
font-size: var(--code-font-size);
|
|
1436
1474
|
line-height: var(--code-line-height);
|
|
1475
|
+
background-color: transparent !important;
|
|
1437
1476
|
}
|
|
1438
1477
|
.vditor-wysiwyg__preview::before {
|
|
1439
1478
|
content: attr(data-language);
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Vditor v0.
|
|
2
|
+
* Vditor v0.2.0 - A markdown editor written in TypeScript.
|
|
3
3
|
*
|
|
4
4
|
* MIT License
|
|
5
5
|
*
|
|
@@ -1267,7 +1267,7 @@ var looseJsonParse = function (text) {
|
|
|
1267
1267
|
/* harmony export */ Y: () => (/* binding */ Constants),
|
|
1268
1268
|
/* harmony export */ g: () => (/* binding */ _VDITOR_VERSION)
|
|
1269
1269
|
/* harmony export */ });
|
|
1270
|
-
var _VDITOR_VERSION = "0.
|
|
1270
|
+
var _VDITOR_VERSION = "0.2.0";
|
|
1271
1271
|
|
|
1272
1272
|
var Constants = /** @class */ (function () {
|
|
1273
1273
|
function Constants() {
|
|
@@ -1315,7 +1315,7 @@ var Constants = /** @class */ (function () {
|
|
|
1315
1315
|
// 别名
|
|
1316
1316
|
"js", "ts", "html", "toml", "c#", "bat"
|
|
1317
1317
|
];
|
|
1318
|
-
Constants.CDN = "https://unpkg.com/@yltrcc/vditor@".concat("0.
|
|
1318
|
+
Constants.CDN = "https://unpkg.com/@yltrcc/vditor@".concat("0.2.0");
|
|
1319
1319
|
Constants.MARKDOWN_OPTIONS = {
|
|
1320
1320
|
autoSpace: false,
|
|
1321
1321
|
gfmAutoLink: true,
|
|
@@ -7017,6 +7017,13 @@ var showCode = function (previewElement, vditor, first) {
|
|
|
7017
7017
|
// 移除内联样式,让 CSS 类控制显示
|
|
7018
7018
|
codeElement.style.removeProperty("display");
|
|
7019
7019
|
previewElement.style.removeProperty("display");
|
|
7020
|
+
// 将语言信息传递给编辑区域
|
|
7021
|
+
var language = previewElement.getAttribute("data-language") || "";
|
|
7022
|
+
codeElement.setAttribute("data-language", language);
|
|
7023
|
+
// 隐藏编辑时的多余工具栏
|
|
7024
|
+
if (vditor.wysiwyg.popover) {
|
|
7025
|
+
vditor.wysiwyg.popover.style.display = "none";
|
|
7026
|
+
}
|
|
7020
7027
|
var range = codeElement.ownerDocument.createRange();
|
|
7021
7028
|
if (codeElement.tagName === "CODE") {
|
|
7022
7029
|
// 行内代码
|
|
@@ -7954,6 +7961,12 @@ var highlightToolbarWYSIWYG = function (vditor) {
|
|
|
7954
7961
|
}
|
|
7955
7962
|
});
|
|
7956
7963
|
if (blockRenderElement && isBlock) {
|
|
7964
|
+
// 如果代码块处于编辑状态,则不显示工具栏
|
|
7965
|
+
var isCodeBlockEditing = blockRenderElement.classList.contains("vditor-wysiwyg__block--editing");
|
|
7966
|
+
if (isCodeBlockEditing) {
|
|
7967
|
+
vditor.wysiwyg.popover.style.display = "none";
|
|
7968
|
+
return;
|
|
7969
|
+
}
|
|
7957
7970
|
vditor.wysiwyg.popover.innerHTML = "";
|
|
7958
7971
|
genUp(range, blockRenderElement, vditor);
|
|
7959
7972
|
genDown(range, blockRenderElement, vditor);
|
|
@@ -11323,7 +11336,7 @@ var fixFirefoxArrowUpTable = function (event, blockElement, range) {
|
|
|
11323
11336
|
return false;
|
|
11324
11337
|
};
|
|
11325
11338
|
var paste = function (vditor, event, callback) { return fixBrowserBehavior_awaiter(void 0, void 0, void 0, function () {
|
|
11326
|
-
var textHTML, textPlain, files, renderers, renderLinkDest, doc, height, code, codeElement, position, tempElement, fileReader_1, file_1, range, blockElement, range;
|
|
11339
|
+
var textHTML, textPlain, files, renderers, renderLinkDest, doc, height, code, codeElement, position, nextSibling, tempElement, fileReader_1, file_1, range, blockElement, range;
|
|
11327
11340
|
var _a;
|
|
11328
11341
|
return fixBrowserBehavior_generator(this, function (_b) {
|
|
11329
11342
|
switch (_b.label) {
|
|
@@ -11449,9 +11462,11 @@ var paste = function (vditor, event, callback) { return fixBrowserBehavior_await
|
|
|
11449
11462
|
codeElement.textContent = codeElement.textContent.substring(0, position.start)
|
|
11450
11463
|
+ textPlain + codeElement.textContent.substring(position.end);
|
|
11451
11464
|
(0,selection/* setSelectionByPosition */.Fm)(position.start + textPlain.length, position.start + textPlain.length, codeElement.parentElement);
|
|
11452
|
-
|
|
11453
|
-
|
|
11454
|
-
|
|
11465
|
+
nextSibling = (_a = codeElement.parentElement) === null || _a === void 0 ? void 0 : _a.nextElementSibling;
|
|
11466
|
+
if (nextSibling && nextSibling.classList
|
|
11467
|
+
.contains("vditor-".concat(vditor.currentMode, "__preview"))) {
|
|
11468
|
+
nextSibling.innerHTML = codeElement.outerHTML;
|
|
11469
|
+
processCodeRender(nextSibling, vditor);
|
|
11455
11470
|
}
|
|
11456
11471
|
}
|
|
11457
11472
|
return [3 /*break*/, 10];
|