Compare commits
1 Commits
WebView-wi
...
929d4e1ccd
Author | SHA1 | Date | |
---|---|---|---|
929d4e1ccd |
6
.gitignore
vendored
6
.gitignore
vendored
@ -264,3 +264,9 @@ __pycache__/
|
|||||||
type-script-helper-1.1.6.vsix
|
type-script-helper-1.1.6.vsix
|
||||||
type-script-helper-1.1.7.vsix
|
type-script-helper-1.1.7.vsix
|
||||||
type-script-helper-1.1.8.vsix
|
type-script-helper-1.1.8.vsix
|
||||||
|
|
||||||
|
.kanbn
|
||||||
|
*.exe
|
||||||
|
*.pdb
|
||||||
|
|
||||||
|
.vscode/helper/**
|
||||||
|
20
.vscode/launch.json
vendored
20
.vscode/launch.json
vendored
@ -1,20 +0,0 @@
|
|||||||
// A launch configuration that compiles the extension and then opens it inside a new window
|
|
||||||
// Use IntelliSense to learn about possible attributes.
|
|
||||||
// Hover to view descriptions of existing attributes.
|
|
||||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
||||||
{
|
|
||||||
"version": "0.2.0",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "Run Extension",
|
|
||||||
"type": "extensionHost",
|
|
||||||
"request": "launch",
|
|
||||||
"args": [
|
|
||||||
"--extensionDevelopmentPath=${workspaceFolder}/type-script-helper"
|
|
||||||
],
|
|
||||||
"outFiles": [
|
|
||||||
"${workspaceFolder}/dist/**/*.js"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
19
.vscode/settings.json
vendored
19
.vscode/settings.json
vendored
@ -1,6 +1,23 @@
|
|||||||
{
|
{
|
||||||
|
"[markdown]": {
|
||||||
|
"editor.wordWrap": "off"
|
||||||
|
},
|
||||||
"cSpell.words": [
|
"cSpell.words": [
|
||||||
|
"initialise",
|
||||||
"Kanban",
|
"Kanban",
|
||||||
"VSIX"
|
"VSIX"
|
||||||
]
|
],
|
||||||
|
"files.eol": "\n",
|
||||||
|
"files.exclude": {
|
||||||
|
"**/dist": false,
|
||||||
|
"**/node_modules": true,
|
||||||
|
"**/out": false
|
||||||
|
},
|
||||||
|
"files.watcherExclude": {
|
||||||
|
"**/node_modules": true
|
||||||
|
},
|
||||||
|
"search.exclude": {
|
||||||
|
"**/dist": true,
|
||||||
|
"**/out": true
|
||||||
|
}
|
||||||
}
|
}
|
BIN
Application.evtx
Normal file
BIN
Application.evtx
Normal file
Binary file not shown.
BIN
type-script-helper-1.5.1.vsix
Normal file
BIN
type-script-helper-1.5.1.vsix
Normal file
Binary file not shown.
7
type-script-helper/.gitignore
vendored
7
type-script-helper/.gitignore
vendored
@ -1,5 +1,6 @@
|
|||||||
out
|
.vscode-test/
|
||||||
|
.vscode/helper/**
|
||||||
|
*.vsix
|
||||||
dist
|
dist
|
||||||
node_modules
|
node_modules
|
||||||
.vscode-test/
|
out
|
||||||
*.vsix
|
|
18
type-script-helper/.vscode/launch.json
vendored
18
type-script-helper/.vscode/launch.json
vendored
@ -14,22 +14,16 @@
|
|||||||
],
|
],
|
||||||
"outFiles": [
|
"outFiles": [
|
||||||
"${workspaceFolder}/dist/**/*.js"
|
"${workspaceFolder}/dist/**/*.js"
|
||||||
],
|
]
|
||||||
"preLaunchTask": "${defaultBuildTask}"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Extension Tests",
|
"type": "node",
|
||||||
"type": "extensionHost",
|
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"args": [
|
"name": "Launch Program",
|
||||||
"--extensionDevelopmentPath=${workspaceFolder}",
|
"program": "${workspaceFolder}/src/extension.ts",
|
||||||
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
|
|
||||||
],
|
|
||||||
"outFiles": [
|
"outFiles": [
|
||||||
"${workspaceFolder}/out/**/*.js",
|
"${workspaceFolder}/out/**/*.js"
|
||||||
"${workspaceFolder}/dist/**/*.js"
|
]
|
||||||
],
|
|
||||||
"preLaunchTask": "tasks: watch-tests"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
26
type-script-helper/.vscode/settings.json
vendored
26
type-script-helper/.vscode/settings.json
vendored
@ -1,13 +1,23 @@
|
|||||||
// Place your settings in this file to overwrite default and user settings.
|
|
||||||
{
|
{
|
||||||
|
"[markdown]": {
|
||||||
|
"editor.wordWrap": "off"
|
||||||
|
},
|
||||||
|
"cSpell.words": [
|
||||||
|
"initialise",
|
||||||
|
"Kanban",
|
||||||
|
"VSIX"
|
||||||
|
],
|
||||||
|
"files.eol": "\n",
|
||||||
"files.exclude": {
|
"files.exclude": {
|
||||||
"out": false, // set this to true to hide the "out" folder with the compiled JS files
|
"**/dist": false,
|
||||||
"dist": false // set this to true to hide the "dist" folder with the compiled JS files
|
"**/node_modules": true,
|
||||||
|
"**/out": false
|
||||||
|
},
|
||||||
|
"files.watcherExclude": {
|
||||||
|
"**/node_modules": true
|
||||||
},
|
},
|
||||||
"search.exclude": {
|
"search.exclude": {
|
||||||
"out": true, // set this to false to include "out" folder in search results
|
"**/dist": true,
|
||||||
"dist": true // set this to false to include "dist" folder in search results
|
"**/out": true
|
||||||
},
|
}
|
||||||
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
|
|
||||||
"typescript.tsc.autoDetect": "off"
|
|
||||||
}
|
}
|
40
type-script-helper/.vscode/tasks.json
vendored
40
type-script-helper/.vscode/tasks.json
vendored
@ -1,40 +0,0 @@
|
|||||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
|
||||||
// for the documentation about the tasks.json format
|
|
||||||
{
|
|
||||||
"version": "2.0.0",
|
|
||||||
"tasks": [
|
|
||||||
{
|
|
||||||
"type": "npm",
|
|
||||||
"script": "watch",
|
|
||||||
"problemMatcher": "$ts-webpack-watch",
|
|
||||||
"isBackground": true,
|
|
||||||
"presentation": {
|
|
||||||
"reveal": "never",
|
|
||||||
"group": "watchers"
|
|
||||||
},
|
|
||||||
"group": {
|
|
||||||
"kind": "build",
|
|
||||||
"isDefault": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "npm",
|
|
||||||
"script": "watch-tests",
|
|
||||||
"problemMatcher": "$tsc-watch",
|
|
||||||
"isBackground": true,
|
|
||||||
"presentation": {
|
|
||||||
"reveal": "never",
|
|
||||||
"group": "watchers"
|
|
||||||
},
|
|
||||||
"group": "build"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "tasks: watch-tests",
|
|
||||||
"dependsOn": [
|
|
||||||
"npm: watch",
|
|
||||||
"npm: watch-tests"
|
|
||||||
],
|
|
||||||
"problemMatcher": []
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,13 +1,14 @@
|
|||||||
.vscode/**
|
|
||||||
.vscode-test/**
|
|
||||||
out/**
|
|
||||||
node_modules/**
|
|
||||||
src/**
|
|
||||||
.gitignore
|
.gitignore
|
||||||
|
.vscode-test/**
|
||||||
|
.vscode/**
|
||||||
.yarnrc
|
.yarnrc
|
||||||
webpack.config.js
|
|
||||||
vsc-extension-quickstart.md
|
|
||||||
**/tsconfig.json
|
|
||||||
**/.eslintrc.json
|
**/.eslintrc.json
|
||||||
**/*.map
|
**/*.map
|
||||||
**/*.ts
|
**/*.ts
|
||||||
|
**/tsconfig.json
|
||||||
|
build/**
|
||||||
|
node_modules/**
|
||||||
|
src/**
|
||||||
|
webviews/**
|
||||||
|
vsc-extension-quickstart.md
|
||||||
|
webpack.config.js
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
# Change Log
|
|
||||||
|
|
||||||
All notable changes to the "type-script-helper" extension will be documented in this file.
|
|
||||||
|
|
||||||
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
|
|
||||||
|
|
||||||
## [Unreleased]
|
|
||||||
|
|
||||||
- Initial release
|
|
@ -1,3 +1,11 @@
|
|||||||
|
---
|
||||||
|
type: "note"
|
||||||
|
created: "2022-03-10T21:18:17.054Z"
|
||||||
|
updated: "2022-03-10T21:18:17.054Z"
|
||||||
|
---
|
||||||
|
|
||||||
|
# LICENSE
|
||||||
|
|
||||||
Copyright (c) Twitter Inc
|
Copyright (c) Twitter Inc
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
---
|
||||||
|
type: "read-me"
|
||||||
|
created: "2023-09-30T01:47:18.241Z"
|
||||||
|
updated: "2023-09-30T01:47:18.242Z"
|
||||||
|
---
|
||||||
|
|
||||||
# type-script-helper README
|
# type-script-helper README
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
@ -16,7 +22,7 @@ yo code
|
|||||||
# ? What's the name of your extension? HelloWorld
|
# ? What's the name of your extension? HelloWorld
|
||||||
### Press <Enter> to choose default for all options below ###
|
### Press <Enter> to choose default for all options below ###
|
||||||
|
|
||||||
# ? What's the identifier of your extension? helloworld
|
# ? What's the identifier of your extension? hello-world
|
||||||
# ? What's the description of your extension? LEAVE BLANK
|
# ? What's the description of your extension? LEAVE BLANK
|
||||||
# ? Initialize a git repository? Yes
|
# ? Initialize a git repository? Yes
|
||||||
# ? Bundle the source code with webpack? No (should be yes?)
|
# ? Bundle the source code with webpack? No (should be yes?)
|
||||||
@ -108,4 +114,6 @@ None
|
|||||||
## 1.5.1
|
## 1.5.1
|
||||||
-----------------------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
- Webview
|
- columns-to-cards-webview-view-provider
|
||||||
|
- file-folder-helper-exe
|
||||||
|
- clickable list
|
||||||
|
@ -4,6 +4,28 @@
|
|||||||
"Other"
|
"Other"
|
||||||
],
|
],
|
||||||
"contributes": {
|
"contributes": {
|
||||||
|
"configuration": {
|
||||||
|
"type": "object",
|
||||||
|
"title": "Type Script Helper Configuration",
|
||||||
|
"properties": {
|
||||||
|
"fileTemplates.author": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
],
|
||||||
|
"default": null,
|
||||||
|
"description": "Value to use to replace #{author} variable."
|
||||||
|
},
|
||||||
|
"fileTemplates.company": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
],
|
||||||
|
"default": null,
|
||||||
|
"description": "Value to use to replace #{company} variable."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"commands": [
|
"commands": [
|
||||||
{
|
{
|
||||||
"category": "Helper",
|
"category": "Helper",
|
||||||
@ -37,24 +59,29 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "Kanban",
|
"category": "Kanban",
|
||||||
"command": "kanban.apiAuthenticate",
|
"command": "kanban.refreshBoth",
|
||||||
"title": "API Authenticate Kanban"
|
"title": "Refresh Kanban Both"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "Kanban",
|
"category": "Kanban",
|
||||||
"command": "kanban.newEntry",
|
"command": "kanban.refreshSidebar",
|
||||||
"title": "New Kanban Entry"
|
"title": "Refresh Kanban Sidebar"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "Kanban",
|
"category": "Kanban",
|
||||||
"command": "kanban.refresh",
|
"command": "kanban.refreshWebView",
|
||||||
"title": "Refresh Kanban"
|
"title": "Refresh Kanban WebView"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "Kanban",
|
"category": "Kanban",
|
||||||
"command": "kanban.debugReload",
|
"command": "kanban.debugReload",
|
||||||
"title": "Debug Reload Kanban"
|
"title": "Debug Reload Kanban"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"category": "Markdown",
|
||||||
|
"command": "markdown.newMarkdownFile",
|
||||||
|
"title": "New Markdown File"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"category": "Quick Fix",
|
"category": "Quick Fix",
|
||||||
"command": "replaceLinesHelper.quickFixCamelCaseProperties",
|
"command": "replaceLinesHelper.quickFixCamelCaseProperties",
|
||||||
@ -167,11 +194,11 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"views": {
|
"views": {
|
||||||
"kanban-sidebar-view": [
|
"columns-to-cards-webview-view-provider-view": [
|
||||||
{
|
{
|
||||||
"contextualTitle": "Kanban",
|
"contextualTitle": "Kanban",
|
||||||
"icon": "media/checklist.svg",
|
"icon": "media/checklist.svg",
|
||||||
"id": "kanban-sidebar",
|
"id": "columns-to-cards-webview-view-provider",
|
||||||
"name": "Kanban",
|
"name": "Kanban",
|
||||||
"type": "webview"
|
"type": "webview"
|
||||||
}
|
}
|
||||||
@ -181,7 +208,7 @@
|
|||||||
"activitybar": [
|
"activitybar": [
|
||||||
{
|
{
|
||||||
"icon": "media/checklist.svg",
|
"icon": "media/checklist.svg",
|
||||||
"id": "kanban-sidebar-view",
|
"id": "columns-to-cards-webview-view-provider-view",
|
||||||
"title": "Kanban"
|
"title": "Kanban"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -193,6 +220,7 @@
|
|||||||
},
|
},
|
||||||
"description": "Helper for VS Code in TypeScript",
|
"description": "Helper for VS Code in TypeScript",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@nodelib/fs.stat": "^3.0.0",
|
||||||
"@rollup/plugin-commonjs": "^25.0.4",
|
"@rollup/plugin-commonjs": "^25.0.4",
|
||||||
"@rollup/plugin-node-resolve": "^15.2.1",
|
"@rollup/plugin-node-resolve": "^15.2.1",
|
||||||
"@rollup/plugin-typescript": "^11.1.4",
|
"@rollup/plugin-typescript": "^11.1.4",
|
||||||
@ -229,16 +257,8 @@
|
|||||||
"publisher": "IFX",
|
"publisher": "IFX",
|
||||||
"repository": "https://github.com/mikepharesjr/YO-VSCode/tree/master/type-script-helper",
|
"repository": "https://github.com/mikepharesjr/YO-VSCode/tree/master/type-script-helper",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"compile": "webpack --config ./build/node-extension.webpack.config.js",
|
"vscode:publish": "node node_modules/@vscode/vsce/vsce package",
|
||||||
"lint": "eslint src --ext ts",
|
|
||||||
"package": "webpack --mode production --devtool hidden-source-map --config ./build/node-extension.webpack.config.js",
|
|
||||||
"pretest": "npm run test-compile && npm run lint",
|
|
||||||
"rollup:compile": "rollup -c && webpack --mode production",
|
|
||||||
"test": "node ./out/test/runTest.js",
|
|
||||||
"test-compile": "tsc -p ./",
|
|
||||||
"test-watch": "tsc -watch -p ./",
|
|
||||||
"vscode:prepublish": "npm run package",
|
|
||||||
"watch": "concurrently \"rollup -c -w\" \"webpack --watch --config ./build/node-extension.webpack.config.js\""
|
"watch": "concurrently \"rollup -c -w\" \"webpack --watch --config ./build/node-extension.webpack.config.js\""
|
||||||
},
|
},
|
||||||
"version": "1.5.1"
|
"version": "1.5.2"
|
||||||
}
|
}
|
22
type-script-helper/src/Card.ts
Normal file
22
type-script-helper/src/Card.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import { H2HexColor } from "./H2HexColor";
|
||||||
|
import { LineNumber } from "./LineNumber";
|
||||||
|
import { H2NoCheckboxes } from "./H2NoCheckboxes";
|
||||||
|
import { H2WithCheckboxes } from "./H2WithCheckboxes";
|
||||||
|
|
||||||
|
export type Card = {
|
||||||
|
Assignees: Array<string>;
|
||||||
|
CreationDateTime: Date;
|
||||||
|
Directory: string;
|
||||||
|
Extension: string;
|
||||||
|
File: string;
|
||||||
|
FileName: string;
|
||||||
|
FileNameWithoutExtension: string;
|
||||||
|
H1: string;
|
||||||
|
H2HexColorCollection: Array<H2HexColor>;
|
||||||
|
H2NoCheckboxesCollection: Array<H2NoCheckboxes>;
|
||||||
|
H2WithCheckboxesCollection: Array<H2WithCheckboxes>;
|
||||||
|
LastWriteDateTime: Date;
|
||||||
|
LineNumber: LineNumber;
|
||||||
|
RequestedDateTime: string;
|
||||||
|
Type: string;
|
||||||
|
};
|
188
type-script-helper/src/ColumnsToCardsWebviewViewProvider.ts
Normal file
188
type-script-helper/src/ColumnsToCardsWebviewViewProvider.ts
Normal file
@ -0,0 +1,188 @@
|
|||||||
|
import { Card } from "./Card";
|
||||||
|
import { readFile } from "fs";
|
||||||
|
import * as vscode from "vscode";
|
||||||
|
import { getNonce } from "./getNonce";
|
||||||
|
import { PostMessage } from "./PostMessage";
|
||||||
|
import { apiBaseUrl, key } from "./constants";
|
||||||
|
import { ExecException, exec } from 'child_process';
|
||||||
|
|
||||||
|
export function refreshSidebarLogic(): undefined {
|
||||||
|
vscode.commands.executeCommand("workbench.action.closeSidebar").then(_ => {
|
||||||
|
vscode.commands.executeCommand("workbench.view.extension.columns-to-cards-sidebar-view");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function columnsToCardsRead(webviewView: vscode.WebviewView, columnsToCardsUri: vscode.Uri, err: NodeJS.ErrnoException | null, data: string | Buffer) {
|
||||||
|
if (err)
|
||||||
|
vscode.window.showInformationMessage(`<${columnsToCardsUri.fsPath}> doesn't exist! ${err.message}`);
|
||||||
|
const columnsToCards: Record<string, Array<Card>> = {};
|
||||||
|
const jsonObject: any = JSON.parse(data.toString('utf8'));
|
||||||
|
for (const property in jsonObject) {
|
||||||
|
columnsToCards[property] = jsonObject[property];
|
||||||
|
}
|
||||||
|
const postMessage: PostMessage = { type: "columns-to-cards", value: columnsToCards };
|
||||||
|
webviewView.webview.postMessage(postMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
function execCallback(webviewView: vscode.WebviewView, destination: vscode.Uri, error: ExecException | null, stdout: string, stderr: string) {
|
||||||
|
if (error) {
|
||||||
|
vscode.window.showInformationMessage(error.message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (stderr) {
|
||||||
|
vscode.window.showInformationMessage(stderr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log(`stdout: ${stdout}`);
|
||||||
|
const columnsToCards = vscode.Uri.joinPath(destination, "columnsToCards.json");
|
||||||
|
readFile(columnsToCards.fsPath, (err, data) =>
|
||||||
|
columnsToCardsRead(webviewView, columnsToCards, err, data));
|
||||||
|
};
|
||||||
|
|
||||||
|
async function postColumnsToCards(extensionUri: vscode.Uri, webviewView: vscode.WebviewView) {
|
||||||
|
if (vscode.workspace.workspaceFolders === undefined)
|
||||||
|
vscode.window.showInformationMessage("Open workspace first!");
|
||||||
|
else {
|
||||||
|
const workspaceFoldersZero = vscode.workspace.workspaceFolders[0].uri;
|
||||||
|
const destination: vscode.Uri = vscode.Uri.joinPath(workspaceFoldersZero, ".vscode", "helper");
|
||||||
|
const fileFolderHelper: vscode.Uri = vscode.Uri.joinPath(extensionUri, "net7.0", "win-x64", "publish", "File-Folder-Helper.exe");
|
||||||
|
const command: string = `${fileFolderHelper.fsPath} s M ${workspaceFoldersZero.fsPath} -s ${workspaceFoldersZero.fsPath} -d ${destination.fsPath}`;
|
||||||
|
exec(command, (error, stdout, stderr) =>
|
||||||
|
execCallback(webviewView, destination, error, stdout, stderr));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getToken(workspaceState: vscode.Memento, webviewView: vscode.WebviewView) {
|
||||||
|
webviewView.webview.postMessage({
|
||||||
|
type: "token",
|
||||||
|
value: workspaceState.get(key),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function authenticate(workspaceState: vscode.Memento, webviewView: vscode.WebviewView) {
|
||||||
|
webviewView.webview.postMessage({
|
||||||
|
type: "token",
|
||||||
|
value: workspaceState.get(key),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function logout(workspaceState: vscode.Memento) {
|
||||||
|
workspaceState.update(key, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
async function openCard(value: any) {
|
||||||
|
if (vscode.workspace.workspaceFolders === undefined)
|
||||||
|
vscode.window.showInformationMessage("Open workspace first!");
|
||||||
|
else {
|
||||||
|
if (!value.File)
|
||||||
|
vscode.window.showInformationMessage("File wasn't passed!");
|
||||||
|
else {
|
||||||
|
const textDocument: vscode.TextDocument = await vscode.workspace.openTextDocument(value.File);
|
||||||
|
vscode.window.showTextDocument(textDocument);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ColumnsToCardsWebviewViewProvider implements vscode.WebviewViewProvider {
|
||||||
|
_view?: vscode.WebviewView;
|
||||||
|
|
||||||
|
constructor(private readonly _extensionContext: vscode.ExtensionContext) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public revive(panel: vscode.WebviewView) {
|
||||||
|
this._view = panel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public resolveWebviewView(webviewView: vscode.WebviewView) {
|
||||||
|
this._view = webviewView;
|
||||||
|
|
||||||
|
webviewView.webview.options = {
|
||||||
|
// Allow scripts in the webview
|
||||||
|
enableScripts: true,
|
||||||
|
|
||||||
|
localResourceRoots: [this._extensionContext.extensionUri],
|
||||||
|
};
|
||||||
|
|
||||||
|
webviewView.webview.html = this._getHtmlForWebview(webviewView.webview);
|
||||||
|
|
||||||
|
webviewView.webview.onDidReceiveMessage(async (postMessage: PostMessage) => {
|
||||||
|
switch (postMessage.type) {
|
||||||
|
case "logout":
|
||||||
|
logout(this._extensionContext.workspaceState);
|
||||||
|
break;
|
||||||
|
case "authenticate":
|
||||||
|
authenticate(this._extensionContext.workspaceState, webviewView);
|
||||||
|
break;
|
||||||
|
case "get-token":
|
||||||
|
getToken(this._extensionContext.workspaceState, webviewView);
|
||||||
|
break;
|
||||||
|
case "get-columns-to-cards":
|
||||||
|
postColumnsToCards(this._extensionContext.extensionUri, webviewView);
|
||||||
|
break;
|
||||||
|
case "open-card":
|
||||||
|
openCard(postMessage.value);
|
||||||
|
break;
|
||||||
|
case "on-info":
|
||||||
|
if (!postMessage.value)
|
||||||
|
return;
|
||||||
|
vscode.window.showInformationMessage(postMessage.value);
|
||||||
|
break;
|
||||||
|
case "on-error":
|
||||||
|
if (!postMessage.value)
|
||||||
|
return;
|
||||||
|
vscode.window.showErrorMessage(postMessage.value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
vscode.window.showErrorMessage(postMessage.type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private _getHtmlForWebview(webview: vscode.Webview) {
|
||||||
|
const styleResetUri = webview.asWebviewUri(
|
||||||
|
vscode.Uri.joinPath(this._extensionContext.extensionUri, "media", "reset.css")
|
||||||
|
);
|
||||||
|
const styleVSCodeUri = webview.asWebviewUri(
|
||||||
|
vscode.Uri.joinPath(this._extensionContext.extensionUri, "media", "vscode.css")
|
||||||
|
);
|
||||||
|
|
||||||
|
const scriptUri = webview.asWebviewUri(
|
||||||
|
vscode.Uri.joinPath(this._extensionContext.extensionUri, "out", "compiled/ColumnsToCards.js")
|
||||||
|
);
|
||||||
|
const styleMainUri = webview.asWebviewUri(
|
||||||
|
vscode.Uri.joinPath(this._extensionContext.extensionUri, "out", "compiled/ColumnsToCards.css")
|
||||||
|
);
|
||||||
|
|
||||||
|
// Use a nonce to only allow a specific script to be run.
|
||||||
|
const nonce = getNonce();
|
||||||
|
|
||||||
|
return `<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<!--
|
||||||
|
Use a content security policy to only allow loading images from https or from our extension directory,
|
||||||
|
and only allow scripts that have a specific nonce.
|
||||||
|
-->
|
||||||
|
<meta http-equiv="Content-Security-Policy"
|
||||||
|
content="img-src https: data:;
|
||||||
|
style-src 'unsafe-inline' ${webview.cspSource};
|
||||||
|
script-src 'nonce-${nonce}';">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link href="${styleResetUri}" rel="stylesheet">
|
||||||
|
<link href="${styleVSCodeUri}" rel="stylesheet">
|
||||||
|
<link href="${styleMainUri}" rel="stylesheet">
|
||||||
|
<script nonce="${nonce}">
|
||||||
|
const acquiredVsCodeApi = acquireVsCodeApi();
|
||||||
|
const apiBaseUrl = ${JSON.stringify(apiBaseUrl)}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script nonce="${nonce}" src="${scriptUri}"></script>
|
||||||
|
</body>
|
||||||
|
</html>`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const refreshSidebar = () => refreshSidebarLogic();
|
4
type-script-helper/src/H2HexColor.ts
Normal file
4
type-script-helper/src/H2HexColor.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export type H2HexColor = {
|
||||||
|
H2: string;
|
||||||
|
HexColor: string;
|
||||||
|
};
|
5
type-script-helper/src/H2NoCheckboxes.ts
Normal file
5
type-script-helper/src/H2NoCheckboxes.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
export type H2NoCheckboxes = {
|
||||||
|
H2: string;
|
||||||
|
Lines: Array<string>;
|
||||||
|
};
|
7
type-script-helper/src/H2WithCheckboxes.ts
Normal file
7
type-script-helper/src/H2WithCheckboxes.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
export type H2WithCheckboxes = {
|
||||||
|
Completed: number;
|
||||||
|
H2: string;
|
||||||
|
NotCompleted: number;
|
||||||
|
Total: number;
|
||||||
|
};
|
9
type-script-helper/src/LineNumber.ts
Normal file
9
type-script-helper/src/LineNumber.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
export type LineNumber = {
|
||||||
|
Created: number;
|
||||||
|
H1: number;
|
||||||
|
FrontMatterYamlEnd: number;
|
||||||
|
Status: number;
|
||||||
|
Type: number;
|
||||||
|
Updated: number;
|
||||||
|
};
|
5
type-script-helper/src/PostMessage.ts
Normal file
5
type-script-helper/src/PostMessage.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
export type PostMessage = {
|
||||||
|
type: string;
|
||||||
|
value: any;
|
||||||
|
};
|
@ -1,115 +0,0 @@
|
|||||||
import * as vscode from "vscode";
|
|
||||||
// import { authenticate } from "./authenticate";
|
|
||||||
import { apiBaseUrl } from "./constants";
|
|
||||||
import { key } from "./constants";
|
|
||||||
import { getNonce } from "./getNonce";
|
|
||||||
|
|
||||||
export class SidebarProvider implements vscode.WebviewViewProvider {
|
|
||||||
_view?: vscode.WebviewView;
|
|
||||||
_doc?: vscode.TextDocument;
|
|
||||||
|
|
||||||
constructor(private readonly _extensionContext: vscode.ExtensionContext) { }
|
|
||||||
|
|
||||||
public resolveWebviewView(webviewView: vscode.WebviewView) {
|
|
||||||
this._view = webviewView;
|
|
||||||
|
|
||||||
webviewView.webview.options = {
|
|
||||||
// Allow scripts in the webview
|
|
||||||
enableScripts: true,
|
|
||||||
|
|
||||||
localResourceRoots: [this._extensionContext.extensionUri],
|
|
||||||
};
|
|
||||||
|
|
||||||
webviewView.webview.html = this._getHtmlForWebview(webviewView.webview);
|
|
||||||
|
|
||||||
webviewView.webview.onDidReceiveMessage(async (data) => {
|
|
||||||
switch (data.type) {
|
|
||||||
case "logout": {
|
|
||||||
this._extensionContext.workspaceState.update(key, "");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "authenticate": {
|
|
||||||
// authenticate(this._extensionContext, () => {
|
|
||||||
// webviewView.webview.postMessage({
|
|
||||||
// type: "token",
|
|
||||||
// value: this._extensionContext.workspaceState.get(key),
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
webviewView.webview.postMessage({
|
|
||||||
type: "token",
|
|
||||||
value: this._extensionContext.workspaceState.get(key),
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "get-token": {
|
|
||||||
webviewView.webview.postMessage({
|
|
||||||
type: "token",
|
|
||||||
value: this._extensionContext.workspaceState.get(key),
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "onInfo": {
|
|
||||||
if (!data.value) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
vscode.window.showInformationMessage(data.value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "onError": {
|
|
||||||
if (!data.value) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
vscode.window.showErrorMessage(data.value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public revive(panel: vscode.WebviewView) {
|
|
||||||
this._view = panel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private _getHtmlForWebview(webview: vscode.Webview) {
|
|
||||||
const styleResetUri = webview.asWebviewUri(
|
|
||||||
vscode.Uri.joinPath(this._extensionContext.extensionUri, "media", "reset.css")
|
|
||||||
);
|
|
||||||
const styleVSCodeUri = webview.asWebviewUri(
|
|
||||||
vscode.Uri.joinPath(this._extensionContext.extensionUri, "media", "vscode.css")
|
|
||||||
);
|
|
||||||
|
|
||||||
const scriptUri = webview.asWebviewUri(
|
|
||||||
vscode.Uri.joinPath(this._extensionContext.extensionUri, "out", "compiled/sidebar.js")
|
|
||||||
);
|
|
||||||
const styleMainUri = webview.asWebviewUri(
|
|
||||||
vscode.Uri.joinPath(this._extensionContext.extensionUri, "out", "compiled/sidebar.css")
|
|
||||||
);
|
|
||||||
|
|
||||||
// Use a nonce to only allow a specific script to be run.
|
|
||||||
const nonce = getNonce();
|
|
||||||
|
|
||||||
return `<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<!--
|
|
||||||
Use a content security policy to only allow loading images from https or from our extension directory,
|
|
||||||
and only allow scripts that have a specific nonce.
|
|
||||||
-->
|
|
||||||
<meta http-equiv="Content-Security-Policy" content="img-src https: data:; style-src 'unsafe-inline' ${webview.cspSource
|
|
||||||
}; script-src 'nonce-${nonce}';">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<link href="${styleResetUri}" rel="stylesheet">
|
|
||||||
<link href="${styleVSCodeUri}" rel="stylesheet">
|
|
||||||
<link href="${styleMainUri}" rel="stylesheet">
|
|
||||||
<script nonce="${nonce}">
|
|
||||||
const acquiredVsCodeApi = acquireVsCodeApi();
|
|
||||||
const apiBaseUrl = ${JSON.stringify(apiBaseUrl)}
|
|
||||||
</script>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<script nonce="${nonce}" src="${scriptUri}"></script>
|
|
||||||
</body>
|
|
||||||
</html>`;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +1,12 @@
|
|||||||
import * as vscode from "vscode";
|
import * as vscode from "vscode";
|
||||||
import { getNonce } from "./getNonce";
|
import { getNonce } from "./getNonce";
|
||||||
|
import { apiBaseUrl } from "./constants";
|
||||||
|
import { PostMessage } from "./PostMessage";
|
||||||
|
|
||||||
|
export function refreshWebView(extensionContext: vscode.ExtensionContext): undefined {
|
||||||
|
WebViewPanel.kill();
|
||||||
|
WebViewPanel.createOrShow(extensionContext);
|
||||||
|
}
|
||||||
|
|
||||||
export class WebViewPanel {
|
export class WebViewPanel {
|
||||||
/**
|
/**
|
||||||
@ -9,11 +16,9 @@ export class WebViewPanel {
|
|||||||
|
|
||||||
public static readonly viewType = "web-view-panel";
|
public static readonly viewType = "web-view-panel";
|
||||||
|
|
||||||
private readonly _panel: vscode.WebviewPanel;
|
|
||||||
private readonly _extensionUri: vscode.Uri;
|
|
||||||
private _disposables: vscode.Disposable[] = [];
|
private _disposables: vscode.Disposable[] = [];
|
||||||
|
|
||||||
public static createOrShow(extensionUri: vscode.Uri) {
|
public static createOrShow(extensionContext: vscode.ExtensionContext) {
|
||||||
const column = vscode.window.activeTextEditor
|
const column = vscode.window.activeTextEditor
|
||||||
? vscode.window.activeTextEditor.viewColumn
|
? vscode.window.activeTextEditor.viewColumn
|
||||||
: undefined;
|
: undefined;
|
||||||
@ -36,13 +41,13 @@ export class WebViewPanel {
|
|||||||
|
|
||||||
// And restrict the webview to only loading content from our extension's `media` directory.
|
// And restrict the webview to only loading content from our extension's `media` directory.
|
||||||
localResourceRoots: [
|
localResourceRoots: [
|
||||||
vscode.Uri.joinPath(extensionUri, "media"),
|
vscode.Uri.joinPath(extensionContext.extensionUri, "media"),
|
||||||
vscode.Uri.joinPath(extensionUri, "out/compiled"),
|
vscode.Uri.joinPath(extensionContext.extensionUri, "out/compiled"),
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
WebViewPanel.currentPanel = new WebViewPanel(panel, extensionUri);
|
WebViewPanel.currentPanel = new WebViewPanel(panel, extensionContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static kill() {
|
public static kill() {
|
||||||
@ -50,13 +55,11 @@ export class WebViewPanel {
|
|||||||
WebViewPanel.currentPanel = undefined;
|
WebViewPanel.currentPanel = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static revive(panel: vscode.WebviewPanel, extensionUri: vscode.Uri) {
|
public static revive(panel: vscode.WebviewPanel, extensionContext: vscode.ExtensionContext) {
|
||||||
WebViewPanel.currentPanel = new WebViewPanel(panel, extensionUri);
|
WebViewPanel.currentPanel = new WebViewPanel(panel, extensionContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
private constructor(panel: vscode.WebviewPanel, extensionUri: vscode.Uri) {
|
private constructor(private readonly _panel: vscode.WebviewPanel, private readonly _extensionContext: vscode.ExtensionContext) {
|
||||||
this._panel = panel;
|
|
||||||
this._extensionUri = extensionUri;
|
|
||||||
|
|
||||||
// Set the webview's initial html content
|
// Set the webview's initial html content
|
||||||
this._update();
|
this._update();
|
||||||
@ -97,49 +100,41 @@ export class WebViewPanel {
|
|||||||
const webview = this._panel.webview;
|
const webview = this._panel.webview;
|
||||||
|
|
||||||
this._panel.webview.html = this._getHtmlForWebview(webview);
|
this._panel.webview.html = this._getHtmlForWebview(webview);
|
||||||
webview.onDidReceiveMessage(async (data) => {
|
webview.onDidReceiveMessage(async (postMessage: PostMessage) => {
|
||||||
switch (data.type) {
|
switch (postMessage.type) {
|
||||||
case "onInfo": {
|
case "on-info":
|
||||||
if (!data.value) {
|
if (!postMessage.value)
|
||||||
return;
|
return;
|
||||||
}
|
vscode.window.showInformationMessage(postMessage.value);
|
||||||
vscode.window.showInformationMessage(data.value);
|
|
||||||
break;
|
break;
|
||||||
}
|
case "on-error":
|
||||||
case "onError": {
|
if (!postMessage.value)
|
||||||
if (!data.value) {
|
|
||||||
return;
|
return;
|
||||||
}
|
vscode.window.showErrorMessage(postMessage.value);
|
||||||
vscode.window.showErrorMessage(data.value);
|
break;
|
||||||
|
default:
|
||||||
|
vscode.window.showErrorMessage(postMessage.type);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
// case "tokens": {
|
|
||||||
// await Util.globalState.update(accessTokenKey, data.accessToken);
|
|
||||||
// await Util.globalState.update(refreshTokenKey, data.refreshToken);
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private _getHtmlForWebview(webview: vscode.Webview) {
|
private _getHtmlForWebview(webview: vscode.Webview) {
|
||||||
// // And the uri we use to load this script in the webview
|
const styleResetUri = webview.asWebviewUri(
|
||||||
|
vscode.Uri.joinPath(this._extensionContext.extensionUri, "media", "reset.css")
|
||||||
|
);
|
||||||
|
const styleVSCodeUri = webview.asWebviewUri(
|
||||||
|
vscode.Uri.joinPath(this._extensionContext.extensionUri, "media", "vscode.css")
|
||||||
|
);
|
||||||
|
|
||||||
const scriptUri = webview.asWebviewUri(
|
const scriptUri = webview.asWebviewUri(
|
||||||
vscode.Uri.joinPath(this._extensionUri, "out/compiled", "WebView.js")
|
vscode.Uri.joinPath(this._extensionContext.extensionUri, "out", "compiled/DisplayDate.js")
|
||||||
|
);
|
||||||
|
const styleMainUri = webview.asWebviewUri(
|
||||||
|
vscode.Uri.joinPath(this._extensionContext.extensionUri, "out", "compiled/DisplayDate.css")
|
||||||
);
|
);
|
||||||
|
|
||||||
// Uri to load styles into webview
|
// Use a nonce to only allow a specific script to be run.
|
||||||
const stylesResetUri = webview.asWebviewUri(
|
|
||||||
vscode.Uri.joinPath(this._extensionUri, "media", "reset.css")
|
|
||||||
);
|
|
||||||
const stylesMainUri = webview.asWebviewUri(
|
|
||||||
vscode.Uri.joinPath(this._extensionUri, "media", "vscode.css")
|
|
||||||
);
|
|
||||||
// const cssUri = webview.asWebviewUri(
|
|
||||||
// vscode.Uri.joinPath(this._extensionUri, "out", "compiled/swiper.css")
|
|
||||||
// );
|
|
||||||
|
|
||||||
// // Use a nonce to only allow specific scripts to be run
|
|
||||||
const nonce = getNonce();
|
const nonce = getNonce();
|
||||||
|
|
||||||
return `<!DOCTYPE html>
|
return `<!DOCTYPE html>
|
||||||
@ -150,16 +145,22 @@ export class WebViewPanel {
|
|||||||
Use a content security policy to only allow loading images from https or from our extension directory,
|
Use a content security policy to only allow loading images from https or from our extension directory,
|
||||||
and only allow scripts that have a specific nonce.
|
and only allow scripts that have a specific nonce.
|
||||||
-->
|
-->
|
||||||
<meta http-equiv="Content-Security-Policy" content="img-src https: data:; style-src 'unsafe-inline' ${webview.cspSource}; script-src 'nonce-${nonce}';">
|
<meta http-equiv="Content-Security-Policy"
|
||||||
|
content="img-src https: data:;
|
||||||
|
style-src 'unsafe-inline' ${webview.cspSource};
|
||||||
|
script-src 'nonce-${nonce}';">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<link href="${stylesResetUri}" rel="stylesheet">
|
<link href="${styleResetUri}" rel="stylesheet">
|
||||||
<link href="${stylesMainUri}" rel="stylesheet">
|
<link href="${styleVSCodeUri}" rel="stylesheet">
|
||||||
|
<link href="${styleMainUri}" rel="stylesheet">
|
||||||
<script nonce="${nonce}">
|
<script nonce="${nonce}">
|
||||||
|
const acquiredVsCodeApi = acquireVsCodeApi();
|
||||||
|
const apiBaseUrl = ${JSON.stringify(apiBaseUrl)}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<script nonce="${nonce}" src="${scriptUri}"></script>
|
||||||
</body>
|
</body>
|
||||||
<script src="${scriptUri}" nonce="${nonce}">
|
|
||||||
</html>`;
|
</html>`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
// import * as vscode from "vscode";
|
|
||||||
// import { apiBaseUrl } from "./constants";
|
|
||||||
// import { key } from "./constants";
|
|
||||||
// import * as polka from "polka";
|
|
||||||
|
|
||||||
// export const authenticate = (extensionContext: vscode.ExtensionContext, fn: () => void) => {
|
|
||||||
// const app = polka();
|
|
||||||
|
|
||||||
// app.get(`/auth/:token`, async (req, res) => {
|
|
||||||
// const { token } = req.params;
|
|
||||||
// if (!token) {
|
|
||||||
// res.end(`<h1>something went wrong</h1>`);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// await extensionContext.workspaceState.update(key, token);
|
|
||||||
// fn();
|
|
||||||
|
|
||||||
// res.end(`<h1>auth was successful, you can close this now</h1>`);
|
|
||||||
|
|
||||||
// (app as any).server.close();
|
|
||||||
// });
|
|
||||||
|
|
||||||
// app.listen(54321, (err: Error) => {
|
|
||||||
// if (err) {
|
|
||||||
// vscode.window.showErrorMessage(err.message);
|
|
||||||
// } else {
|
|
||||||
// vscode.commands.executeCommand(
|
|
||||||
// "vscode.open",
|
|
||||||
// vscode.Uri.parse(`${apiBaseUrl}/auth/github`)
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// };
|
|
@ -1,2 +1,2 @@
|
|||||||
export const key = "type-script-helper";
|
export const apiBaseUrl: string = "http://localhost:3002";
|
||||||
export const apiBaseUrl = "http://localhost:3002";
|
export const key: string = "type-script-helper";
|
||||||
|
@ -2,24 +2,24 @@
|
|||||||
// Import the module and reference it with the alias vscode in your code below
|
// Import the module and reference it with the alias vscode in your code below
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as kanbanHelper from './kanbanHelper';
|
import * as kanbanHelper from './kanbanHelper';
|
||||||
|
import * as markdownHelper from './markdownHelper';
|
||||||
|
import * as promiseLinesHelper from './promiseLinesHelper';
|
||||||
import * as replaceLinesHelper from './replaceLinesHelper';
|
import * as replaceLinesHelper from './replaceLinesHelper';
|
||||||
import * as readOnlyLinesHelper from './readOnlyLinesHelper';
|
import * as readOnlyLinesHelper from './readOnlyLinesHelper';
|
||||||
import * as promiseLinesHelper from './promiseLinesHelper';
|
import { WebViewPanel, refreshWebView } from "./WebViewPanel";
|
||||||
import { SidebarProvider } from "./SidebarProvider";
|
import { ColumnsToCardsWebviewViewProvider, refreshSidebar } from "./ColumnsToCardsWebviewViewProvider";
|
||||||
import { WebViewPanel } from "./WebViewPanel";
|
|
||||||
|
|
||||||
// This method is called when your extension is activated
|
// This method is called when your extension is activated
|
||||||
// Your extension is activated the very first time the command is executed
|
// Your extension is activated the very first time the command is executed
|
||||||
export async function activate(extensionContext: vscode.ExtensionContext) {
|
export async function activate(extensionContext: vscode.ExtensionContext) {
|
||||||
|
|
||||||
const sidebarProvider = new SidebarProvider(extensionContext);
|
const columnsToCardsWebviewViewProvider = new ColumnsToCardsWebviewViewProvider(extensionContext);
|
||||||
|
|
||||||
const item = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right);
|
const item = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right);
|
||||||
item.text = "$(beaker) Show Kanban";
|
item.text = "$(beaker) Show Kanban";
|
||||||
// item.command = "kanban.show";
|
// item.command = "kanban.show";
|
||||||
item.show();
|
item.show();
|
||||||
|
extensionContext.subscriptions.push(vscode.window.registerWebviewViewProvider("columns-to-cards-webview-view-provider", columnsToCardsWebviewViewProvider));
|
||||||
extensionContext.subscriptions.push(vscode.window.registerWebviewViewProvider("kanban-sidebar", sidebarProvider));
|
|
||||||
|
|
||||||
// Use the console to output diagnostic information (console.log) and errors (console.error)
|
// Use the console to output diagnostic information (console.log) and errors (console.error)
|
||||||
// This line of code will only be executed once when your extension is activated
|
// This line of code will only be executed once when your extension is activated
|
||||||
@ -37,10 +37,10 @@ export async function activate(extensionContext: vscode.ExtensionContext) {
|
|||||||
// context.subscriptions.push(disposable);
|
// context.subscriptions.push(disposable);
|
||||||
|
|
||||||
const commands = [
|
const commands = [
|
||||||
// vscode.commands.registerCommand("kanban.apiAuthenticate", kanbanHelper.apiAuthenticate(extensionContext)),
|
vscode.commands.registerCommand("kanban.refreshBoth", () => { kanbanHelper.refreshBoth(extensionContext); }),
|
||||||
vscode.commands.registerCommand("kanban.newEntry", kanbanHelper.newEntry(sidebarProvider)),
|
vscode.commands.registerCommand("kanban.refreshSidebar", refreshSidebar),
|
||||||
vscode.commands.registerCommand("kanban.refresh", await kanbanHelper.refresh()),
|
vscode.commands.registerCommand("kanban.refreshWebView", () => { refreshWebView(extensionContext); }),
|
||||||
// vscode.commands.registerCommand("kanban.debugReload", await kanbanHelper.debugReload(extensionContext)),
|
vscode.commands.registerCommand("markdown.newMarkdownFile", markdownHelper.newMarkdownFile),
|
||||||
vscode.commands.registerCommand('promiseLinesHelper.codeGeneratorQuickPick', promiseLinesHelper.codeGeneratorQuickPick),
|
vscode.commands.registerCommand('promiseLinesHelper.codeGeneratorQuickPick', promiseLinesHelper.codeGeneratorQuickPick),
|
||||||
vscode.commands.registerCommand('promiseLinesHelper.insertDateTime', promiseLinesHelper.insertDateTime),
|
vscode.commands.registerCommand('promiseLinesHelper.insertDateTime', promiseLinesHelper.insertDateTime),
|
||||||
vscode.commands.registerCommand('promiseLinesHelper.transformToPopperCase', promiseLinesHelper.transformToPopperCase),
|
vscode.commands.registerCommand('promiseLinesHelper.transformToPopperCase', promiseLinesHelper.transformToPopperCase),
|
||||||
@ -67,7 +67,7 @@ export async function activate(extensionContext: vscode.ExtensionContext) {
|
|||||||
vscode.commands.registerCommand('replaceLinesHelper.unwrapSql', replaceLinesHelper.unwrapSql),
|
vscode.commands.registerCommand('replaceLinesHelper.unwrapSql', replaceLinesHelper.unwrapSql),
|
||||||
vscode.commands.registerCommand('replaceLinesHelper.wrapSqlCSharp', replaceLinesHelper.wrapSqlCSharp),
|
vscode.commands.registerCommand('replaceLinesHelper.wrapSqlCSharp', replaceLinesHelper.wrapSqlCSharp),
|
||||||
vscode.commands.registerCommand('replaceLinesHelper.wrapSqlVB', replaceLinesHelper.wrapSqlVB),
|
vscode.commands.registerCommand('replaceLinesHelper.wrapSqlVB', replaceLinesHelper.wrapSqlVB),
|
||||||
vscode.commands.registerCommand("webView.webView", () => { WebViewPanel.createOrShow(extensionContext.extensionUri); })
|
vscode.commands.registerCommand("webView.webView", () => { WebViewPanel.createOrShow(extensionContext); })
|
||||||
];
|
];
|
||||||
|
|
||||||
commands.forEach(command => extensionContext.subscriptions.push(command));
|
commands.forEach(command => extensionContext.subscriptions.push(command));
|
||||||
|
@ -1,40 +1,9 @@
|
|||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
// import { authenticate } from "./authenticate";
|
import { refreshWebView } from './WebViewPanel';
|
||||||
import { SidebarProvider } from './SidebarProvider';
|
import { refreshSidebar } from './ColumnsToCardsWebviewViewProvider';
|
||||||
// import { WebViewPanel } from "./WebViewPanel";
|
|
||||||
|
|
||||||
export function newEntry(sidebarProvider: SidebarProvider): any {
|
export function refreshBoth(extensionContext: vscode.ExtensionContext): undefined {
|
||||||
const { activeTextEditor } = vscode.window;
|
refreshSidebar();
|
||||||
if (!activeTextEditor) {
|
refreshWebView(extensionContext);
|
||||||
vscode.window.showInformationMessage("No active text editor");
|
setTimeout(() => { vscode.commands.executeCommand("workbench.action.webview.openDeveloperTools"); }, 500);
|
||||||
return;
|
|
||||||
}
|
|
||||||
const text = activeTextEditor.document.getText(
|
|
||||||
activeTextEditor.selection
|
|
||||||
);
|
|
||||||
sidebarProvider._view?.webview.postMessage({
|
|
||||||
type: "new-entry",
|
|
||||||
value: text,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// export function apiAuthenticate(extensionContext: vscode.ExtensionContext): any {
|
|
||||||
// try {
|
|
||||||
// authenticate(extensionContext, () => { });
|
|
||||||
// } catch (err) {
|
|
||||||
// console.log(err);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
export async function refresh(): Promise<any> {
|
|
||||||
await vscode.commands.executeCommand("workbench.action.closeSidebar");
|
|
||||||
await vscode.commands.executeCommand("workbench.view.extension.kanban-sidebar-view");
|
|
||||||
}
|
|
||||||
|
|
||||||
// export async function debugReload(extensionContext: vscode.ExtensionContext): Promise<any> {
|
|
||||||
// WebViewPanel.kill();
|
|
||||||
// WebViewPanel.createOrShow(extensionContext.extensionUri);
|
|
||||||
// await vscode.commands.executeCommand("workbench.action.closeSidebar");
|
|
||||||
// await vscode.commands.executeCommand("workbench.view.extension.kanban-sidebar-view");
|
|
||||||
// setTimeout(() => { vscode.commands.executeCommand("workbench.action.webview.openDeveloperTools"); }, 500);
|
|
||||||
// }
|
|
||||||
|
21
type-script-helper/src/markdownHelper.ts
Normal file
21
type-script-helper/src/markdownHelper.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import * as vscode from 'vscode';
|
||||||
|
import { paramCase } from './promiseLinesHelper';
|
||||||
|
|
||||||
|
async function newMarkdownFileLogic(): Promise<undefined> {
|
||||||
|
if (vscode.workspace.workspaceFolders === undefined) {
|
||||||
|
vscode.window.showInformationMessage("Open workspace first!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const workspaceFoldersZero = vscode.workspace.workspaceFolders[0].uri;
|
||||||
|
const cardTitle = await vscode.window.showInputBox({ prompt: 'Provide title for card.' });
|
||||||
|
if (cardTitle === undefined)
|
||||||
|
return;
|
||||||
|
const paramCaseCardTitle: string = paramCase(cardTitle);
|
||||||
|
const fileUri: vscode.Uri = vscode.Uri.joinPath(workspaceFoldersZero, `${paramCaseCardTitle}.md`);
|
||||||
|
const buffer: Buffer = Buffer.from(`# ${cardTitle}`, 'utf8');
|
||||||
|
await vscode.workspace.fs.writeFile(fileUri, buffer);
|
||||||
|
const textDocument: vscode.TextDocument = await vscode.workspace.openTextDocument(fileUri);
|
||||||
|
vscode.window.showTextDocument(textDocument);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const newMarkdownFile = () => newMarkdownFileLogic();
|
@ -177,7 +177,7 @@ function transformToPopperCaseLogic(): undefined {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
function paramCase(str: string) {
|
export function paramCase(str: string) {
|
||||||
return str
|
return str
|
||||||
.replace(
|
.replace(
|
||||||
/([A-Z]+(.))/g,
|
/([A-Z]+(.))/g,
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
---
|
||||||
|
type: "note"
|
||||||
|
created: "2023-07-07T16:15:27.822Z"
|
||||||
|
updated: "2023-07-07T16:15:27.822Z"
|
||||||
|
---
|
||||||
|
|
||||||
|
# vsc-extension-quickstart
|
||||||
|
|
||||||
# Welcome to your VS Code Extension
|
# Welcome to your VS Code Extension
|
||||||
|
|
||||||
## What's in the folder
|
## What's in the folder
|
||||||
|
25
type-script-helper/webviews/components/CardComponent.svelte
Normal file
25
type-script-helper/webviews/components/CardComponent.svelte
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { Card } from "../../src/Card";
|
||||||
|
|
||||||
|
export let key: string;
|
||||||
|
export let card: Card;
|
||||||
|
export let index: number;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||||
|
<!-- svelte-ignore missing-declaration -->
|
||||||
|
<li id={index.toString()}>
|
||||||
|
<!-- svelte-ignore a11y-invalid-attribute -->
|
||||||
|
<a
|
||||||
|
href="#{index.toString()}"
|
||||||
|
title="{key}"
|
||||||
|
on:click={async () => {
|
||||||
|
acquiredVsCodeApi.postMessage({
|
||||||
|
type: "open-card",
|
||||||
|
value: { File: card.File },
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{card.H1}
|
||||||
|
</a>
|
||||||
|
</li>
|
19
type-script-helper/webviews/components/Cards.svelte
Normal file
19
type-script-helper/webviews/components/Cards.svelte
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { Card } from "../../src/Card";
|
||||||
|
import CardComponent from "./CardComponent.svelte";
|
||||||
|
|
||||||
|
export let key: string = "";
|
||||||
|
export let value: Array<Card> = [];
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if !value}
|
||||||
|
<div>loading...</div>
|
||||||
|
{:else}
|
||||||
|
<hr>
|
||||||
|
<h1>{key}</h1>
|
||||||
|
<ul>
|
||||||
|
{#each value as card, index}
|
||||||
|
<CardComponent {key} {card} {index} />
|
||||||
|
{/each}
|
||||||
|
</ul>
|
||||||
|
{/if}
|
33
type-script-helper/webviews/components/ColumnsToCards.svelte
Normal file
33
type-script-helper/webviews/components/ColumnsToCards.svelte
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { onMount } from "svelte";
|
||||||
|
import Cards from "./Cards.svelte";
|
||||||
|
import type { Card } from "../../src/Card";
|
||||||
|
import type { PostMessage } from "../../src/PostMessage";
|
||||||
|
|
||||||
|
let columnsToCards: Record<string, Array<Card>> = {};
|
||||||
|
|
||||||
|
onMount(async () => {
|
||||||
|
window.addEventListener("message", async (event) => {
|
||||||
|
const postMessage: PostMessage = event.data;
|
||||||
|
switch (postMessage.type) {
|
||||||
|
case "columns-to-cards": {
|
||||||
|
columnsToCards = postMessage.value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const postMessage: PostMessage = {
|
||||||
|
type: "get-columns-to-cards",
|
||||||
|
value: undefined,
|
||||||
|
};
|
||||||
|
acquiredVsCodeApi.postMessage(postMessage);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if Object.entries(columnsToCards).length == 0}
|
||||||
|
<div>loading...</div>
|
||||||
|
{:else}
|
||||||
|
{#each Object.entries(columnsToCards) as [key, value], index (key)}
|
||||||
|
<Cards {key} {value} />
|
||||||
|
{/each}
|
||||||
|
{/if}
|
@ -0,0 +1,4 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<h1>2023-09-23-15-20</h1>
|
@ -1,87 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import { onMount } from "svelte";
|
|
||||||
import type { User } from "../types";
|
|
||||||
import type { Entry } from "../types";
|
|
||||||
|
|
||||||
export let user: User;
|
|
||||||
export let accessToken: string;
|
|
||||||
let text = "";
|
|
||||||
let entries: Array<Entry> = [];
|
|
||||||
|
|
||||||
async function addEntry(t: string) {
|
|
||||||
const response = await fetch(`${apiBaseUrl}/entry`, {
|
|
||||||
method: "POST",
|
|
||||||
body: JSON.stringify({
|
|
||||||
text: t,
|
|
||||||
}),
|
|
||||||
headers: {
|
|
||||||
"content-type": "application/json",
|
|
||||||
authorization: `Bearer ${accessToken}`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const { entry } = await response.json();
|
|
||||||
entries = [entry, ...entries];
|
|
||||||
}
|
|
||||||
|
|
||||||
onMount(async () => {
|
|
||||||
window.addEventListener("message", async (event) => {
|
|
||||||
const message = event.data;
|
|
||||||
switch (message.type) {
|
|
||||||
case "new-entry":
|
|
||||||
addEntry(message.value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await fetch(`${apiBaseUrl}/entry`, {
|
|
||||||
headers: {
|
|
||||||
authorization: `Bearer ${accessToken}`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const payload = await response.json();
|
|
||||||
entries = payload.entries;
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div>Hello: {user.name}</div>
|
|
||||||
|
|
||||||
<form
|
|
||||||
on:submit|preventDefault={async () => {
|
|
||||||
addEntry(text);
|
|
||||||
text = "";
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<input bind:value={text} />
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
{#each entries as entry (entry.id)}
|
|
||||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
||||||
<!-- svelte-ignore missing-declaration -->
|
|
||||||
<li
|
|
||||||
class:complete={entry.completed}
|
|
||||||
on:click={async () => {
|
|
||||||
entry.completed = !entry.completed;
|
|
||||||
const response = await fetch(`${apiBaseUrl}/entry`, {
|
|
||||||
method: "PUT",
|
|
||||||
body: JSON.stringify({
|
|
||||||
id: entry.id,
|
|
||||||
}),
|
|
||||||
headers: {
|
|
||||||
"content-type": "application/json",
|
|
||||||
authorization: `Bearer ${accessToken}`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
console.log(await response.json());
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{entry.text}
|
|
||||||
</li>
|
|
||||||
{/each}
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.complete {
|
|
||||||
text-decoration: line-through;
|
|
||||||
}
|
|
||||||
</style>
|
|
@ -1,70 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import { onMount } from "svelte";
|
|
||||||
import type { User } from "../types";
|
|
||||||
import Entries from "./Entries.svelte";
|
|
||||||
|
|
||||||
let accessToken = "";
|
|
||||||
let loading = true;
|
|
||||||
let user: User | null = null;
|
|
||||||
let page: "entries" | "contact" =
|
|
||||||
acquiredVsCodeApi.getState()?.page || "entries";
|
|
||||||
|
|
||||||
$: {
|
|
||||||
acquiredVsCodeApi.setState({ page });
|
|
||||||
}
|
|
||||||
|
|
||||||
onMount(async () => {
|
|
||||||
window.addEventListener("message", async (event) => {
|
|
||||||
const message = event.data;
|
|
||||||
switch (message.type) {
|
|
||||||
case "token":
|
|
||||||
accessToken = message.value;
|
|
||||||
const response = await fetch(`${apiBaseUrl}/me`, {
|
|
||||||
headers: {
|
|
||||||
authorization: `Bearer ${accessToken}`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const data = await response.json();
|
|
||||||
user = data.user;
|
|
||||||
loading = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
acquiredVsCodeApi.postMessage({ type: "get-token", value: undefined });
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{#if loading}
|
|
||||||
<div>loading...</div>
|
|
||||||
{:else if user}
|
|
||||||
{#if page === "entries"}
|
|
||||||
<Entries {user} {accessToken} />
|
|
||||||
<button
|
|
||||||
on:click={() => {
|
|
||||||
page = "contact";
|
|
||||||
}}>go to contact</button
|
|
||||||
>
|
|
||||||
{:else}
|
|
||||||
<div>Contact me here: adlkfjjqioefeqio</div>
|
|
||||||
<button
|
|
||||||
on:click={() => {
|
|
||||||
page = "entries";
|
|
||||||
}}>go back</button
|
|
||||||
>
|
|
||||||
{/if}
|
|
||||||
<!-- svelte-ignore missing-declaration -->
|
|
||||||
<button
|
|
||||||
on:click={() => {
|
|
||||||
accessToken = "";
|
|
||||||
user = null;
|
|
||||||
acquiredVsCodeApi.postMessage({ type: "logout", value: undefined });
|
|
||||||
}}>logout</button
|
|
||||||
>
|
|
||||||
{:else}
|
|
||||||
<!-- svelte-ignore missing-declaration -->
|
|
||||||
<button
|
|
||||||
on:click={() => {
|
|
||||||
acquiredVsCodeApi.postMessage({ type: "authenticate", value: undefined });
|
|
||||||
}}>login with GitHub</button
|
|
||||||
>
|
|
||||||
{/if}
|
|
@ -1,4 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<h1>WebView 2023-09-23-15-20</h1>
|
|
4
type-script-helper/webviews/globals.d.ts
vendored
4
type-script-helper/webviews/globals.d.ts
vendored
@ -1,10 +1,10 @@
|
|||||||
import * as _vscode from "vscode";
|
import * as _vscode from "vscode";
|
||||||
|
import type { PostMessage } from "../types";
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
const acquiredVsCodeApi: {
|
const acquiredVsCodeApi: {
|
||||||
postMessage: ({ type: string, value: any }) => void;
|
postMessage: (PostMessage) => void;
|
||||||
getState: () => any;
|
getState: () => any;
|
||||||
setState: (state: any) => void;
|
setState: (state: any) => void;
|
||||||
};
|
};
|
||||||
const apiBaseUrl: string;
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import App from "../components/WebView.svelte";
|
import App from "../components/ColumnsToCards.svelte";
|
||||||
|
|
||||||
const app = new App({
|
const app = new App({
|
||||||
target: document.body,
|
target: document.body,
|
@ -1,4 +1,4 @@
|
|||||||
import App from "../components/Sidebar.svelte";
|
import App from "../components/DisplayDate.svelte";
|
||||||
|
|
||||||
const app = new App({
|
const app = new App({
|
||||||
target: document.body,
|
target: document.body,
|
@ -1,11 +0,0 @@
|
|||||||
export type User = {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
githubId: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type Entry = {
|
|
||||||
text: string;
|
|
||||||
completed: boolean;
|
|
||||||
id: number;
|
|
||||||
};
|
|
Reference in New Issue
Block a user