Commit ba7890f8 authored by Utkarsh Gupta's avatar Utkarsh Gupta Committed by Phil Hughes

Remove var from text_markdown.js

parent 00b7f217
/* eslint-disable func-names, no-var, no-param-reassign, one-var, operator-assignment, no-else-return, consistent-return */ /* eslint-disable func-names, no-param-reassign, operator-assignment, no-else-return, consistent-return */
import $ from 'jquery'; import $ from 'jquery';
import { insertText } from '~/lib/utils/common_utils'; import { insertText } from '~/lib/utils/common_utils';
...@@ -13,8 +13,7 @@ function addBlockTags(blockTag, selected) { ...@@ -13,8 +13,7 @@ function addBlockTags(blockTag, selected) {
} }
function lineBefore(text, textarea) { function lineBefore(text, textarea) {
var split; const split = text
split = text
.substring(0, textarea.selectionStart) .substring(0, textarea.selectionStart)
.trim() .trim()
.split('\n'); .split('\n');
...@@ -80,7 +79,7 @@ function moveCursor({ ...@@ -80,7 +79,7 @@ function moveCursor({
editorSelectionStart, editorSelectionStart,
editorSelectionEnd, editorSelectionEnd,
}) { }) {
var pos; let pos;
if (textArea && !textArea.setSelectionRange) { if (textArea && !textArea.setSelectionRange) {
return; return;
} }
...@@ -132,18 +131,13 @@ export function insertMarkdownText({ ...@@ -132,18 +131,13 @@ export function insertMarkdownText({
select, select,
editor, editor,
}) { }) {
var textToInsert, let removedLastNewLine = false;
selectedSplit, let removedFirstNewLine = false;
startChar, let currentLineEmpty = false;
removedLastNewLine, let editorSelectionStart;
removedFirstNewLine, let editorSelectionEnd;
currentLineEmpty, let lastNewLine;
lastNewLine, let textToInsert;
editorSelectionStart,
editorSelectionEnd;
removedLastNewLine = false;
removedFirstNewLine = false;
currentLineEmpty = false;
if (editor) { if (editor) {
const selectionRange = editor.getSelectionRange(); const selectionRange = editor.getSelectionRange();
...@@ -186,7 +180,7 @@ export function insertMarkdownText({ ...@@ -186,7 +180,7 @@ export function insertMarkdownText({
} }
} }
selectedSplit = selected.split('\n'); const selectedSplit = selected.split('\n');
if (editor && !wrap) { if (editor && !wrap) {
lastNewLine = editor.getValue().split('\n')[editorSelectionStart.row]; lastNewLine = editor.getValue().split('\n')[editorSelectionStart.row];
...@@ -207,8 +201,7 @@ export function insertMarkdownText({ ...@@ -207,8 +201,7 @@ export function insertMarkdownText({
(textArea && textArea.selectionStart === 0) || (textArea && textArea.selectionStart === 0) ||
(editor && editorSelectionStart.column === 0 && editorSelectionStart.row === 0); (editor && editorSelectionStart.column === 0 && editorSelectionStart.row === 0);
startChar = !wrap && !currentLineEmpty && !isBeginning ? '\n' : ''; const startChar = !wrap && !currentLineEmpty && !isBeginning ? '\n' : '';
const textPlaceholder = '{text}'; const textPlaceholder = '{text}';
if (selectedSplit.length > 1 && (!wrap || (blockTag != null && blockTag !== ''))) { if (selectedSplit.length > 1 && (!wrap || (blockTag != null && blockTag !== ''))) {
...@@ -263,11 +256,10 @@ export function insertMarkdownText({ ...@@ -263,11 +256,10 @@ export function insertMarkdownText({
} }
function updateText({ textArea, tag, cursorOffset, blockTag, wrap, select, tagContent }) { function updateText({ textArea, tag, cursorOffset, blockTag, wrap, select, tagContent }) {
var $textArea, selected, text; const $textArea = $(textArea);
$textArea = $(textArea);
textArea = $textArea.get(0); textArea = $textArea.get(0);
text = $textArea.val(); const text = $textArea.val();
selected = selectedText(text, textArea) || tagContent; const selected = selectedText(text, textArea) || tagContent;
$textArea.focus(); $textArea.focus();
return insertMarkdownText({ return insertMarkdownText({
textArea, textArea,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment