Vanessa 2024-12-17 20:03:37 +08:00
parent b3326e9757
commit 053e03ed53
2 changed files with 4 additions and 4 deletions

View file

@ -1027,7 +1027,7 @@ export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLEleme
element.style.maxWidth = "none";
const textElements = element.querySelectorAll("textarea");
textElements[0].addEventListener("input", (event: InputEvent) => {
const value = (event.target as HTMLInputElement).value.replace(/\n|\r\n|\r|\u2028|\u2029/g, "");
const value = (event.target as HTMLInputElement).value.replace(/\n|\r\n|\r|\u2028|\u2029/g, "").trim();
imgElement.setAttribute("src", value);
imgElement.setAttribute("data-src", value);
if (value.startsWith("assets/")) {
@ -1854,7 +1854,7 @@ export const iframeMenu = (protyle: IProtyle, nodeElement: Element) => {
bind(element) {
element.style.maxWidth = "none";
element.querySelector("textarea").addEventListener("change", (event) => {
const value = (event.target as HTMLTextAreaElement).value.replace(/\n|\r\n|\r|\u2028|\u2029/g, "");
const value = (event.target as HTMLTextAreaElement).value.replace(/\n|\r\n|\r|\u2028|\u2029/g, "").trim();
const biliMatch = value.match(/(?:www\.|\/\/)bilibili\.com\/video\/(\w+)/);
if (value.indexOf("bilibili.com") > -1 && (value.indexOf("bvid=") > -1 || (biliMatch && biliMatch[1]))) {
const params: IObject = {
@ -1925,7 +1925,7 @@ export const videoMenu = (protyle: IProtyle, nodeElement: Element, type: string)
bind(element) {
element.style.maxWidth = "none";
element.querySelector("textarea").addEventListener("change", (event) => {
videoElement.setAttribute("src", (event.target as HTMLTextAreaElement).value.replace(/\n|\r\n|\r|\u2028|\u2029/g, ""));
videoElement.setAttribute("src", (event.target as HTMLTextAreaElement).value.replace(/\n|\r\n|\r|\u2028|\u2029/g, "").trim());
updateTransaction(protyle, id, nodeElement.outerHTML, html);
html = nodeElement.outerHTML;
event.stopPropagation();