|
@@ -5,7 +5,7 @@ import * as dayjs from "dayjs";
|
|
|
import {transaction, updateTransaction} from "./transaction";
|
|
|
import {mathRender} from "../render/mathRender";
|
|
|
import {highlightRender} from "../render/highlightRender";
|
|
|
-import {getContenteditableElement, getNextBlock, isNotEditBlock} from "./getBlock";
|
|
|
+import {getContenteditableElement, getNextBlock, hasNextSibling, isNotEditBlock} from "./getBlock";
|
|
|
import {genEmptyBlock} from "../../block/util";
|
|
|
import {blockRender} from "../render/blockRender";
|
|
|
import {hideElements} from "../ui/hideElements";
|
|
@@ -14,7 +14,7 @@ import {fetchPost, fetchSyncPost} from "../../util/fetch";
|
|
|
import {headingTurnIntoList, turnIntoTaskList} from "./turnIntoList";
|
|
|
import {updateAVName} from "../render/av/action";
|
|
|
|
|
|
-export const input = async (protyle: IProtyle, blockElement: HTMLElement, range: Range, needRender = true) => {
|
|
|
+export const input = async (protyle: IProtyle, blockElement: HTMLElement, range: Range, needRender = true, event?: InputEvent) => {
|
|
|
if (!blockElement.parentElement) {
|
|
|
// 不同 windows 版本下输入法会多次触发 input,导致 outerhtml 赋值的块丢失
|
|
|
return;
|
|
@@ -48,6 +48,15 @@ export const input = async (protyle: IProtyle, blockElement: HTMLElement, range:
|
|
|
blockElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
|
|
|
const wbrElement = document.createElement("wbr");
|
|
|
range.insertNode(wbrElement);
|
|
|
+ if (event && event.inputType === "deleteContentForward") {
|
|
|
+ const wbrNextElement = hasNextSibling(wbrElement) as HTMLElement;
|
|
|
+ if (wbrNextElement && wbrNextElement.nodeType === 1 && !wbrNextElement.textContent.startsWith(Constants.ZWSP)) {
|
|
|
+ const type = wbrNextElement.getAttribute("data-type").split(" ")
|
|
|
+ if (type.includes("code") || type.includes("kbd") || type.includes("tag")) {
|
|
|
+ wbrNextElement.insertAdjacentElement("afterbegin", wbrElement);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
const id = blockElement.getAttribute("data-node-id");
|
|
|
if (type !== "NodeCodeBlock" && (editElement.innerHTML.endsWith("\n<wbr>") || editElement.innerHTML.endsWith("\n<wbr>\n"))) {
|
|
|
// 软换行
|