@riebeckite/plugin-text-fragment 0.0.32 → 0.0.33

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.
package/README.md CHANGED
@@ -7,6 +7,10 @@ you select in an article.
7
7
 
8
8
  [日本語](./README_ja.md)
9
9
 
10
+ ## Live example
11
+
12
+ Select any sentence on this page. The plugin adds a copy action that produces a URL containing a `#:~:text=` fragment for the selected text.
13
+
10
14
  ## Overview
11
15
 
12
16
  Client-only plugin. On page load it installs one selection popover with two
@@ -21,17 +25,17 @@ actions:
21
25
 
22
26
  ```ts
23
27
  import { defineConfig } from "@riebeckite/core";
24
- import { textFragmentPlugin } from "@riebeckite/plugin-text-fragment";
28
+ import { textFragment } from "@riebeckite/plugin-text-fragment";
25
29
 
26
30
  export default defineConfig({
27
31
  // ...
28
- plugins: [textFragmentPlugin()],
32
+ plugins: [textFragment()],
29
33
  });
30
34
  ```
31
35
 
32
- `textFragmentPlugin()` registers `style.css` and the `initTextFragmentShare`
36
+ `textFragment()` registers `style.css` and the `initTextFragmentShare`
33
37
  client entry, which the app calls during page initialization. Pass
34
- `textFragmentPlugin({ labels })` to override individual UI labels.
38
+ `textFragment({ labels })` to override individual UI labels.
35
39
 
36
40
  ## Behavior
37
41
 
@@ -59,7 +63,7 @@ The fragment follows `#:~:text=[prefix-,]start[,end][,-suffix]`:
59
63
 
60
64
  ## API
61
65
 
62
- - `textFragmentPlugin(options?)` — plugin factory; `options.labels` overrides
66
+ - `textFragment(options?)` — plugin factory; `options.labels` overrides
63
67
  the UI labels
64
68
  - `initTextFragmentShare(labels?)` — client initializer (also via
65
69
  `@riebeckite/plugin-text-fragment/client`)
package/README_ja.md CHANGED
@@ -6,6 +6,10 @@
6
6
 
7
7
  [English](./README.md)
8
8
 
9
+ ## 実行例
10
+
11
+ このページの任意の文を選択してください。選択したテキストへの `#:~:text=` フラグメントを含む URL をコピーする操作が追加されます。
12
+
9
13
  ## できること
10
14
 
11
15
  クライアント専用のプラグインです。ページ表示時に、選択範囲のそばへ小さなポップオーバーを出し、次の二つをコピーできます。
@@ -17,15 +21,15 @@
17
21
 
18
22
  ```ts
19
23
  import { defineConfig } from "@riebeckite/core";
20
- import { textFragmentPlugin } from "@riebeckite/plugin-text-fragment";
24
+ import { textFragment } from "@riebeckite/plugin-text-fragment";
21
25
 
22
26
  export default defineConfig({
23
27
  // ...
24
- plugins: [textFragmentPlugin()],
28
+ plugins: [textFragment()],
25
29
  });
26
30
  ```
27
31
 
28
- `textFragmentPlugin()` はスタイルと `initTextFragmentShare` を登録します。初期化処理はアプリのページ初期化時に呼ばれます。`textFragmentPlugin({ labels })` で UI ラベルだけを差し替えられます。
32
+ `textFragment()` はスタイルと `initTextFragmentShare` を登録します。初期化処理はアプリのページ初期化時に呼ばれます。`textFragment({ labels })` で UI ラベルだけを差し替えられます。
29
33
 
30
34
  ## 挙動
31
35
 
@@ -42,12 +46,12 @@ export default defineConfig({
42
46
  - `,`、`-`、`&` はパーセントエンコードします(`%2C`、`%2D`、`%26`)。
43
47
  - それ以外は UTF-8 単位でエンコードします(改行は `%0A`)。
44
48
  - ページ URL に既存のハッシュがあるときは、それを外してからディレクティブを付けます。
45
- - 200 文字前後より長い選択、または改行を含む選択は、先頭と末尾のトークンによる `start,end` に短縮します。
49
+ - 約 200 文字を超える選択、または改行を含む選択は、先頭と末尾のトークンによる `start,end` に短縮します。
46
50
  - 空または空白だけの選択は `""` を返します。
47
51
 
48
52
  ## 公開 API
49
53
 
50
- - `textFragmentPlugin(options?)`:プラグインファクトリ。`options.labels` で UI ラベルを上書きする
54
+ - `textFragment(options?)`:プラグインファクトリ。`options.labels` で UI ラベルを上書きする
51
55
  - `initTextFragmentShare(labels?)`:ブラウザ初期化関数(`@riebeckite/plugin-text-fragment/client` からも読み込める)
52
56
  - `encodeTextFragment(text)`:テキスト片をパーセントエンコードする
53
57
  - `buildTextFragmentUrl(pageUrl, selection, options?)`:ディープリンクを作る。`options` は `{ prefix?, suffix? }`
package/dist/index.d.ts CHANGED
@@ -9,4 +9,4 @@ export type TextFragmentPluginOptions = {
9
9
  * Registers the client-only text fragment share plugin: a selection popover
10
10
  * that copies a `#:~:text=` deep link or a Markdown quote.
11
11
  */
12
- export declare function textFragmentPlugin(options?: TextFragmentPluginOptions): RiebeckitePlugin;
12
+ export declare function textFragment(options?: TextFragmentPluginOptions): RiebeckitePlugin;
package/dist/index.js CHANGED
@@ -272,7 +272,7 @@ function copyWithExecCommand(value) {
272
272
  }
273
273
 
274
274
  // index.ts
275
- function textFragmentPlugin(options = {}) {
275
+ function textFragment(options = {}) {
276
276
  return definePlugin({
277
277
  name: "text-fragment",
278
278
  assets: [
@@ -300,5 +300,5 @@ export {
300
300
  buildTextFragmentUrl,
301
301
  encodeTextFragment,
302
302
  initTextFragmentShare,
303
- textFragmentPlugin
303
+ textFragment
304
304
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/plugin-text-fragment",
3
- "version": "0.0.32",
3
+ "version": "0.0.33",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -21,7 +21,7 @@
21
21
  "./style.css": "./style.css"
22
22
  },
23
23
  "dependencies": {
24
- "@riebeckite/core": "0.0.32"
24
+ "@riebeckite/core": "0.0.33"
25
25
  },
26
26
  "devDependencies": {
27
27
  "tsx": "^4.22.4"