chore: Enable eslint to enforce curly (#3060)
This commit is contained in:
@@ -6,14 +6,20 @@ export default function backspaceToParagraph(type: NodeType) {
|
||||
const { $from, from, to, empty } = state.selection;
|
||||
|
||||
// if the selection has anything in it then use standard delete behavior
|
||||
if (!empty) return null;
|
||||
if (!empty) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// check we're in a matching node
|
||||
if ($from.parent.type !== type) return null;
|
||||
if ($from.parent.type !== type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// check if we're at the beginning of the heading
|
||||
const $pos = state.doc.resolve(from - 1);
|
||||
if ($pos.parent === $from.parent) return null;
|
||||
if ($pos.parent === $from.parent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// okay, replace it with a paragraph
|
||||
dispatch(
|
||||
|
||||
@@ -48,7 +48,9 @@ const createAndInsertLink = async function (
|
||||
const url = await onCreateLink(title);
|
||||
const result = findPlaceholderLink(view.state.doc, href);
|
||||
|
||||
if (!result) return;
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(
|
||||
view.state.tr
|
||||
@@ -65,7 +67,9 @@ const createAndInsertLink = async function (
|
||||
);
|
||||
} catch (err) {
|
||||
const result = findPlaceholderLink(view.state.doc, href);
|
||||
if (!result) return;
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(
|
||||
view.state.tr.removeMark(
|
||||
|
||||
@@ -25,7 +25,9 @@ const insertFiles = function (
|
||||
): void {
|
||||
// filter to only include image files
|
||||
const images = files.filter((file) => /image/i.test(file.type));
|
||||
if (images.length === 0) return;
|
||||
if (images.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const {
|
||||
dictionary,
|
||||
@@ -47,7 +49,9 @@ const insertFiles = function (
|
||||
event.preventDefault();
|
||||
|
||||
// let the user know we're starting to process the images
|
||||
if (onImageUploadStart) onImageUploadStart();
|
||||
if (onImageUploadStart) {
|
||||
onImageUploadStart();
|
||||
}
|
||||
|
||||
const { schema } = view.state;
|
||||
|
||||
|
||||
@@ -8,15 +8,21 @@ export default function splitHeading(type: NodeType) {
|
||||
const { $from, from, $to, to } = state.selection;
|
||||
|
||||
// check we're in a matching heading node
|
||||
if ($from.parent.type !== type) return false;
|
||||
if ($from.parent.type !== type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// check that the caret is at the end of the content, if it isn't then
|
||||
// standard node splitting behaviour applies
|
||||
const endPos = $to.after() - 1;
|
||||
if (endPos !== to) return false;
|
||||
if (endPos !== to) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the node isn't collapsed standard behavior applies
|
||||
if (!$from.parent.attrs.collapsed) return false;
|
||||
if (!$from.parent.attrs.collapsed) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Find the next visible block after this one. It takes into account nested
|
||||
// collapsed headings and reaching the end of the document
|
||||
|
||||
@@ -37,7 +37,9 @@ class Frame extends React.Component<PropsWithRef> {
|
||||
}
|
||||
|
||||
loadIframe = () => {
|
||||
if (!this.mounted) return;
|
||||
if (!this.mounted) {
|
||||
return;
|
||||
}
|
||||
this.isLoaded = true;
|
||||
};
|
||||
|
||||
|
||||
@@ -73,7 +73,9 @@ export default class ExtensionManager {
|
||||
)
|
||||
.reduce((nodes, extension: Node | Mark) => {
|
||||
const md = extension.parseMarkdown();
|
||||
if (!md) return nodes;
|
||||
if (!md) {
|
||||
return nodes;
|
||||
}
|
||||
|
||||
return {
|
||||
...nodes,
|
||||
|
||||
@@ -5,17 +5,23 @@ export default function filterExcessSeparators(
|
||||
): (MenuItem | EmbedDescriptor)[] {
|
||||
return items.reduce((acc, item, index) => {
|
||||
// trim separators from start / end
|
||||
if (item.name === "separator" && index === 0) return acc;
|
||||
if (item.name === "separator" && index === items.length - 1) return acc;
|
||||
if (item.name === "separator" && index === 0) {
|
||||
return acc;
|
||||
}
|
||||
if (item.name === "separator" && index === items.length - 1) {
|
||||
return acc;
|
||||
}
|
||||
|
||||
// trim double separators looking ahead / behind
|
||||
const prev = items[index - 1];
|
||||
if (prev && prev.name === "separator" && item.name === "separator")
|
||||
if (prev && prev.name === "separator" && item.name === "separator") {
|
||||
return acc;
|
||||
}
|
||||
|
||||
const next = items[index + 1];
|
||||
if (next && next.name === "separator" && item.name === "separator")
|
||||
if (next && next.name === "separator" && item.name === "separator") {
|
||||
return acc;
|
||||
}
|
||||
|
||||
// otherwise, continue
|
||||
return [...acc, item];
|
||||
|
||||
@@ -18,7 +18,9 @@ function safeSlugify(text: string) {
|
||||
// in the document that is as stable as possible
|
||||
export default function headingToSlug(node: Node, index = 0) {
|
||||
const slugified = safeSlugify(node.textContent);
|
||||
if (index === 0) return slugified;
|
||||
if (index === 0) {
|
||||
return slugified;
|
||||
}
|
||||
return `${slugified}-${index}`;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,28 @@
|
||||
export default function isMarkdown(text: string): boolean {
|
||||
// code-ish
|
||||
const fences = text.match(/^```/gm);
|
||||
if (fences && fences.length > 1) return true;
|
||||
if (fences && fences.length > 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// link-ish
|
||||
if (text.match(/\[[^]+\]\(https?:\/\/\S+\)/gm)) return true;
|
||||
if (text.match(/\[[^]+\]\(\/\S+\)/gm)) return true;
|
||||
if (text.match(/\[[^]+\]\(https?:\/\/\S+\)/gm)) {
|
||||
return true;
|
||||
}
|
||||
if (text.match(/\[[^]+\]\(\/\S+\)/gm)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// heading-ish
|
||||
if (text.match(/^#{1,6}\s+\S+/gm)) return true;
|
||||
if (text.match(/^#{1,6}\s+\S+/gm)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// list-ish
|
||||
const listItems = text.match(/^[\d-*].?\s\S+/gm);
|
||||
if (listItems && listItems.length > 1) return true;
|
||||
if (listItems && listItems.length > 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -80,20 +80,28 @@ export class MarkdownSerializerState {
|
||||
// on a node level by specifying a tight attribute on the node.
|
||||
// Defaults to false.
|
||||
this.options = options || {};
|
||||
if (typeof this.options.tightLists === "undefined")
|
||||
if (typeof this.options.tightLists === "undefined") {
|
||||
this.options.tightLists = true;
|
||||
}
|
||||
}
|
||||
|
||||
flushClose(size) {
|
||||
if (this.closed) {
|
||||
if (!this.atBlank()) this.out += "\n";
|
||||
if (size === null || size === undefined) size = 2;
|
||||
if (!this.atBlank()) {
|
||||
this.out += "\n";
|
||||
}
|
||||
if (size === null || size === undefined) {
|
||||
size = 2;
|
||||
}
|
||||
if (size > 1) {
|
||||
let delimMin = this.delim;
|
||||
const trim = /\s+$/.exec(delimMin);
|
||||
if (trim)
|
||||
if (trim) {
|
||||
delimMin = delimMin.slice(0, delimMin.length - trim[0].length);
|
||||
for (let i = 1; i < size; i++) this.out += delimMin + "\n";
|
||||
}
|
||||
for (let i = 1; i < size; i++) {
|
||||
this.out += delimMin + "\n";
|
||||
}
|
||||
}
|
||||
this.closed = false;
|
||||
}
|
||||
@@ -120,7 +128,9 @@ export class MarkdownSerializerState {
|
||||
// :: ()
|
||||
// Ensure the current content ends with a newline.
|
||||
ensureNewLine() {
|
||||
if (!this.atBlank()) this.out += "\n";
|
||||
if (!this.atBlank()) {
|
||||
this.out += "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// :: (?string)
|
||||
@@ -129,8 +139,12 @@ export class MarkdownSerializerState {
|
||||
// (unescaped) to the output.
|
||||
write(content) {
|
||||
this.flushClose();
|
||||
if (this.delim && this.atBlank()) this.out += this.delim;
|
||||
if (content) this.out += content;
|
||||
if (this.delim && this.atBlank()) {
|
||||
this.out += this.delim;
|
||||
}
|
||||
if (content) {
|
||||
this.out += content;
|
||||
}
|
||||
}
|
||||
|
||||
// :: (Node)
|
||||
@@ -148,14 +162,18 @@ export class MarkdownSerializerState {
|
||||
const startOfLine = this.atBlank() || this.closed;
|
||||
this.write();
|
||||
this.out += escape !== false ? this.esc(lines[i], startOfLine) : lines[i];
|
||||
if (i !== lines.length - 1) this.out += "\n";
|
||||
if (i !== lines.length - 1) {
|
||||
this.out += "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// :: (Node)
|
||||
// Render the given node as a block.
|
||||
render(node, parent, index) {
|
||||
if (typeof parent === "number") throw new Error("!");
|
||||
if (typeof parent === "number") {
|
||||
throw new Error("!");
|
||||
}
|
||||
this.nodes[node.type.name](this, node, parent, index);
|
||||
}
|
||||
|
||||
@@ -178,14 +196,17 @@ export class MarkdownSerializerState {
|
||||
// before closing marks.
|
||||
// (FIXME it'd be nice if we had a schema-agnostic way to
|
||||
// identify nodes that serialize as hard breaks)
|
||||
if (node && node.type.name === "hard_break")
|
||||
if (node && node.type.name === "hard_break") {
|
||||
marks = marks.filter((m) => {
|
||||
if (index + 1 === parent.childCount) return false;
|
||||
if (index + 1 === parent.childCount) {
|
||||
return false;
|
||||
}
|
||||
const next = parent.child(index + 1);
|
||||
return (
|
||||
m.isInSet(next.marks) && (!next.isText || /\S/.test(next.text))
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
let leading = trailing;
|
||||
trailing = "";
|
||||
@@ -205,7 +226,9 @@ export class MarkdownSerializerState {
|
||||
trailing = trail;
|
||||
if (lead || trail) {
|
||||
node = inner ? node.withText(inner) : null;
|
||||
if (!node) marks = active;
|
||||
if (!node) {
|
||||
marks = active;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,23 +242,28 @@ export class MarkdownSerializerState {
|
||||
// active.
|
||||
outer: for (let i = 0; i < len; i++) {
|
||||
const mark = marks[i];
|
||||
if (!this.marks[mark.type.name]().mixable) break;
|
||||
if (!this.marks[mark.type.name]().mixable) {
|
||||
break;
|
||||
}
|
||||
for (let j = 0; j < active.length; j++) {
|
||||
const other = active[j];
|
||||
if (!this.marks[other.type.name]().mixable) break;
|
||||
if (!this.marks[other.type.name]().mixable) {
|
||||
break;
|
||||
}
|
||||
if (mark.eq(other)) {
|
||||
if (i > j)
|
||||
if (i > j) {
|
||||
marks = marks
|
||||
.slice(0, j)
|
||||
.concat(mark)
|
||||
.concat(marks.slice(j, i))
|
||||
.concat(marks.slice(i + 1, len));
|
||||
else if (j > i)
|
||||
} else if (j > i) {
|
||||
marks = marks
|
||||
.slice(0, i)
|
||||
.concat(marks.slice(i + 1, j))
|
||||
.concat(mark)
|
||||
.concat(marks.slice(j, len));
|
||||
}
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
@@ -246,15 +274,19 @@ export class MarkdownSerializerState {
|
||||
while (
|
||||
keep < Math.min(active.length, len) &&
|
||||
marks[keep].eq(active[keep])
|
||||
)
|
||||
) {
|
||||
++keep;
|
||||
}
|
||||
|
||||
// Close the marks that need to be closed
|
||||
while (keep < active.length)
|
||||
while (keep < active.length) {
|
||||
this.text(this.markString(active.pop(), false, parent, index), false);
|
||||
}
|
||||
|
||||
// Output any previously expelled trailing whitespace outside the marks
|
||||
if (leading) this.text(leading);
|
||||
if (leading) {
|
||||
this.text(leading);
|
||||
}
|
||||
|
||||
// Open the marks that need to be opened
|
||||
if (node) {
|
||||
@@ -266,14 +298,16 @@ export class MarkdownSerializerState {
|
||||
|
||||
// Render the node. Special case code marks, since their content
|
||||
// may not be escaped.
|
||||
if (noEsc && node.isText)
|
||||
if (noEsc && node.isText) {
|
||||
this.text(
|
||||
this.markString(inner, true, parent, index) +
|
||||
node.text +
|
||||
this.markString(inner, false, parent, index + 1),
|
||||
false
|
||||
);
|
||||
else this.render(node, parent, index);
|
||||
} else {
|
||||
this.render(node, parent, index);
|
||||
}
|
||||
}
|
||||
};
|
||||
parent.forEach(progress);
|
||||
@@ -286,8 +320,11 @@ export class MarkdownSerializerState {
|
||||
// `firstDelim` is a function going from an item index to a
|
||||
// delimiter for the first line of the item.
|
||||
renderList(node, delim, firstDelim) {
|
||||
if (this.closed && this.closed.type === node.type) this.flushClose(3);
|
||||
else if (this.inTightList) this.flushClose(1);
|
||||
if (this.closed && this.closed.type === node.type) {
|
||||
this.flushClose(3);
|
||||
} else if (this.inTightList) {
|
||||
this.flushClose(1);
|
||||
}
|
||||
|
||||
const isTight =
|
||||
typeof node.attrs.tight !== "undefined"
|
||||
@@ -298,7 +335,9 @@ export class MarkdownSerializerState {
|
||||
this.inList = true;
|
||||
this.inTightList = isTight;
|
||||
node.forEach((child, _, i) => {
|
||||
if (i && isTight) this.flushClose(1);
|
||||
if (i && isTight) {
|
||||
this.flushClose(1);
|
||||
}
|
||||
this.wrapBlock(delim, firstDelim(i), node, () =>
|
||||
this.render(child, node, i)
|
||||
);
|
||||
@@ -387,7 +426,9 @@ export class MarkdownSerializerState {
|
||||
// Repeat the given string `n` times.
|
||||
repeat(str, n) {
|
||||
let out = "";
|
||||
for (let i = 0; i < n; i++) out += str;
|
||||
for (let i = 0; i < n; i++) {
|
||||
out += str;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,9 @@ export default class Placeholder extends Mark {
|
||||
const $from = state.doc.resolve(from);
|
||||
|
||||
const range = getMarkRange($from, state.schema.marks.placeholder);
|
||||
if (!range) return false;
|
||||
if (!range) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const selectionStart = Math.min(from, range.from);
|
||||
const selectionEnd = Math.max(to, range.to);
|
||||
@@ -88,7 +90,9 @@ export default class Placeholder extends Mark {
|
||||
state.doc.resolve(Math.max(0, state.selection.from - 1)),
|
||||
state.schema.marks.placeholder
|
||||
);
|
||||
if (!range) return false;
|
||||
if (!range) {
|
||||
return false;
|
||||
}
|
||||
|
||||
dispatch(
|
||||
state.tr
|
||||
@@ -107,7 +111,9 @@ export default class Placeholder extends Mark {
|
||||
state.doc.resolve(Math.max(0, state.selection.from - 1)),
|
||||
state.schema.marks.placeholder
|
||||
);
|
||||
if (!range) return false;
|
||||
if (!range) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const startOfMark = state.doc.resolve(range.from);
|
||||
dispatch(state.tr.setSelection(TextSelection.near(startOfMark)));
|
||||
@@ -119,7 +125,9 @@ export default class Placeholder extends Mark {
|
||||
state.selection.$from,
|
||||
state.schema.marks.placeholder
|
||||
);
|
||||
if (!range) return false;
|
||||
if (!range) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const endOfMark = state.doc.resolve(range.to);
|
||||
dispatch(state.tr.setSelection(TextSelection.near(endOfMark)));
|
||||
@@ -145,7 +153,9 @@ export default class Placeholder extends Mark {
|
||||
state.selection.$from,
|
||||
state.schema.marks.placeholder
|
||||
);
|
||||
if (!range) return false;
|
||||
if (!range) {
|
||||
return false;
|
||||
}
|
||||
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
|
||||
@@ -150,7 +150,9 @@ export default class CodeFence extends Node {
|
||||
state: EditorState,
|
||||
dispatch: (tr: Transaction) => void
|
||||
) => {
|
||||
if (!isInCode(state)) return false;
|
||||
if (!isInCode(state)) {
|
||||
return false;
|
||||
}
|
||||
const {
|
||||
tr,
|
||||
selection,
|
||||
@@ -171,7 +173,9 @@ export default class CodeFence extends Node {
|
||||
return true;
|
||||
},
|
||||
Tab: (state: EditorState, dispatch: (tr: Transaction) => void) => {
|
||||
if (!isInCode(state)) return false;
|
||||
if (!isInCode(state)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const { tr, selection } = state;
|
||||
dispatch(tr.insertText(" ", selection.from, selection.to));
|
||||
|
||||
@@ -39,7 +39,9 @@ export default class HardBreak extends Node {
|
||||
state: EditorState,
|
||||
dispatch: (tr: Transaction) => void
|
||||
) => {
|
||||
if (!isInTable(state)) return false;
|
||||
if (!isInTable(state)) {
|
||||
return false;
|
||||
}
|
||||
dispatch(state.tr.replaceSelectionWith(type.create()).scrollIntoView());
|
||||
return true;
|
||||
},
|
||||
|
||||
@@ -216,7 +216,9 @@ export default class Heading extends Node {
|
||||
const previouslySeen = {};
|
||||
|
||||
doc.descendants((node, pos) => {
|
||||
if (node.type.name !== this.name) return;
|
||||
if (node.type.name !== this.name) {
|
||||
return;
|
||||
}
|
||||
|
||||
// calculate the optimal id
|
||||
const slug = headingToSlug(node);
|
||||
|
||||
@@ -41,7 +41,9 @@ const uploadPlugin = (options: Options) =>
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!event.clipboardData) return false;
|
||||
if (!event.clipboardData) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// check if we actually pasted any files
|
||||
const files = Array.prototype.slice
|
||||
@@ -49,7 +51,9 @@ const uploadPlugin = (options: Options) =>
|
||||
.map((dt: any) => dt.getAsFile())
|
||||
.filter((file: File) => file);
|
||||
|
||||
if (files.length === 0) return false;
|
||||
if (files.length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const { tr } = view.state;
|
||||
if (!tr.selection.empty) {
|
||||
@@ -96,7 +100,9 @@ const uploadPlugin = (options: Options) =>
|
||||
const IMAGE_CLASSES = ["right-50", "left-50"];
|
||||
|
||||
const getLayoutAndTitle = (tokenTitle: string | null) => {
|
||||
if (!tokenTitle) return {};
|
||||
if (!tokenTitle) {
|
||||
return {};
|
||||
}
|
||||
if (IMAGE_CLASSES.includes(tokenTitle)) {
|
||||
return {
|
||||
layoutClass: tokenTitle,
|
||||
@@ -242,7 +248,9 @@ export default class Image extends Node {
|
||||
const alt = event.currentTarget.innerText;
|
||||
const { src, title, layoutClass } = node.attrs;
|
||||
|
||||
if (alt === node.attrs.alt) return;
|
||||
if (alt === node.attrs.alt) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { view } = this.editor;
|
||||
const { tr } = view.state;
|
||||
|
||||
@@ -203,8 +203,12 @@ export default class ListItem extends Node {
|
||||
state: EditorState,
|
||||
dispatch: (tr: Transaction) => void
|
||||
) => {
|
||||
if (!isInList(state)) return false;
|
||||
if (!state.selection.empty) return false;
|
||||
if (!isInList(state)) {
|
||||
return false;
|
||||
}
|
||||
if (!state.selection.empty) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const { tr, selection } = state;
|
||||
dispatch(tr.split(selection.to));
|
||||
@@ -214,9 +218,13 @@ export default class ListItem extends Node {
|
||||
state: EditorState,
|
||||
dispatch: (tr: Transaction) => void
|
||||
) => {
|
||||
if (!state.selection.empty) return false;
|
||||
if (!state.selection.empty) {
|
||||
return false;
|
||||
}
|
||||
const result = getParentListItem(state);
|
||||
if (!result) return false;
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const [li, pos] = result;
|
||||
const $pos = state.doc.resolve(pos);
|
||||
@@ -244,9 +252,13 @@ export default class ListItem extends Node {
|
||||
state: EditorState,
|
||||
dispatch: (tr: Transaction) => void
|
||||
) => {
|
||||
if (!state.selection.empty) return false;
|
||||
if (!state.selection.empty) {
|
||||
return false;
|
||||
}
|
||||
const result = getParentListItem(state);
|
||||
if (!result) return false;
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const [li, pos] = result;
|
||||
const $pos = state.doc.resolve(pos + li.nodeSize);
|
||||
|
||||
@@ -124,7 +124,9 @@ export default class Table extends Node {
|
||||
Tab: goToNextCell(1),
|
||||
"Shift-Tab": goToNextCell(-1),
|
||||
Enter: (state: EditorState, dispatch: (tr: Transaction) => void) => {
|
||||
if (!isInTable(state)) return false;
|
||||
if (!isInTable(state)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: Adding row at the end for now, can we find the current cell
|
||||
// row index and add the row below that?
|
||||
@@ -156,11 +158,15 @@ export default class Table extends Node {
|
||||
let index = 0;
|
||||
|
||||
doc.descendants((node, pos) => {
|
||||
if (node.type.name !== this.name) return;
|
||||
if (node.type.name !== this.name) {
|
||||
return;
|
||||
}
|
||||
|
||||
const elements = document.getElementsByClassName("rme-table");
|
||||
const table = elements[index];
|
||||
if (!table) return;
|
||||
if (!table) {
|
||||
return;
|
||||
}
|
||||
|
||||
const element = table.parentElement;
|
||||
const shadowRight = !!(
|
||||
|
||||
@@ -44,7 +44,9 @@ export function run(
|
||||
|
||||
const match = regex.exec(textBefore);
|
||||
const tr = handler(state, match, match ? from - match[0].length : from, to);
|
||||
if (!tr) return false;
|
||||
if (!tr) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,9 @@ export default class Folding extends Extension {
|
||||
return {};
|
||||
},
|
||||
appendTransaction: (transactions, oldState, newState) => {
|
||||
if (loaded) return;
|
||||
if (loaded) {
|
||||
return;
|
||||
}
|
||||
if (
|
||||
!transactions.some((transaction) => transaction.getMeta("folding"))
|
||||
) {
|
||||
|
||||
@@ -53,7 +53,9 @@ export default class PasteHandler extends Extension {
|
||||
if (view.props.editable && !view.props.editable(view.state)) {
|
||||
return false;
|
||||
}
|
||||
if (!event.clipboardData) return false;
|
||||
if (!event.clipboardData) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const text = event.clipboardData.getData("text/plain");
|
||||
const html = event.clipboardData.getData("text/html");
|
||||
|
||||
@@ -2,7 +2,9 @@ import { CellSelection } from "prosemirror-tables";
|
||||
|
||||
export default function getColumnIndex(selection: CellSelection) {
|
||||
const isColSelection = selection.isColSelection && selection.isColSelection();
|
||||
if (!isColSelection) return undefined;
|
||||
if (!isColSelection) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const path = (selection.$from as any).path;
|
||||
return path[path.length - 5];
|
||||
|
||||
@@ -2,7 +2,9 @@ import { CellSelection } from "prosemirror-tables";
|
||||
|
||||
export default function getRowIndex(selection: CellSelection) {
|
||||
const isRowSelection = selection.isRowSelection && selection.isRowSelection();
|
||||
if (!isRowSelection) return undefined;
|
||||
if (!isRowSelection) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const path = (selection.$from as any).path;
|
||||
return path[path.length - 8];
|
||||
|
||||
@@ -26,7 +26,9 @@ export default function markdownBreakToParagraphs(md: MarkdownIt) {
|
||||
const children = tokenChildren.filter((child) => !isHardbreak(child));
|
||||
|
||||
let count = matches.length;
|
||||
if (children.length) count++;
|
||||
if (children.length) {
|
||||
count++;
|
||||
}
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
const isLast = i === count - 1;
|
||||
|
||||
@@ -23,8 +23,12 @@ export default function (embeds: EmbedDescriptor[]) {
|
||||
const href = link.attrs ? link.attrs[0][1] : "";
|
||||
const simpleLink = href === token.content;
|
||||
|
||||
if (!simpleLink) return false;
|
||||
if (!embeds) return false;
|
||||
if (!simpleLink) {
|
||||
return false;
|
||||
}
|
||||
if (!embeds) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const embed of embeds) {
|
||||
const matches = embed.matcher(href);
|
||||
@@ -51,7 +55,9 @@ export default function (embeds: EmbedDescriptor[]) {
|
||||
|
||||
for (let j = 0; j < tokenChildren.length - 1; j++) {
|
||||
const current = tokenChildren[j];
|
||||
if (!current) continue;
|
||||
if (!current) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isLinkOpen(current)) {
|
||||
insideLink = current;
|
||||
|
||||
@@ -10,8 +10,12 @@ type Domain = {
|
||||
// a large list of possible TLD's which increase the size of the bundle
|
||||
// unnecessarily for our usecase of trusted input.
|
||||
export function parseDomain(url?: string): Domain | null | undefined {
|
||||
if (typeof url !== "string") return null;
|
||||
if (url === "") return null;
|
||||
if (typeof url !== "string") {
|
||||
return null;
|
||||
}
|
||||
if (url === "") {
|
||||
return null;
|
||||
}
|
||||
|
||||
// strip extermeties and whitespace from input
|
||||
const normalizedDomain = trim(url.replace(/(https?:)?\/\//, ""));
|
||||
@@ -54,8 +58,12 @@ export function parseDomain(url?: string): Domain | null | undefined {
|
||||
|
||||
export function stripSubdomain(hostname: string) {
|
||||
const parsed = parseDomain(hostname);
|
||||
if (!parsed) return hostname;
|
||||
if (parsed.tld) return `${parsed.domain}.${parsed.tld}`;
|
||||
if (!parsed) {
|
||||
return hostname;
|
||||
}
|
||||
if (parsed.tld) {
|
||||
return `${parsed.domain}.${parsed.tld}`;
|
||||
}
|
||||
return parsed.domain;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,9 @@ function naturalSortBy<T>(
|
||||
key: string | ((item: T) => string),
|
||||
sortOptions?: NaturalSortOptions
|
||||
): T[] {
|
||||
if (!items) return [];
|
||||
if (!items) {
|
||||
return [];
|
||||
}
|
||||
const sort = sortOptions
|
||||
? naturalSort({
|
||||
caseSensitive: sortOptions.caseSensitive,
|
||||
|
||||
Reference in New Issue
Block a user