Skip to content

Commit

Permalink
modernise brackets and quotse extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
pilotmoon committed Apr 5, 2024
1 parent cf9ae87 commit 18cae98
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 188 deletions.
Binary file modified extensions/Brackets.popclipextz
Binary file not shown.
Binary file modified extensions/Quotes.popclipextz
Binary file not shown.
40 changes: 0 additions & 40 deletions source/Brackets.popclipext/Config.js

This file was deleted.

5 changes: 3 additions & 2 deletions source/Brackets.popclipext/Config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"identifier" : "com.pilotmoon.popclip.extension.brackets",
"name" : "Brackets",
"icon" : "brackets-round.png",
"popclipVersion" : 3749,
"entitlements": ["dynamic"]
"popclipVersion" : 4225,
"entitlements": ["dynamic"],
"module": "brackets.ts"
}
39 changes: 0 additions & 39 deletions source/Brackets.popclipext/Config.ts

This file was deleted.

45 changes: 45 additions & 0 deletions source/Brackets.popclipext/brackets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const styles = [
"(round)",
"[square]",
"{curly}",
"<angle>",
];

function makeIcon(index: number): string {
return [
"brackets-round.png",
"brackets-square.png",
"brackets-curly.png",
"brackets-angle.png",
][index];
}

function makeIdentifier(index: number): string {
return `style-${index}`;
}

defineExtension({
options: styles.map((style, index) => {
return {
identifier: makeIdentifier(index),
label: style,
type: "boolean",
icon: makeIcon(index),
defaultValue: !(index > 0),
};
}),
actions: function (selection, options) {
if (selection.text.length > 0) {
return styles.filter((style, index) => options[makeIdentifier(index)])
.map((style, index) => {
return {
title: styles[index],
icon: makeIcon(index),
code: (selection) => {
popclip.pasteText(style[0] + selection.text + style[2]);
},
};
});
}
}
});
51 changes: 0 additions & 51 deletions source/Quotes.popclipext/Config.js

This file was deleted.

5 changes: 3 additions & 2 deletions source/Quotes.popclipext/Config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"identifier" : "com.pilotmoon.popclip.extension.quotes",
"name" : "Quotes",
"icon" : "quotes.png",
"popclipVersion" : 3749,
"note" : "Updated 12 Oct 2021: Added backticks"
"popclipVersion" : 4225,
"entitlements" : ["dynamic"],
"module" : "quotes.ts"
}
54 changes: 0 additions & 54 deletions source/Quotes.popclipext/Config.ts

This file was deleted.

53 changes: 53 additions & 0 deletions source/Quotes.popclipext/quotes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// the possible quotes styles
const styles = [
"“…”",
"‘…’",
'"…"',
"'…'",
"`…`",
"«…»",
"‹…›",
"»…«",
"›…‹",
"「…」",
"『…』",
"„…“",
"‚…‘",
];

// generate square icon
function makeIcon(style: string): string {
return `[[${style[0]}${style[2]}]]`;
}

function makeIdentifier(index: number): string {
return `style-${index}`;
}

const extension: Extension = {
options: styles.map((style, index) => {
return {
identifier: makeIdentifier(index),
label: style,
type: "boolean",
icon: makeIcon(style),
defaultValue: !(index > 0),
};
}),
actions(selection, options) {
if (selection.text.length > 0) {
return styles.filter((style, index) => options[makeIdentifier(index)])
.map((style, index) => {
return {
title: styles[index],
icon: makeIcon(style),
code: (selection) => {
popclip.pasteText(style[0] + selection.text + style[2]);
},
};
});
}
},
};

export default extension;

0 comments on commit 18cae98

Please sign in to comment.