forked from SkepticMystic/breadcrumbs
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Initial work on juggl code blocks
- Loading branch information
Showing
7 changed files
with
77 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,44 @@ | ||
import type {ParsedCodeblock} from "../interfaces"; | ||
import type BCPlugin from "../main"; | ||
import {getPlugin, IJugglSettings} from 'juggl-api'; | ||
|
||
export function createdJugglCB(target: HTMLElement, args: ParsedCodeblock) { | ||
function indentToDepth(indent: string) { | ||
return indent.length / 2 + 1; | ||
} | ||
|
||
function meetsConditions(indent: string, node: string, froms: string[], min: number, max: number) { | ||
const depth = indentToDepth(indent); | ||
return ( | ||
depth >= min && | ||
depth <= max && | ||
(froms === undefined || froms.includes(node)) | ||
); | ||
} | ||
|
||
export function createdJugglCB(plugin: BCPlugin, | ||
target: HTMLElement, | ||
args: ParsedCodeblock, | ||
lines: [string, string][], | ||
froms: string[], | ||
min: number, | ||
max: number) { | ||
try { | ||
const jugglPlugin = getPlugin(plugin.app); | ||
if (!jugglPlugin) { | ||
// TODO: Error handling | ||
return; | ||
} | ||
const nodes = lines | ||
.filter(([indent, node]) => meetsConditions(indent, node, froms, min, max)) | ||
.map(([_, node]) => node); | ||
console.log({nodes}) | ||
const juggl = jugglPlugin.createJuggl(target, null, null, nodes) | ||
console.log("Created juggl!") | ||
plugin.addChild(juggl); | ||
juggl.load(); | ||
console.log({juggl}); | ||
} | ||
catch (error) { | ||
plugin.codeblockError(args) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -182,7 +182,7 @@ | |
dependencies: | ||
"@octokit/types" "^6.0.3" | ||
|
||
"@octokit/core@^3.5.1": | ||
"@octokit/core@^3.5.0", "@octokit/core@^3.5.1", "@octokit/core@>=2", "@octokit/core@>=3": | ||
"integrity" "sha512-omncwpLVxMP+GLpLPgeGJBF6IWJFjXDS5flY5VbppePYX9XehevbDykRH9PdCdvqt9TS5AOTiDide7h0qrkHjw==" | ||
"resolved" "https://registry.npmjs.org/@octokit/core/-/core-3.5.1.tgz" | ||
"version" "3.5.1" | ||
|
@@ -525,7 +525,7 @@ | |
"eslint-scope" "^5.1.1" | ||
"eslint-utils" "^3.0.0" | ||
|
||
"@typescript-eslint/parser@^4.27.0": | ||
"@typescript-eslint/parser@^4.0.0", "@typescript-eslint/parser@^4.27.0": | ||
"integrity" "sha512-UjrMsgnhQIIK82hXGaD+MCN8IfORS1CbMdu7VlZbYa8LCZtbZjJA26De4IPQB7XYZbL8gJ99KWNj0l6WD0guJg==" | ||
"resolved" "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.28.1.tgz" | ||
"version" "4.28.1" | ||
|
@@ -584,7 +584,7 @@ | |
"resolved" "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.1.tgz" | ||
"version" "5.3.1" | ||
|
||
"acorn@^7.4.0": | ||
"acorn@^6.0.0 || ^7.0.0 || ^8.0.0", "acorn@^7.4.0": | ||
"integrity" "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==" | ||
"resolved" "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz" | ||
"version" "7.4.1" | ||
|
@@ -1353,7 +1353,7 @@ | |
"resolved" "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz" | ||
"version" "1.0.3" | ||
|
||
"[email protected]": | ||
"cosmiconfig@>=6", "cosmiconfig@7.0.0": | ||
"integrity" "sha512-pondGvTuVYDk++upghXJabWzL6Kxu6f26ljFw64Swq9v6sQPUL3EUlVDV56diOjpCayKihL6hVe8exIACU4XcA==" | ||
"resolved" "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-7.0.0.tgz" | ||
"version" "7.0.0" | ||
|
@@ -1940,7 +1940,7 @@ | |
"resolved" "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz" | ||
"version" "2.1.0" | ||
|
||
"eslint@^7.29.0": | ||
"eslint@*", "eslint@^5.0.0 || ^6.0.0 || ^7.0.0", "eslint@^7.29.0", "eslint@>=5": | ||
"integrity" "sha512-VLqz80i3as3NdloY44BQSJpFw534L9Oh+6zJOUaViV4JPd+DaHwutqP7tcpkW3YiXbK6s05RZl7yl7cQn+lijg==" | ||
"resolved" "https://registry.npmjs.org/eslint/-/eslint-7.30.0.tgz" | ||
"version" "7.30.0" | ||
|
@@ -2253,7 +2253,7 @@ | |
"resolved" "https://registry.npmjs.org/flatted/-/flatted-3.2.0.tgz" | ||
"version" "3.2.0" | ||
|
||
"fp-ts@^2.5.3": | ||
"fp-ts@^2.5.0", "fp-ts@^2.5.3": | ||
"integrity" "sha512-UUpeygu50mV/J96Nk92fzHDznYXJxsO20wrUZGJppja1f8P+fhCaclcqcfubEyrH7XXPsmYn98CJF0BVAEn3ZQ==" | ||
"resolved" "https://registry.npmjs.org/fp-ts/-/fp-ts-2.11.7.tgz" | ||
"version" "2.11.7" | ||
|
@@ -2413,7 +2413,7 @@ | |
"graphology-utils" "^2.0.0" | ||
"mnemonist" "^0.38.3" | ||
|
||
"graphology-types@^0.23.0": | ||
"graphology-types@^0.23.0", "graphology-types@>=0.20.0", "graphology-types@>=0.23.0": | ||
"integrity" "sha512-6Je1NWU3el7YmybAhRzrOEi79Blhx05EU3wGUCvP5ikaxRXEflrW/5unfw5q/wqfwjryM9tcwUv4M7TZ8yTBYQ==" | ||
"resolved" "https://registry.npmjs.org/graphology-types/-/graphology-types-0.23.0.tgz" | ||
"version" "0.23.0" | ||
|
@@ -2887,8 +2887,8 @@ | |
"jsonparse" "^1.2.0" | ||
"through" ">=2.2.7 <3" | ||
|
||
"juggl-api@git+https://github.com/HEmile/juggl-api.git": | ||
"resolved" "git+ssh://[email protected]/HEmile/juggl-api.git#1caa564271ca44e2c56cdac947f44b59b200ff44" | ||
"juggl-api@github:HEmile/juggl-api": | ||
"resolved" "git+ssh://[email protected]/HEmile/juggl-api.git#f286b3855858686bc381ed4c47a429d196aafcfd" | ||
"version" "1.0.0" | ||
dependencies: | ||
"@types/cytoscape" "^3.14.11" | ||
|
@@ -3137,7 +3137,7 @@ | |
dependencies: | ||
"obliterator" "^2.0.0" | ||
|
||
"mocha@^9.1.3": | ||
"mocha@^3.X.X || ^4.X.X || ^5.X.X || ^6.X.X || ^7.X.X || ^8.X.X", "mocha@^9.1.3": | ||
"integrity" "sha512-Xcpl9FqXOAYqI3j79pEtHBBnQgVXIhpULjGQa7DVb0Po+VzmSIK9kanAiWLHoRR/dbZ2qpdPshuXr8l1VaHCzw==" | ||
"resolved" "https://registry.npmjs.org/mocha/-/mocha-9.1.3.tgz" | ||
"version" "9.1.3" | ||
|
@@ -3888,7 +3888,7 @@ | |
dependencies: | ||
"estree-walker" "^0.6.1" | ||
|
||
"rollup@^2.32.1": | ||
"rollup@^1.20.0||^2.0.0", "rollup@^2.14.0", "rollup@^2.30.0", "rollup@^2.32.1", "rollup@>=2.0.0": | ||
"integrity" "sha512-55cSH4CCU6MaPr9TAOyrIC+7qFCHscL7tkNsm1MBfIJRRqRbCEY0mmeFn4Wg8FKsHtEH8r389Fz38r/o+kgXLg==" | ||
"resolved" "https://registry.npmjs.org/rollup/-/rollup-2.52.7.tgz" | ||
"version" "2.52.7" | ||
|
@@ -4306,7 +4306,7 @@ | |
"detect-indent" "^6.0.0" | ||
"strip-indent" "^3.0.0" | ||
|
||
"[email protected]": | ||
"svelte@^3.23.0", "svelte@^3.24.0", "svelte@>=3.5.0", "svelte@3.35.0": | ||
"integrity" "sha512-gknlZkR2sXheu/X+B7dDImwANVvK1R0QGQLd8CNIfxxGPeXBmePnxfzb6fWwTQRsYQG7lYkZXvpXJvxvpsoB7g==" | ||
"resolved" "https://registry.npmjs.org/svelte/-/svelte-3.35.0.tgz" | ||
"version" "3.35.0" | ||
|
@@ -4477,6 +4477,11 @@ | |
"minimist" "^1.2.0" | ||
"strip-bom" "^3.0.0" | ||
|
||
"tslib@*", "tslib@^2", "tslib@^2.2.0": | ||
"integrity" "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==" | ||
"resolved" "https://registry.npmjs.org/tslib/-/tslib-2.3.0.tgz" | ||
"version" "2.3.0" | ||
|
||
"tslib@^1.14.1": | ||
"integrity" "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" | ||
"resolved" "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz" | ||
|
@@ -4487,11 +4492,6 @@ | |
"resolved" "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz" | ||
"version" "1.14.1" | ||
|
||
"tslib@^2", "tslib@^2.2.0": | ||
"integrity" "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==" | ||
"resolved" "https://registry.npmjs.org/tslib/-/tslib-2.3.0.tgz" | ||
"version" "2.3.0" | ||
|
||
"[email protected]": | ||
"integrity" "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==" | ||
"resolved" "https://registry.npmjs.org/tslib/-/tslib-2.1.0.tgz" | ||
|
@@ -4551,7 +4551,7 @@ | |
"resolved" "https://registry.npmjs.org/typescript-memoize/-/typescript-memoize-1.1.0.tgz" | ||
"version" "1.1.0" | ||
|
||
"typescript@*", "typescript@^4.4.2": | ||
"typescript@*", "typescript@^3.9.5 || ^4.0.0", "typescript@^4.4.2", "typescript@>=2.7", "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta", "typescript@>=3.7.0": | ||
"integrity" "sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg==" | ||
"resolved" "https://registry.npmjs.org/typescript/-/typescript-4.5.4.tgz" | ||
"version" "4.5.4" | ||
|