This commit is contained in:
Mirco Wittrien 2019-12-21 00:40:42 +01:00
parent ea67cd02d6
commit d4577dc1eb
2 changed files with 20 additions and 24 deletions

View File

@ -3929,7 +3929,7 @@
return newRichValue;
};
BDFDB.StringUtils.hasOpenPlainTextCodeBlock = function (richValue) {
let codeMatches = BDBFDB.LibraryModules.SlateSelectionUtils.serializeSelection(richValue.document, {
let codeMatches = BDFDB.LibraryModules.SlateSelectionUtils.serializeSelection(richValue.document, {
start: {
key: richValue.document.getFirstText().key,
offset:0
@ -3939,7 +3939,7 @@
return codeMatches && codeMatches.length && codeMatches.length % 2 != 0;
};
BDFDB.StringUtils.getCurrentWord = function (richValue) {
if (!richValue || !richValue.selection.isCollapsed || BDFDB.StringUtils.hasOpenPlainTextCodeBlock(richvalue) || richValue.document.text.trim().length == 0) return {word: null, isAtStart: false};
if (!richValue || !richValue.selection.isCollapsed || BDFDB.StringUtils.hasOpenPlainTextCodeBlock(richValue) || richValue.document.text.trim().length == 0) return {word: null, isAtStart: false};
if (richValue.document.text.startsWith("/giphy ") || richValue.document.text.startsWith("/tenor ")) {
let node = richValue.document.getNode(richValue.selection.start.key);
if (node) return {
@ -3952,31 +3952,27 @@
word: null,
isAtStart: false
};
let word = "",
s = !1,
d = richValue.selection.start.offset,
c = richValue.document.getClosestBlock(l.key);
for ((0, i.default)(null != c, "selected line should not be null at this point"); ; ) {
if (--d < 0) {
if (null == (l = c.getPreviousNode(l.key))) {
s = !0;
break
}
if ("text" !== l.object)
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;
d = l.text.length - 1
}
if (node.object!== "text") break;
offset = node.text.length - 1;
}
if ("text" !== l.object)
break;
var f = l.text[d];
if (M.test(f))
break;
u = f + u
if (node.object !== "text") break;
let prefix = node.text[offset];
if (/(\t|\s)/.test(prefix)) break;
word = prefix + word;
}
return {
word: "" === u ? null : u,
isAtStart: s && "line" === c.type && r.nodes.get(0) === c
}
word: !word ? null : word,
isAtStart: atStart && block.type == "line" && richValue.document.nodes.get(0) === block
};
};
BDFDB.StringUtils.highlight = function (string, searchstring, prefix = `<span class="${BDFDB.disCN.highlight}">`, suffix = `</span>`) {
if (typeof string != "string" || !searchstring || searchstring.length < 1) return string;

File diff suppressed because one or more lines are too long