From d2e19d740e1d3d96dd0d2f8fce87861534fbf8ed Mon Sep 17 00:00:00 2001 From: Mirco Wittrien Date: Sat, 23 Jan 2021 13:43:32 +0100 Subject: [PATCH] Update 0BDFDB.plugin.js --- Library/0BDFDB.plugin.js | 86 ---------------------------------------- 1 file changed, 86 deletions(-) diff --git a/Library/0BDFDB.plugin.js b/Library/0BDFDB.plugin.js index 2779e3ac03..dd549d341b 100644 --- a/Library/0BDFDB.plugin.js +++ b/Library/0BDFDB.plugin.js @@ -3876,92 +3876,6 @@ module.exports = (_ => { } return newRichValue; }; - BDFDB.SlateUtils.hasOpenPlainTextCodeBlock = function (editor) { - let richValue = BDFDB.ObjectUtils.get(editor, "props.richValue"); - if (!BDFDB.SlateUtils.isRichValue(richValue)) return false; - let codeMatches = BDFDB.LibraryModules.SlateSelectionUtils.serializeSelection(richValue.document, { - start: { - key: richValue.document.getFirstText().key, - offset: 0 - }, - end: richValue.selection.start - }, "raw").match(/```/g); - return codeMatches && codeMatches.length && codeMatches.length % 2 != 0; - }; - BDFDB.SlateUtils.getCurrentWord = function (editor) { - let richValue = BDFDB.ObjectUtils.get(editor, "props.richValue"); - if (!BDFDB.SlateUtils.isRichValue(richValue) || !richValue.selection.isCollapsed || BDFDB.SlateUtils.hasOpenPlainTextCodeBlock(editor) || richValue.document.text.trim().length == 0) return {word: null, isAtStart: false}; - if (editor.props.useSlate) { - if (richValue.document.text.startsWith("/giphy ") || richValue.document.text.startsWith("/tenor ")) { - let node = richValue.document.getNode(richValue.selection.start.key); - if (node) return { - word: node.text.substring(0, richValue.selection.start.offset), - isAtStart: true - } - } - let node = richValue.document.getNode(richValue.selection.start.key); - if (node == null) return { - word: null, - isAtStart: false - }; - let word = "", atStart = false; - let offset = richValue.selection.start.offset; - let block = richValue.document.getClosestBlock(node.key); - while (true) { - if (--offset < 0) { - if ((node = block.getPreviousNode(node.key) == null)) { - atStart = true; - break; - } - if (node.object!== "text") break; - offset = node.text.length - 1; - } - if (node.object !== "text") break; - let prefix = node.text[offset]; - if (/(\t|\s)/.test(prefix)) break; - word = prefix + word; - } - return { - word: !word ? null : word, - isAtStart: atStart && block.type == "line" && richValue.document.nodes.get(0) === block - }; - } - else { - let textarea = BDFDB.ReactUtils.findDOMNode(editor.ref.current); - if (!Node.prototype.isPrototypeOf(textarea) || textarea.tagName != "TEXTAREA" || !textarea.value.length || /\s/.test(textarea.value.slice(textarea.selectionStart, textarea.selectionEnd))) return { - word: null, - isAtStart: true - }; - else { - if (textarea.selectionEnd == textarea.value.length) { - let words = textarea.value.split(/\s/).reverse(); - return { - word: !words[0] ? null : words[0], - isAtStart: words.length > 1 - }; - } - else { - let chars = textarea.value.split(""), word = "", currentWord = "", isCurrentWord = false, isAtStart = true; - for (let i in chars) { - if (i == textarea.selectionStart) isCurrentWord = true; - if (/\s/.test(chars[i])) { - word = ""; - isAtStart = currentWord.length > 0 && isAtStart || false; - isCurrentWord = false; - } - else { - word += chars[i]; - if (isCurrentWord) currentWord = word; - } - } - return { - word: !currentWord ? null : currentWord, - isAtStart: isAtStart - }; - } - } - } - }; BDFDB.NumberUtils = {}; BDFDB.NumberUtils.formatBytes = function (bytes, sigDigits) {