Skip to content

Commit 94fc7a6

Browse files
committed
chore: bump @f0rce/lit-ace version to "1.10.0"
1 parent 3708790 commit 94fc7a6

File tree

5 files changed

+162
-174
lines changed

5 files changed

+162
-174
lines changed

src/main/java/de/f0rce/ace/AceEditor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
@SuppressWarnings("serial")
3838
@Tag("lit-ace")
3939
@NpmPackage(value = "@f0rce/lit-ace", version = "1.9.0")
40+
@NpmPackage(value = "@f0rce/lit-ace", version = "1.10.0")
4041
@JsModule("./@f0rce/lit-ace/lit-ace.js")
4142
public class AceEditor extends Component implements HasSize, HasStyle, Focusable<AceEditor> {
4243

src/main/resources/META-INF/resources/frontend/@f0rce/lit-ace/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
## [1.10.0](https://github.com/f0rce/lit-ace/compare/v1.9.0...v1.10.0) (2022-07-20)
6+
7+
8+
### Features
9+
10+
* **statusbar:** possibility to choose the starting index ([7403120](https://github.com/f0rce/lit-ace/commit/7403120993259c58e85d1bfbd9a3d63feb790013))
11+
512
## [1.9.0](https://github.com/f0rce/lit-ace/compare/v1.8.3...v1.9.0) (2022-06-28)
613

714
### [1.8.3](https://github.com/f0rce/lit-ace/compare/v1.8.2...v1.8.3) (2022-06-13)

src/main/resources/META-INF/resources/frontend/@f0rce/lit-ace/lit-ace.js

Lines changed: 117 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,11 @@ class LitAce extends LitElement {
285285
this.editor.focus();
286286
}
287287

288+
this._statusbarIndex = 1;
288289
this.editor.statusbar = new this.statusBar(
289290
this.editor,
290-
this.editorStatusbarDiv
291+
this.editorStatusbarDiv,
292+
this._statusbarIndex
291293
);
292294

293295
this.vScrollbarObserver = new IntersectionObserver(
@@ -1006,72 +1008,16 @@ class LitAce extends LitElement {
10061008
}
10071009

10081010
/** @private */
1009-
_generateHTML(exportType) {
1010-
if (exportType.toLowerCase() == "flat") {
1011-
let currentVal = this.editorValue;
1011+
async _generateHTML(exportType) {
1012+
const content = await this._generateExport(exportType);
10121013

1013-
currentVal = currentVal.replace(/[\u00A0-\u9999<>\&]/g, function (i) {
1014-
return "&#" + i.charCodeAt(0) + ";";
1015-
});
1016-
currentVal = currentVal.replace(new RegExp("\r?\n", "g"), "<br/>");
1017-
currentVal = currentVal.replace(/\s/g, "&nbsp;");
1018-
1019-
var htmlContent = `<!DOCTYPE html>
1020-
<html>
1021-
<head>
1022-
<link rel="preconnect" href="https://fonts.gstatic.com">
1023-
<link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro&display=swap" rel="stylesheet">
1024-
<style>
1025-
#aceRaw {
1026-
font-family: 'Source Code Pro', monospace;
1027-
font-size: 12px;
1028-
}
1029-
</style>
1030-
</head>
1031-
<body>
1032-
<div id="aceRaw">${currentVal}</div>
1033-
</body>
1034-
</html>`;
1035-
1036-
this.dispatchEvent(
1037-
new CustomEvent("html-generated", {
1038-
detail: {
1039-
html: htmlContent,
1040-
},
1041-
})
1042-
);
1043-
} else if (exportType.toLowerCase() == "rich") {
1044-
let self = this;
1045-
ace
1046-
.require("ace/config")
1047-
.loadModule("ace/ext/static_highlight", function (m) {
1048-
var result = m.renderSync(
1049-
self.editor.getValue(),
1050-
self.editor.session.getMode(),
1051-
self.editor.renderer.theme
1052-
);
1053-
1054-
var htmlContent = `<!DOCTYPE html>
1055-
<html>
1056-
<head>
1057-
<style>
1058-
${result.css}
1059-
</style>
1060-
</head>
1061-
<body>
1062-
${result.html}
1063-
</body>
1064-
</html>`;
1065-
1066-
self.dispatchEvent(
1067-
new CustomEvent("html-generated", {
1068-
detail: {
1069-
html: htmlContent,
1070-
},
1071-
})
1072-
);
1073-
});
1074-
}
1014+
this.dispatchEvent(
1015+
new CustomEvent("html-generated", {
1016+
detail: {
1017+
html: content,
1018+
},
1019+
})
1020+
);
10751021
}
10761022

10771023
unfold() {
@@ -1237,82 +1183,42 @@ class LitAce extends LitElement {
12371183
}
12381184

12391185
/** @private */
1240-
_print(exportType) {
1241-
if (exportType.toLowerCase() == "flat") {
1242-
let currentVal = this.editorValue;
1243-
1244-
currentVal = currentVal.replace(/[\u00A0-\u9999<>\&]/g, function (i) {
1245-
return "&#" + i.charCodeAt(0) + ";";
1246-
});
1247-
currentVal = currentVal.replace(new RegExp("\r?\n", "g"), "<br/>");
1248-
currentVal = currentVal.replace(/\s/g, "&nbsp;");
1186+
async _print(exportType) {
1187+
const content = await this._generateExport(exportType);
1188+
this._initializePrint(content);
1189+
}
12491190

1250-
var htmlContent = `<!DOCTYPE html>
1251-
<html>
1252-
<head>
1253-
<title>Ace Export</title>
1254-
<link rel="preconnect" href="https://fonts.gstatic.com">
1255-
<link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro&display=swap" rel="stylesheet">
1256-
<style>
1257-
#aceRaw {
1258-
font-family: 'Source Code Pro', monospace;
1259-
font-size: 12px;
1260-
}
1261-
@media print {
1262-
@page {
1263-
margin-top: 0;
1264-
margin-bottom: 0;
1265-
}
1266-
body {
1267-
padding-top: 72px;
1268-
padding-bottom: 72px ;
1191+
setStatusbarIndexing(statusbarIndex) {
1192+
if (this.editor == undefined) {
1193+
this.addEventListener(
1194+
"editor-ready",
1195+
() => this._setStatusbarIndexing(statusbarIndex),
1196+
{
1197+
once: true,
12691198
}
1270-
}
1271-
</style>
1272-
</head>
1273-
<body>
1274-
<div id="aceRaw">${currentVal}</div>
1275-
</body>
1276-
</html>`;
1199+
);
1200+
} else {
1201+
this._setStatusbarIndexing(statusbarIndex);
1202+
}
1203+
}
12771204

1278-
this.initializePrint(htmlContent);
1279-
} else if (exportType.toLowerCase() == "rich") {
1280-
let self = this;
1281-
ace
1282-
.require("ace/config")
1283-
.loadModule("ace/ext/static_highlight", function (m) {
1284-
var result = m.renderSync(
1285-
self.editor.getValue(),
1286-
self.editor.session.getMode(),
1287-
self.editor.renderer.theme
1288-
);
1205+
/** @private */
1206+
_setStatusbarIndexing(statusbarIndex) {
1207+
if (statusbarIndex == this._statusbarIndex) return;
12891208

1290-
var htmlContent = `<!DOCTYPE html>
1291-
<html>
1292-
<head>
1293-
<title>Ace Export</title>
1294-
<style>
1295-
${result.css}
1296-
@media print {
1297-
@page {
1298-
margin-top: 0;
1299-
margin-bottom: 0;
1300-
}
1301-
body {
1302-
padding-top: 72px;
1303-
padding-bottom: 72px ;
1304-
}
1305-
}
1306-
</style>
1307-
</head>
1308-
<body>
1309-
${result.html}
1310-
</body>
1311-
</html>`;
1209+
this._statusbarIndex = statusbarIndex;
13121210

1313-
self.initializePrint(htmlContent);
1314-
});
1211+
for (const child of this.editorStatusbarDiv.childNodes) {
1212+
this.editorStatusbarDiv.removeChild(child);
13151213
}
1214+
1215+
this.editor.statusbar = new this.statusBar(
1216+
this.editor,
1217+
this.editorStatusbarDiv,
1218+
this._statusbarIndex
1219+
);
1220+
1221+
this.editor.statusbar.updateStatus(this.editor, this._statusbarIndex);
13161222
}
13171223

13181224
/** @private */
@@ -1365,7 +1271,81 @@ class LitAce extends LitElement {
13651271
}
13661272

13671273
/** @private */
1368-
initializePrint(content) {
1274+
_generateExport(exportType) {
1275+
const printCSS = `@media print {
1276+
@page {
1277+
margin-top: 0;
1278+
margin-bottom: 0;
1279+
}
1280+
body {
1281+
padding-top: 72px;
1282+
padding-bottom: 72px ;
1283+
}
1284+
}`;
1285+
1286+
return new Promise((resolve) => {
1287+
if (exportType.toLowerCase() == "flat") {
1288+
let currentVal = this.editorValue;
1289+
1290+
currentVal = currentVal.replace(/[\u00A0-\u9999<>\&]/g, function (i) {
1291+
return "&#" + i.charCodeAt(0) + ";";
1292+
});
1293+
currentVal = currentVal.replace(new RegExp("\r?\n", "g"), "<br/>");
1294+
currentVal = currentVal.replace(/\s/g, "&nbsp;");
1295+
1296+
var htmlContent = `<!DOCTYPE html>
1297+
<html>
1298+
<head>
1299+
<title>Ace Export</title>
1300+
<link rel="preconnect" href="https://fonts.gstatic.com">
1301+
<link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro&display=swap" rel="stylesheet">
1302+
<style>
1303+
#aceRaw {
1304+
font-family: 'Source Code Pro', monospace;
1305+
font-size: 12px;
1306+
}
1307+
${printCSS}
1308+
</style>
1309+
</head>
1310+
<body>
1311+
<div id="aceRaw">${currentVal}</div>
1312+
</body>
1313+
</html>`;
1314+
1315+
resolve(htmlContent);
1316+
} else if (exportType.toLowerCase() == "rich") {
1317+
let self = this;
1318+
ace
1319+
.require("ace/config")
1320+
.loadModule("ace/ext/static_highlight", function (m) {
1321+
var result = m.renderSync(
1322+
self.editor.getValue(),
1323+
self.editor.session.getMode(),
1324+
self.editor.renderer.theme
1325+
);
1326+
1327+
var htmlContent = `<!DOCTYPE html>
1328+
<html>
1329+
<head>
1330+
<title>Ace Export</title>
1331+
<style>
1332+
${result.css}
1333+
${printCSS}
1334+
</style>
1335+
</head>
1336+
<body>
1337+
${result.html}
1338+
</body>
1339+
</html>`;
1340+
1341+
resolve(htmlContent);
1342+
});
1343+
}
1344+
});
1345+
}
1346+
1347+
/** @private */
1348+
_initializePrint(content) {
13691349
const popupWidth = 742;
13701350
const popupHeight = 600;
13711351

0 commit comments

Comments
 (0)