Skip to content

Commit

Permalink
flow editor for canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
jp-cen committed Dec 15, 2022
1 parent c1fdc86 commit c9b3c96
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 23 deletions.
42 changes: 23 additions & 19 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8844,39 +8844,43 @@ var loadFlowEditorByDOM2 = (make, el, view, id) => {
while (!dom.hasClass("mk-floweditor") && !dom.hasClass("workspace") && dom.parentElement) {
dom = dom.parentElement;
}
if (!dom.hasClass("mk-floweditor") && !dom.hasClass("workspace")) {
if (!dom.hasClass("mk-floweditor") && !dom.hasClass("workspace") && !(dom.nodeName == "HTML")) {
return;
}
setTimeout(async () => {
let counter2 = 0;
while (!dom.parentElement && counter2++ <= 50)
await sleep(50);
if (!dom.parentElement)
return;
app.workspace.iterateLeaves((leaf) => {
var _a2;
const cm = (_a2 = leaf.view.editor) == null ? void 0 : _a2.cm;
if (cm && view.dom == cm.dom) {
loadFlowEditorsForLeafForID(cm, leaf, make, id);
var _a2;
let leafFound = false;
if (app.workspace.activeEditor) {
if (app.workspace.activeEditor.editMode.cm.dom == view.dom) {
leafFound = true;
loadFlowEditorsForLeafForID(app.workspace.activeEditor.editMode.cm, (_a2 = app.workspace.activeEditor.file) == null ? void 0 : _a2.path, make, id);
}
}, app.workspace["rootSplit"]);
}
if (!leafFound) {
app.workspace.iterateLeaves((leaf) => {
var _a3, _b2;
const cm = (_a3 = leaf.view.editor) == null ? void 0 : _a3.cm;
if (cm && view.dom == cm.dom) {
leafFound = true;
loadFlowEditorsForLeafForID(cm, (_b2 = leaf.view.file) == null ? void 0 : _b2.path, make, id);
}
}, app.workspace["rootSplit"]);
}
});
});
};
var loadFlowEditorsForLeafForID = (cm, leaf, make, id) => {
var loadFlowEditorsForLeafForID = (cm, source, make, id) => {
const stateField = cm.state.field(flowEditorInfo, false);
if (!stateField)
return;
const flowInfo = stateField.find((f4) => f4.id == id);
if (flowInfo && flowInfo.expandedState == 2) {
loadFlowEditor(cm, flowInfo, leaf, make);
loadFlowEditor(cm, flowInfo, source, make);
}
};
var loadFlowEditor = (cm, flowEditorInfo2, leaf, make) => {
var _a2;
var loadFlowEditor = (cm, flowEditorInfo2, source, make) => {
const dom = cm.dom.querySelector("#mk-flow-" + flowEditorInfo2.id);
const [link, ref] = parseOutReferences(flowEditorInfo2.link);
const source = (_a2 = leaf.view.file) == null ? void 0 : _a2.path;
const file = getFileFromString(link, source);
if (dom) {
if (file) {
Expand All @@ -8893,7 +8897,7 @@ var loadFlowEditor = (cm, flowEditorInfo2, leaf, make) => {
e3.stopPropagation();
e3.stopImmediatePropagation();
await app.fileManager.createNewMarkdownFile(app.vault.getRoot(), link);
loadFlowEditor(cm, flowEditorInfo2, leaf, make);
loadFlowEditor(cm, flowEditorInfo2, source, make);
};
createDiv.setText(`"${link}" ` + i18n_default.labels.noFile);
createDiv.addEventListener("click", createFile);
Expand Down Expand Up @@ -23896,7 +23900,7 @@ var replaceAllEmbed = (el, ctx) => {
toggleState: false,
toggleFlow: (e3) => {
const cm = getCMFromElement(dom);
const pos = cm.posAtDOM(dom);
const pos = cm == null ? void 0 : cm.posAtDOM(dom);
iterateTreeInSelection({ from: pos - 3, to: pos + 4 }, cm.state, {
enter: (node) => {
if (node.name.contains("hmd-internal-link")) {
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "make-md",
"name": "MAKE.md",
"version": "0.5.3",
"version": "0.5.4",
"minAppVersion": "0.16.0",
"description": "Make.md brings you features that supercharges Obsidian. Sort your files in custom order and add file icons using Spaces. Edit inline embeds with Flow Editor. And style your text and add new markdown blocks without writing markdown using Maker Mode.",
"author": "MAKE.md",
Expand Down
8 changes: 5 additions & 3 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
margin: 0;
border-radius: var(--he-popover-border-radius);
overflow: hidden;
height: 100%;
}
.mk-floweditor.hover-editor .popover-content .workspace-split {
display: none;
}
.mk-floweditor.hover-editor .workspace-leaf,
.mk-floweditor.hover-editor .workspace-split {
Expand Down Expand Up @@ -107,7 +109,7 @@
border: thin solid var(--color-base-20);
margin-top: 4px;
}
.mk-flow-classic .markdown-embed {
.mk-flow-classic .internal-embed.markdown-embed {
margin-top: 24px;
}
.markdown-embed .markdown-rendered h1,
Expand All @@ -121,7 +123,7 @@
.markdown-embed p {
margin-bottom: 24px;
}
.mk-flow-seamless .markdown-embed {
.mk-flow-seamless .internal-embed.markdown-embed {
margin-top: 24px;
}
.mk-floweditor-container:not(.mk-floweditor-fix) > .mk-floweditor:hover {
Expand Down

0 comments on commit c9b3c96

Please sign in to comment.