Templates 2.0 (#636)
Templates 2.0 and a whole bunch of other refactoring
This commit is contained in:
@@ -131,9 +131,12 @@ export function attachmentExtension(editor: Client) {
|
||||
if (currentNode) {
|
||||
const fencedParentNode = findParentMatching(
|
||||
currentNode,
|
||||
(t) => t.type === "FencedCode",
|
||||
(t) => ["FrontMatter", "FencedCode"].includes(t.type!),
|
||||
);
|
||||
if (fencedParentNode || currentNode.type === "FencedCode") {
|
||||
if (
|
||||
fencedParentNode ||
|
||||
["FrontMatter", "FencedCode"].includes(currentNode.type!)
|
||||
) {
|
||||
console.log("Inside of fenced code block, not pasting rich text");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -165,8 +165,13 @@ export class MarkdownWidget extends WidgetType {
|
||||
el.addEventListener("click", (e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
console.info("Command link clicked in widget, running", command);
|
||||
this.client.runCommandByName(command).catch(console.error);
|
||||
console.info(
|
||||
"Command link clicked in widget, running",
|
||||
parsedOnclick,
|
||||
);
|
||||
this.client.runCommandByName(command, parsedOnclick[2]).catch(
|
||||
console.error,
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
+11
-3
@@ -30,13 +30,21 @@ export class LinkWidget extends WidgetType {
|
||||
anchor.textContent = this.options.text;
|
||||
|
||||
// Mouse handling
|
||||
anchor.addEventListener("mousedown", (e) => {
|
||||
anchor.addEventListener("click", (e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
});
|
||||
anchor.addEventListener("mouseup", (e) => {
|
||||
if (e.button !== 0) {
|
||||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.options.callback(e);
|
||||
try {
|
||||
this.options.callback(e);
|
||||
} catch (e) {
|
||||
console.error("Error handling wiki link click", e);
|
||||
}
|
||||
});
|
||||
|
||||
// Touch handling
|
||||
@@ -111,7 +119,7 @@ export class ButtonWidget extends WidgetType {
|
||||
const anchor = document.createElement("button");
|
||||
anchor.className = this.cssClass;
|
||||
anchor.textContent = this.text;
|
||||
anchor.addEventListener("click", (e) => {
|
||||
anchor.addEventListener("mouseup", (e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.callback(e);
|
||||
|
||||
Reference in New Issue
Block a user