Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sawhney17 committed Mar 14, 2022
1 parent 3754421 commit 3c76e49
Show file tree
Hide file tree
Showing 6 changed files with 1,710 additions and 27 deletions.
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"tabWidth": 2,
"useTabs": false
}
Binary file modified icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 0 additions & 22 deletions index.js

This file was deleted.

58 changes: 58 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import '@logseq/libs';
import { SettingSchemaDesc } from '@logseq/libs/dist/LSPlugin.user';

// const settings = [{preferred}]
let settings: SettingSchemaDesc[] = [{ key: "CommaSeparatedOptions", type: "string", title: "Options in workflow", description: "Enter your desired workflow options, separated by commas. i.e. 'TODO, DOING, WAITING, CANCELLED'", default: "TODO, DONE, CANCELLED, WAITING" }, { key: "Keyboard-Shortcut", type: "string", title: "keyboard shortcut", description: "Choose your desired keyboard shortcut to toggle the changes", default: "mod+shift+enter" }]
logseq.useSettingsSchema(settings)
const main = async () => {
console.log('plugin loade2d');
console.log(logseq.settings['Keyboard-Shortcut'])

logseq.App.registerCommandPalette({
key: 'Toggle-Workflow-State',
label: 'Toggle Workflow State',
keybinding: {
binding: (await logseq.settings['Keyboard-Shortcut'])
}
}, async () => {
let block = await logseq.Editor.getCurrentBlock()
if (block != undefined) {
let blockFirstWord = block.content.split(' ')[0].split('\n')[0]
console.log("blockFirstWord", blockFirstWord)
block
let SeparatedArray = logseq.settings.CommaSeparatedOptions
let commaSeparatedArray = SeparatedArray.split(", ")
console.log(commaSeparatedArray)
let insertionTracker = false
for (const x in commaSeparatedArray) {


if (commaSeparatedArray[x] == (blockFirstWord)) {
console.log(blockFirstWord)
console.log(commaSeparatedArray[x])
let index = commaSeparatedArray.indexOf(commaSeparatedArray[x])
console.log(`The valeu i ${commaSeparatedArray[index + 1]}`)
console.log("YAY")
let finalText;
if (commaSeparatedArray[index + 1] == undefined) {
finalText = " "
insertionTracker = true
}
else {
finalText = commaSeparatedArray[index + 1]
insertionTracker = true
}
logseq.Editor.updateBlock(block.uuid, finalText)
break
}
}
if (insertionTracker == false) {
logseq.Editor.updateBlock(block.uuid, commaSeparatedArray[0])
}
}
else {
logseq.App.showMsg("Error: You can't toggle state outside of a block")
}
});
}
logseq.ready(main).catch(console.error);
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "logseq-starter-plugin",
"name": "logseq-custom-workflow-plugin",
"version": "1.0",
"description": "Starter Plugin",
"description": "Custom Workflow Plugin",
"main": "dist/index.html",
"targets": {
"main": false
Expand All @@ -14,11 +14,12 @@
"author": "Aryan Sawhney",
"license": "MIT",
"dependencies": {
"@logseq/libs": "0.0.1-alpha.34"
"@logseq/libs": "0.0.1-alpha.35",
"prettier": "^2.5.1"
},
"logseq": {
"id": "logseq-starter-plugin",
"title": "logseq-starter-plugin",
"id": "logseq-custom-workflow-plugin",
"title": "Custom Workflows",
"icon": "./icon.png"
},
"devDependencies": {
Expand Down
Loading

0 comments on commit 3c76e49

Please sign in to comment.