mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Move isInside to private function (#15268)
This text manipulation library can be used by plugins as well, so better to have this defined as a function instead of floating above the class.
This commit is contained in:
@@ -11,11 +11,6 @@ import {
|
|||||||
} from "discourse/lib/utilities";
|
} from "discourse/lib/utilities";
|
||||||
import { next, schedule } from "@ember/runloop";
|
import { next, schedule } from "@ember/runloop";
|
||||||
|
|
||||||
const isInside = (text, regex) => {
|
|
||||||
const matches = text.match(regex);
|
|
||||||
return matches && matches.length % 2;
|
|
||||||
};
|
|
||||||
|
|
||||||
const INDENT_DIRECTION_LEFT = "left";
|
const INDENT_DIRECTION_LEFT = "left";
|
||||||
const INDENT_DIRECTION_RIGHT = "right";
|
const INDENT_DIRECTION_RIGHT = "right";
|
||||||
|
|
||||||
@@ -240,6 +235,11 @@ export default Mixin.create({
|
|||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_isInside(text, regex) {
|
||||||
|
const matches = text.match(regex);
|
||||||
|
return matches && matches.length % 2;
|
||||||
|
},
|
||||||
|
|
||||||
@bind
|
@bind
|
||||||
paste(e) {
|
paste(e) {
|
||||||
if (!this._$textarea.is(":focus") && !isTesting()) {
|
if (!this._$textarea.is(":focus") && !isTesting()) {
|
||||||
@@ -259,7 +259,7 @@ export default Mixin.create({
|
|||||||
const selected = this._getSelected(null, { lineVal: true });
|
const selected = this._getSelected(null, { lineVal: true });
|
||||||
const { pre, value: selectedValue, lineVal } = selected;
|
const { pre, value: selectedValue, lineVal } = selected;
|
||||||
const isInlinePasting = pre.match(/[^\n]$/);
|
const isInlinePasting = pre.match(/[^\n]$/);
|
||||||
const isCodeBlock = isInside(pre, /(^|\n)```/g);
|
const isCodeBlock = this._isInside(pre, /(^|\n)```/g);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
plainText &&
|
plainText &&
|
||||||
@@ -279,7 +279,7 @@ export default Mixin.create({
|
|||||||
if (isInlinePasting) {
|
if (isInlinePasting) {
|
||||||
canPasteHtml = !(
|
canPasteHtml = !(
|
||||||
lineVal.match(/^```/) ||
|
lineVal.match(/^```/) ||
|
||||||
isInside(pre, /`/g) ||
|
this._isInside(pre, /`/g) ||
|
||||||
lineVal.match(/^ /)
|
lineVal.match(/^ /)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user