From cd426ffe6ea9556ebb0a41846365d05bfe54297b Mon Sep 17 00:00:00 2001 From: Randy Butts Date: Thu, 23 Dec 2021 21:55:54 -0500 Subject: [PATCH] Added target to link builder --- .gitignore | 1 + dist/extension.js | 135 ------------------------------------------ dist/extension.js.map | 1 - src/extension.ts | 57 ++++++++++++++++-- 4 files changed, 53 insertions(+), 141 deletions(-) delete mode 100644 dist/extension.js delete mode 100644 dist/extension.js.map diff --git a/.gitignore b/.gitignore index 5fe00fe..aa5f7d3 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ out node_modules .vscode-test/ *.vsix +dist/ \ No newline at end of file diff --git a/dist/extension.js b/dist/extension.js deleted file mode 100644 index 0396c3b..0000000 --- a/dist/extension.js +++ /dev/null @@ -1,135 +0,0 @@ -/******/ (() => { // webpackBootstrap -/******/ "use strict"; -/******/ var __webpack_modules__ = ([ -/* 0 */, -/* 1 */ -/***/ ((module) => { - -module.exports = require("vscode"); - -/***/ }) -/******/ ]); -/************************************************************************/ -/******/ // The module cache -/******/ var __webpack_module_cache__ = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = __webpack_module_cache__[moduleId] = { -/******/ // no module.id needed -/******/ // no module.loaded needed -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/************************************************************************/ -var __webpack_exports__ = {}; -// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. -(() => { -var exports = __webpack_exports__; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.deactivate = exports.activate = void 0; -// The module 'vscode' contains the VS Code extensibility API -// Import the module and reference it with the alias vscode in your code below -const vscode = __webpack_require__(1); -// this method is called when your extension is activated -// your extension is activated the very first time the command is executed -function activate(context) { - function multiReplace(templateCallback) { - let editor = vscode.window.activeTextEditor; - if (!editor) { - vscode.window.showWarningMessage('No text selected'); - return; // No open text editor - } - let selections = editor.selections; - editor.edit(function (e) { - selections.forEach(selection => { - var text = editor.document.getText(selection); - text = templateCallback(text); - e.replace(selection, text); - }); - }); - } - let mailto = vscode.commands.registerCommand('extension.quick-link.mailto', () => { - multiReplace(v => { - return `${v}`; - }); - }); - context.subscriptions.push(mailto); - let tel = vscode.commands.registerCommand('extension.quick-link.tel', () => { - multiReplace(v => { - return `${v}`; - }); - }); - context.subscriptions.push(tel); - let sms = vscode.commands.registerCommand('extension.quick-link.sms', () => { - multiReplace(v => { - return `${v}`; - }); - }); - context.subscriptions.push(sms); - let callto = vscode.commands.registerCommand('extension.quick-link.callto', () => { - multiReplace(v => { - return `${v}`; - }); - }); - context.subscriptions.push(callto); - let fax = vscode.commands.registerCommand('extension.quick-link.fax', () => { - multiReplace(v => { - return `${v}`; - }); - }); - context.subscriptions.push(fax); - let linkInPlace = vscode.commands.registerCommand('extension.quick-link.link-in-place', () => { - multiReplace(v => { - return `${v}`; - }); - }); - context.subscriptions.push(linkInPlace); - let linkCustom = vscode.commands.registerCommand('extension.quick-link.link-builder', async () => { - let href = await vscode.window.showInputBox({ - placeHolder: "https://privatebutts.dev", - prompt: "Destination (href attribute)?", - title: "QLHREFInput" - }); - if (href === undefined) { - return; - } - let content = await vscode.window.showInputBox({ - placeHolder: "Visit my website!", - prompt: "Display Text?", - title: "QLDisplayInput" - }); - if (content === undefined) { - return; - } - multiReplace(v => { - return `${content}`; - }); - }); - context.subscriptions.push(linkCustom); - console.log('Quick Link has been installed'); -} -exports.activate = activate; -function deactivate() { } -exports.deactivate = deactivate; - -})(); - -module.exports = __webpack_exports__; -/******/ })() -; -//# sourceMappingURL=extension.js.map \ No newline at end of file diff --git a/dist/extension.js.map b/dist/extension.js.map deleted file mode 100644 index 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F,YAAY,CAAC,CAAC,CAAC,EAAE;YAChB,OAAO,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC;QAClC,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAExC,IAAI,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,mCAAmC,EAAE,KAAK,IAAI,EAAE;QAChG,IAAI,IAAI,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,YAAY,CAC1C;YACC,WAAW,EAAE,0BAA0B;YACvC,MAAM,EAAE,+BAA+B;YACvC,KAAK,EAAE,aAAa;SACpB,CACD,CAAC;QAEF,IAAG,IAAI,KAAK,SAAS,EAAC;YACrB,OAAO;SACP;QAED,IAAI,OAAO,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,YAAY,CAC7C;YACC,WAAW,EAAE,mBAAmB;YAChC,MAAM,EAAE,eAAe;YACvB,KAAK,EAAE,gBAAgB;SACvB,CACD,CAAC;QAEF,IAAG,OAAO,KAAK,SAAS,EAAC;YACxB,OAAO;SACP;QAED,YAAY,CAAC,CAAC,CAAC,EAAE;YAChB,OAAO,YAAY,IAAI,KAAK,OAAO,MAAM,CAAC;QAC3C,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACvC,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;AAC9C,CAAC;AAnGD,4BAmGC;AAED,SAAgB,UAAU,KAAI,CAAC;AAA/B,gCAA+B","sources":["webpack://quick-link/external commonjs \"vscode\"","webpack://quick-link/webpack/bootstrap","webpack://quick-link/./src/extension.ts"],"names":[],"sourceRoot":""} \ No newline at end of file diff --git a/src/extension.ts b/src/extension.ts index c6fb451..8c326e6 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -75,8 +75,7 @@ export function activate(context: vscode.ExtensionContext) { let href = await vscode.window.showInputBox( { placeHolder: "https://privatebutts.dev", - prompt: "Destination (href attribute)?", - title: "QLHREFInput" + prompt: "Destination (href attribute)?" }, ); @@ -87,8 +86,7 @@ export function activate(context: vscode.ExtensionContext) { let content = await vscode.window.showInputBox( { placeHolder: "Visit my website!", - prompt: "Display Text?", - title: "QLDisplayInput" + prompt: "Display Text?" }, ); @@ -96,8 +94,57 @@ export function activate(context: vscode.ExtensionContext) { return; } + let targets:vscode.QuickPickItem[] = [ + { + label: 'Same Frame (no target)', + }, + { + label: 'New Tab or Window', + detail: '_blank' + }, + { + label: 'Parent Frame', + detail: '_parent' + }, + { + label: 'Top Frame', + detail: '_top' + }, + { + label: 'Custom Frame' + } + + ]; + + let target = await vscode.window.showQuickPick( + targets, + { + title: "Target?" + } + ); + + let text = ""; + switch(target) { + case targets[0]: + text = `${content}`; + break; + case targets[4]: + let t = await vscode.window.showInputBox( + { + placeHolder: "customframe", + prompt: "Frame?" + }, + ); + text = `${content}`; + break; + default: + text = `${content}`; + break; + } + + multiReplace(v => { - return `${content}`; + return text; }); });