1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-11-08 21:42:24 +03:00

Switch to a discriminated unions

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski
2020-07-20 16:33:53 +01:00
parent 2bf5e4b142
commit ed0d9973b7
9 changed files with 130 additions and 74 deletions

View File

@@ -15,16 +15,15 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import {BasePart} from "./parts";
import {Part} from "./parts";
import EditorModel from "./model";
import {instanceOf} from "prop-types";
export function needsCaretNodeBefore(part: BasePart, prevPart: BasePart) {
export function needsCaretNodeBefore(part: Part, prevPart: Part) {
const isFirst = !prevPart || prevPart.type === "newline";
return !part.canEdit && (isFirst || !prevPart.canEdit);
}
export function needsCaretNodeAfter(part: BasePart, isLastOfLine: boolean) {
export function needsCaretNodeAfter(part: Part, isLastOfLine: boolean) {
return !part.canEdit && isLastOfLine;
}
@@ -83,7 +82,7 @@ function removeChildren(parent: HTMLElement) {
}
}
function reconcileLine(lineContainer: ChildNode, parts: BasePart[]) {
function reconcileLine(lineContainer: ChildNode, parts: Part[]) {
let currentNode;
let prevPart;
const lastPart = parts[parts.length - 1];