Skip to content

Commit

Permalink
clipboard action
Browse files Browse the repository at this point in the history
  • Loading branch information
taichunmin committed Feb 5, 2024
1 parent 355739b commit 24faba2
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 95 deletions.
131 changes: 53 additions & 78 deletions libs/tryAddShareBtn.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,89 +8,64 @@ const flexShareBtn = ({ uri, gistId }) => ({
type: 'flex',
contents: {
type: 'carousel',
contents: [
contents: _.map([
{
size: 'nano',
type: 'bubble',
body: {
alignItems: 'center',
justifyContent: 'center',
layout: 'horizontal',
paddingAll: '5px',
spacing: 'md',
type: 'box',
action: {
type: 'uri',
uri,
},
contents: [
{
height: '16px',
layout: 'vertical',
type: 'box',
width: '16px',
contents: [
{
aspectMode: 'cover',
aspectRatio: '1:1',
size: 'full',
type: 'image',
url: 'https://i.imgur.com/IFjR25G.png',
},
],
},
{
flex: 0,
size: '16px',
text: '分享',
type: 'text',
},
],
},
icon: 'https://i.imgur.com/IFjR25G.png',
text: '分享',
action: { type: 'uri', uri },
},
{
size: 'nano',
type: 'bubble',
body: {
alignItems: 'center',
justifyContent: 'center',
layout: 'horizontal',
paddingAll: '5px',
spacing: 'md',
type: 'box',
action: {
data: '/gistReplaceAltText',
displayText: '如果你是在手機上點選「改替代」按鈕,你應該可以在下方輸入框看到自動填寫的文字指令,請在指令後面輸入新的替代文字後傳送。',
fillInText: `/gistReplaceAltText ${gistId} `,
inputOption: 'openKeyboard',
type: 'postback',
},
contents: [
{
height: '16px',
layout: 'vertical',
type: 'box',
width: '16px',
contents: [
{
aspectMode: 'cover',
aspectRatio: '1:1',
size: 'full',
type: 'image',
url: 'https://i.imgur.com/dLElEk7.png',
},
],
},
{
flex: 0,
size: '16px',
text: '改替代',
type: 'text',
},
],
icon: 'https://i.imgur.com/W6RbIne.png',
text: '複製網址',
action: { type: 'clipboard', clipboardText: uri },
},
{
icon: 'https://i.imgur.com/dLElEk7.png',
text: '改替代',
action: {
data: '/gistReplaceAltText',
displayText: '如果你是在手機上點選「改替代」按鈕,你應該可以在下方輸入框看到自動填寫的文字指令,請在指令後面輸入新的替代文字後傳送。',
fillInText: `/gistReplaceAltText ${gistId} `,
inputOption: 'openKeyboard',
type: 'postback',
},
},
],
], btn => ({
size: 'nano',
type: 'bubble',
body: {
alignItems: 'center',
justifyContent: 'center',
layout: 'horizontal',
paddingAll: '5px',
spacing: 'md',
type: 'box',
action: btn.action,
contents: [
{
height: '16px',
layout: 'vertical',
type: 'box',
width: '16px',
contents: [
{
aspectMode: 'cover',
aspectRatio: '1:1',
size: 'full',
type: 'image',
url: btn.icon,
},
],
},
{
flex: 0,
size: '16px',
text: btn.text,
type: 'text',
},
],
},
})),
},
sender: {
iconUrl: 'https://i.imgur.com/1KZoSue.png',
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
"dependencies": {
"@google-cloud/functions-framework": "^3.3.0",
"@josephg/resolvable": "^1.0.1",
"@line/bot-sdk": "^8.2.0",
"axios": "^1.6.3",
"@line/bot-sdk": "^8.3.1",
"axios": "^1.6.7",
"crypto-js": "^4.2.0",
"dayjs": "^1.11.10",
"dotenv": "^16.3.1",
"dotenv": "^16.4.1",
"json5": "^2.2.3",
"lodash": "^4.17.21",
"octokit": "^3.1.2",
Expand All @@ -22,7 +22,7 @@
"eslint": "^8.56.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-n": "^16.6.1",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.1.1",
"jest": "^29.7.0"
Expand Down
40 changes: 27 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -612,10 +612,10 @@
"@jridgewell/resolve-uri" "^3.1.0"
"@jridgewell/sourcemap-codec" "^1.4.14"

"@line/bot-sdk@^8.2.0":
version "8.2.0"
resolved "https://registry.yarnpkg.com/@line/bot-sdk/-/bot-sdk-8.2.0.tgz#4c42db8ed368365917dd9fd8022ef65d0b0a9889"
integrity sha512-DpAXnyuZXjNQ2lcoRrkI7bYfmOYkJ+vnYXDHSBGH3ik/6sVNM15JQS/C3DHLpzlp9xVuwcJqJGRoGv8SSQDTZA==
"@line/bot-sdk@^8.3.1":
version "8.3.1"
resolved "https://registry.yarnpkg.com/@line/bot-sdk/-/bot-sdk-8.3.1.tgz#2478e9ddce444f86d3a55ab7da80a214abb6e0d0"
integrity sha512-8rE5Cb4soGYr9momWZ6Cgp+5XkXsNuGL73zfXczCd1Hhwdc5bq9VbA4AC3BpnIRbJE/g/16F12BYJojsNkrGlQ==
dependencies:
"@types/body-parser" "^1.19.2"
"@types/node" "^20.0.0"
Expand Down Expand Up @@ -1285,7 +1285,7 @@ available-typed-arrays@^1.0.5:
resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz#92f95616501069d07d10edb2fc37d3e1c65123b7"
integrity sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==

axios@^1.0.0, axios@^1.6.3:
axios@^1.0.0:
version "1.6.3"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.3.tgz#7f50f23b3aa246eff43c54834272346c396613f4"
integrity sha512-fWyNdeawGam70jXSVlKl+SUNVcL6j6W79CuSIPfi6HnDUmSCH6gyUys/HrqHeA/wU0Az41rRgean494d0Jb+ww==
Expand All @@ -1294,6 +1294,15 @@ axios@^1.0.0, axios@^1.6.3:
form-data "^4.0.0"
proxy-from-env "^1.1.0"

axios@^1.6.7:
version "1.6.7"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.7.tgz#7b48c2e27c96f9c68a2f8f31e2ab19f59b06b0a7"
integrity sha512-/hDJGff6/c7u0hDkvkGxR/oy6CbCs8ziCsC7SqmhjfozqiJGc8Z11wrv9z9lYfY4K8l+H9TpjcMDX0xOZmx+RA==
dependencies:
follow-redirects "^1.15.4"
form-data "^4.0.0"
proxy-from-env "^1.1.0"

babel-jest@^29.7.0:
version "29.7.0"
resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-29.7.0.tgz#f4369919225b684c56085998ac63dbd05be020d5"
Expand Down Expand Up @@ -1776,10 +1785,10 @@ doctrine@^3.0.0:
dependencies:
esutils "^2.0.2"

dotenv@^16.3.1:
version "16.3.1"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.3.1.tgz#369034de7d7e5b120972693352a3bf112172cc3e"
integrity sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==
dotenv@^16.4.1:
version "16.4.1"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.1.tgz#1d9931f1d3e5d2959350d1250efab299561f7f11"
integrity sha512-CjA3y+Dr3FyFDOAMnxZEGtnW9KBR2M0JvvUtXNW+dYJL5ROWxP9DUHCwgFqpMk0OXCc0ljhaNTr2w/kutYIcHQ==

[email protected]:
version "1.0.11"
Expand Down Expand Up @@ -1981,10 +1990,10 @@ eslint-plugin-import@^2.29.1:
semver "^6.3.1"
tsconfig-paths "^3.15.0"

eslint-plugin-n@^16.6.1:
version "16.6.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-n/-/eslint-plugin-n-16.6.1.tgz#b16e0033bc9ce592b1c3512cb1cee24f84ecb5ae"
integrity sha512-M1kE5bVQRLBMDYRZwDhWzlzbp370SRRRC1MHqq4I3L2Tatey+9/2csc5mwLDPlmhJaDvkojbrNUME5/llpRyDg==
eslint-plugin-n@^16.6.2:
version "16.6.2"
resolved "https://registry.yarnpkg.com/eslint-plugin-n/-/eslint-plugin-n-16.6.2.tgz#6a60a1a376870064c906742272074d5d0b412b0b"
integrity sha512-6TyDmZ1HXoFQXnhCTUjVFULReoBPOAjpuiKELMkeP40yffI/1ZRO+d9ug/VC6fqISo2WkuIBk3cvuRPALaWlOQ==
dependencies:
"@eslint-community/eslint-utils" "^4.4.0"
builtins "^5.0.1"
Expand Down Expand Up @@ -2294,6 +2303,11 @@ follow-redirects@^1.15.0:
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13"
integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==

follow-redirects@^1.15.4:
version "1.15.5"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.5.tgz#54d4d6d062c0fa7d9d17feb008461550e3ba8020"
integrity sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==

for-each@^0.3.3:
version "0.3.3"
resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.3.tgz#69b447e88a0a5d32c3e7084f3f1710034b21376e"
Expand Down

0 comments on commit 24faba2

Please sign in to comment.