aboutsummaryrefslogtreecommitdiffstats
path: root/web_src
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2020-10-21 13:02:24 +0200
committerGitHub <noreply@github.com>2020-10-21 19:02:24 +0800
commit58e1e5ba13a4a0e134afea1b4010fa363b27e38e (patch)
tree549e5d48edd444144803a8f729386b0671e18bdd /web_src
parent965861043ae4daf7ae50460edf5533e52980bdb1 (diff)
downloadgitea-58e1e5ba13a4a0e134afea1b4010fa363b27e38e.tar.gz
gitea-58e1e5ba13a4a0e134afea1b4010fa363b27e38e.zip
Update some JS dependencies (#13222)
* Update some JS dependencies - Update selective dependencies that are compatible with webpack 4. We can not upgrade to webpack 5 yet because `license-webpack-plugin` is incompatible. - Enable a few new eslint rules and fix new issues * fix comment Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'web_src')
-rw-r--r--web_src/js/features/emoji.js2
-rw-r--r--web_src/js/index.js42
-rw-r--r--web_src/js/utils.js12
3 files changed, 24 insertions, 32 deletions
diff --git a/web_src/js/features/emoji.js b/web_src/js/features/emoji.js
index 51d8801dc8..0da61c4d56 100644
--- a/web_src/js/features/emoji.js
+++ b/web_src/js/features/emoji.js
@@ -15,7 +15,7 @@ export const emojiKeys = Object.keys(tempMap).sort((a, b) => {
return a.localeCompare(b);
});
-export const emojiMap = {};
+const emojiMap = {};
for (const key of emojiKeys) {
emojiMap[key] = tempMap[key];
}
diff --git a/web_src/js/index.js b/web_src/js/index.js
index 9fafe62d3e..8636427092 100644
--- a/web_src/js/index.js
+++ b/web_src/js/index.js
@@ -25,6 +25,7 @@ import ActivityTopAuthors from './components/ActivityTopAuthors.vue';
import {initNotificationsTable, initNotificationCount} from './features/notification.js';
import {createCodeEditor} from './features/codeeditor.js';
import {svg, svgs} from './svg.js';
+import {stripTags} from './utils.js';
const {AppSubUrl, StaticUrlPrefix, csrf} = window.config;
@@ -1325,25 +1326,26 @@ function initWikiForm() {
element: $editArea[0],
forceSync: true,
previewRender(plainText, preview) { // Async method
+ // FIXME: still send render request when return back to edit mode
+ const render = function () {
+ sideBySideChanges = 0;
+ if (sideBySideTimeout !== null) {
+ clearTimeout(sideBySideTimeout);
+ sideBySideTimeout = null;
+ }
+ $.post($editArea.data('url'), {
+ _csrf: csrf,
+ mode: 'gfm',
+ context: $editArea.data('context'),
+ text: plainText,
+ wiki: true
+ }, (data) => {
+ preview.innerHTML = `<div class="markdown ui segment">${data}</div>`;
+ renderMarkdownContent();
+ });
+ };
+
setTimeout(() => {
- // FIXME: still send render request when return back to edit mode
- const render = function () {
- sideBySideChanges = 0;
- if (sideBySideTimeout !== null) {
- clearTimeout(sideBySideTimeout);
- sideBySideTimeout = null;
- }
- $.post($editArea.data('url'), {
- _csrf: csrf,
- mode: 'gfm',
- context: $editArea.data('context'),
- text: plainText,
- wiki: true
- }, (data) => {
- preview.innerHTML = `<div class="markdown ui segment">${data}</div>`;
- renderMarkdownContent();
- });
- };
if (!simplemde.isSideBySideActive()) {
render();
} else {
@@ -3367,10 +3369,6 @@ function initTopicbar() {
success: false,
results: [],
};
- const stripTags = function (text) {
- return text.replace(/<[^>]*>?/gm, '');
- };
-
const query = stripTags(this.urlData.query.trim());
let found_query = false;
const current_topics = [];
diff --git a/web_src/js/utils.js b/web_src/js/utils.js
index d5f921f8dc..fc65644c7b 100644
--- a/web_src/js/utils.js
+++ b/web_src/js/utils.js
@@ -24,13 +24,7 @@ export function uniq(arr) {
return Array.from(new Set(arr));
}
-const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
-
-// generate a random string
-export function random(length) {
- let str = '';
- for (let i = 0; i < length; i++) {
- str += chars.charAt(Math.floor(Math.random() * chars.length));
- }
- return str;
+// strip <tags> from a string
+export function stripTags(text) {
+ return text.replace(/<[^>]*>?/gm, '');
}