Skip to content

Commit

Permalink
Added target to link builder
Browse files Browse the repository at this point in the history
  • Loading branch information
PrivateButts committed Dec 24, 2021
1 parent ec835f9 commit cd426ff
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 141 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ out
node_modules
.vscode-test/
*.vsix
dist/
135 changes: 0 additions & 135 deletions dist/extension.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/extension.js.map

This file was deleted.

57 changes: 52 additions & 5 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)?"
},
);

Expand All @@ -87,17 +86,65 @@ export function activate(context: vscode.ExtensionContext) {
let content = await vscode.window.showInputBox(
{
placeHolder: "Visit my website!",
prompt: "Display Text?",
title: "QLDisplayInput"
prompt: "Display Text?"
},
);

if(content === undefined){
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 = `<a href="${href}">${content}</a>`;
break;
case targets[4]:
let t = await vscode.window.showInputBox(
{
placeHolder: "customframe",
prompt: "Frame?"
},
);
text = `<a href="${href}" target="${t}">${content}</a>`;
break;
default:
text = `<a href="${href}" target="${target?.detail}">${content}</a>`;
break;
}


multiReplace(v => {
return `<a href="${href}">${content}</a>`;
return text;
});
});

Expand Down

0 comments on commit cd426ff

Please sign in to comment.