@celljs/ta-share 4.32.0 → 4.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +4 -4
  2. package/web/index.js +53 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-share",
3
- "version": "4.32.0",
3
+ "version": "4.33.0",
4
4
  "description": "A pi package for Ta: share a conversation, a page or a file by a link, public, with a password or for yourself, end to end through the relay; open and import what others share",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -27,9 +27,9 @@
27
27
  "watch": "tsc -b -w --preserveWatchOutput"
28
28
  },
29
29
  "devDependencies": {
30
- "@celljs/ta-protocol": "4.32.0",
31
- "@celljs/ta-relay": "4.32.0",
32
- "@celljs/ta-web": "4.32.0",
30
+ "@celljs/ta-protocol": "4.33.0",
31
+ "@celljs/ta-relay": "4.33.0",
32
+ "@celljs/ta-web": "4.33.0",
33
33
  "@types/react": "^19.3.0"
34
34
  },
35
35
  "publishConfig": {
package/web/index.js CHANGED
@@ -85,6 +85,7 @@ var EN = {
85
85
  ta: "Ta",
86
86
  copy: "Copy link",
87
87
  copied: "Copied",
88
+ openBrowser: "Open in browser",
88
89
  stop: "Stop sharing",
89
90
  stopTitle: "Stop sharing “{title}”?",
90
91
  stopHint: "The link stops working at once, and the copy on the relay is deleted.",
@@ -291,6 +292,7 @@ var ZH = {
291
292
  ta: "Ta",
292
293
  copy: "复制链接",
293
294
  copied: "已复制",
295
+ openBrowser: "在浏览器中打开",
294
296
  stop: "停止分享",
295
297
  stopTitle: "停止分享“{title}”?",
296
298
  stopHint: "链接立即失效,中继上的副本也会删除。",
@@ -497,6 +499,7 @@ var ZH_TW = {
497
499
  ta: "Ta",
498
500
  copy: "複製連結",
499
501
  copied: "已複製",
502
+ openBrowser: "在瀏覽器中開啟",
500
503
  stop: "停止分享",
501
504
  stopTitle: "停止分享「{title}」?",
502
505
  stopHint: "連結立即失效,中繼上的副本也會刪除。",
@@ -703,6 +706,7 @@ var JA = {
703
706
  ta: "Ta",
704
707
  copy: "リンクをコピー",
705
708
  copied: "コピーしました",
709
+ openBrowser: "ブラウザで開く",
706
710
  stop: "共有を停止",
707
711
  stopTitle: "「{title}」の共有を停止しますか?",
708
712
  stopHint: "リンクは即座に無効になり、リレー上のコピーは削除されます。",
@@ -2649,7 +2653,53 @@ function ImportBar({ link, password, title }) {
2649
2653
  onClose: () => setPicking(false)
2650
2654
  }));
2651
2655
  }
2656
+ function LinkActions({ link }) {
2657
+ const [copied, setCopied] = React.useState(false);
2658
+ const touch = pi.ui.useDevice().touch;
2659
+ React.useEffect(() => {
2660
+ if (!copied) {
2661
+ return;
2662
+ }
2663
+ const timer = setTimeout(() => setCopied(false), 1500);
2664
+ return () => clearTimeout(timer);
2665
+ }, [copied]);
2666
+ if (!pi.ui.EditorActions) {
2667
+ return null;
2668
+ }
2669
+ const Copy = icon(copied ? "Check" : "Copy");
2670
+ const Outside = icon("ExternalLink");
2671
+ const copy = () => void navigator.clipboard?.writeText(link).then(() => {
2672
+ setCopied(true);
2673
+ if (touch) {
2674
+ pi.ui.notify(t("copied"));
2675
+ }
2676
+ }).catch((error) => pi.ui.notify(message(error), "error"));
2677
+ return /* @__PURE__ */ React.createElement(pi.ui.EditorActions, null, /* @__PURE__ */ React.createElement("button", {
2678
+ type: "button",
2679
+ className: "tsh-tab-action",
2680
+ title: copied ? t("copied") : t("copy"),
2681
+ "aria-label": t("copy"),
2682
+ onClick: copy
2683
+ }, /* @__PURE__ */ React.createElement(Copy, {
2684
+ size: 15
2685
+ })), /* @__PURE__ */ React.createElement("button", {
2686
+ type: "button",
2687
+ className: "tsh-tab-action",
2688
+ title: t("openBrowser"),
2689
+ "aria-label": t("openBrowser"),
2690
+ onClick: () => window.open(link, "_blank", "noopener,noreferrer")
2691
+ }, /* @__PURE__ */ React.createElement(Outside, {
2692
+ size: 15
2693
+ })));
2694
+ }
2652
2695
  function SharedView({ link }) {
2696
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(LinkActions, {
2697
+ link
2698
+ }), /* @__PURE__ */ React.createElement(SharedContent, {
2699
+ link
2700
+ }));
2701
+ }
2702
+ function SharedContent({ link }) {
2653
2703
  const [state, setState] = React.useState({ step: "loading" });
2654
2704
  const [input, setInput] = React.useState("");
2655
2705
  const open = React.useCallback(async (password) => {
@@ -3083,6 +3133,9 @@ var STYLE = `
3083
3133
  .tsh-icon.tsh-danger:hover:not(:disabled) { color: var(--ta-red); }
3084
3134
 
3085
3135
  /* What a link shares, in the workbench. */
3136
+ .tsh-tab-action { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 7px; background: none; color: var(--ta-muted); cursor: pointer; }
3137
+ .tsh-tab-action:hover { background: var(--ta-hover); color: var(--ta-text); }
3138
+ .tsh-tab-action:focus-visible { outline: 1px solid var(--ta-border-focus); outline-offset: -1px; }
3086
3139
  .tsh-view { height: 100%; overflow: auto; padding: 18px 20px 32px; box-sizing: border-box; }
3087
3140
  .tsh-view-page { padding: 0; overflow: hidden; }
3088
3141
  .tsh-head { margin: 0 auto 18px; max-width: 760px; }