@capgo/capacitor-textinteraction 8.0.42 → 8.1.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.
package/README.md CHANGED
@@ -5,7 +5,7 @@ Turn text selection on or off in the WebView of your Capacitor iOS app, so it fe
5
5
  <a href="https://capgo.app/?ref=plugin_textinteraction"><img src="https://capgo.app/readme-banner.svg?repo=Cap-go/capacitor-textinteraction" alt="Capgo - Instant updates for Capacitor" /></a>
6
6
 
7
7
  <div align="center">
8
- <p><b>Capgo</b>: open-source live updates for Ionic and Capacitor apps. Ship OTA fixes and features instantly, without waiting for app store review.</p>
8
+ <p><b>Capgo</b>: push fixes to your Capacitor users in minutes, build signed iOS and Android apps without a Mac, and roll back in one click.</p>
9
9
  <h2><a href="https://capgo.app/register/?ref=plugin_textinteraction">➡️ Get started for free</a></h2>
10
10
  <p>14-day unlimited free trial. No credit card required</p>
11
11
  <p><a href="https://capgo.app/consulting/?ref=plugin_textinteraction">Missing a feature? We'll build the plugin for you 💪</a></p>
@@ -18,7 +18,7 @@ Turn text selection on or off in the WebView of your Capacitor iOS app, so it fe
18
18
  ## Key features
19
19
 
20
20
  - **One call**: `toggle()` enables or disables text interaction.
21
- - **Native feel**: stops long-press text selection when disabled.
21
+ - **Native feel**: stops long-press text selection when disabled. Text inputs stop working too, so turn it back on before text entry.
22
22
  - **WebKit based**: uses the WKWebView text interaction setting on iOS.
23
23
  - **Reversible**: turn it back on for screens with editable or copyable text.
24
24
  - **Platforms**: iOS. iOS only. Android and web are not supported.
@@ -64,18 +64,45 @@ npx cap sync
64
64
  ```ts
65
65
  import { TextInteraction } from '@capgo/capacitor-textinteraction';
66
66
 
67
- // Disable the iOS magnifier lens while the WebView is visible
68
- await TextInteraction.toggle({ enabled: false });
67
+ const { enabled } = await TextInteraction.isEnabled();
68
+
69
+ if (enabled) {
70
+ // Disable the iOS magnifier lens while the WebView is visible
71
+ await TextInteraction.toggle({ enabled: false });
72
+ }
69
73
 
70
74
  // Remember to re-enable before presenting any text inputs
71
75
  await TextInteraction.toggle({ enabled: true });
72
76
  ```
73
77
 
78
+ ### Configuration
79
+
80
+ Set defaults in `capacitor.config.ts`:
81
+
82
+ ```ts
83
+ import type { CapacitorConfig } from '@capacitor/cli';
84
+
85
+ const config: CapacitorConfig = {
86
+ plugins: {
87
+ TextInteraction: {
88
+ enabled: true,
89
+ locked: false,
90
+ },
91
+ },
92
+ };
93
+
94
+ export default config;
95
+ ```
96
+
97
+ - `enabled` (default `true`): when `false`, text interaction starts disabled on app launch.
98
+ - `locked` (default `false`): when `true`, `toggle()` rejects at runtime; use `isEnabled()` to read the current state.
99
+
74
100
  ## API
75
101
 
76
102
  <docgen-index>
77
103
 
78
104
  * [`toggle(...)`](#toggle)
105
+ * [`isEnabled()`](#isenabled)
79
106
  * [`getPluginVersion()`](#getpluginversion)
80
107
  * [Interfaces](#interfaces)
81
108
 
@@ -106,6 +133,25 @@ iOS only.
106
133
  --------------------
107
134
 
108
135
 
136
+ ### isEnabled()
137
+
138
+ ```typescript
139
+ isEnabled() => Promise<TextInteractionEnabledResult>
140
+ ```
141
+
142
+ Returns whether text interaction is currently enabled.
143
+
144
+ On iOS this reflects the WebView preference. On Android and web, toggling text
145
+ interaction is not supported; the value reflects the plugin configuration state
146
+ (`plugins.TextInteraction.enabled` at startup) rather than a platform change.
147
+
148
+ **Returns:** <code>Promise&lt;<a href="#textinteractionenabledresult">TextInteractionEnabledResult</a>&gt;</code>
149
+
150
+ **Since:** 8.0.41
151
+
152
+ --------------------
153
+
154
+
109
155
  ### getPluginVersion()
110
156
 
111
157
  ```typescript
@@ -128,10 +174,6 @@ Get the native Capacitor plugin version
128
174
  | ------------- | -------------------- | ------------------------------------------------------------------------------------------------ |
129
175
  | **`success`** | <code>boolean</code> | `true` when the platform supports toggling text interaction (iOS &gt;= 14.5), otherwise `false`. |
130
176
 
131
- | Method | Signature | Description |
132
- | -------------------- | -------------------------------------------- | --------------------------------------- |
133
- | **getPluginVersion** | () =&gt; Promise&lt;{ version: string; }&gt; | Get the native Capacitor plugin version |
134
-
135
177
 
136
178
  #### TextInteractionOptions
137
179
 
@@ -139,6 +181,13 @@ Get the native Capacitor plugin version
139
181
  | ------------- | -------------------- | -------------------------------------------------------------------------------------------------------------------- |
140
182
  | **`enabled`** | <code>boolean</code> | Whether text interaction should be enabled or disabled. Disabling hides the magnifier lens reintroduced with iOS 15. |
141
183
 
184
+
185
+ #### TextInteractionEnabledResult
186
+
187
+ | Prop | Type | Description |
188
+ | ------------- | -------------------- | ---------------------------------------------- |
189
+ | **`enabled`** | <code>boolean</code> | Whether text interaction is currently enabled. |
190
+
142
191
  </docgen-api>
143
192
 
144
193
  ### Credits
@@ -4,6 +4,16 @@ import com.getcapacitor.Logger;
4
4
 
5
5
  public class TextInteraction {
6
6
 
7
+ private boolean enabled = true;
8
+
9
+ public boolean isEnabled() {
10
+ return enabled;
11
+ }
12
+
13
+ public void setEnabled(boolean enabled) {
14
+ this.enabled = enabled;
15
+ }
16
+
7
17
  public boolean toggle(boolean enabled) {
8
18
  Logger.info("TextInteraction", "toggle called on Android with enabled=" + enabled + ". This platform is not supported.");
9
19
  return false;
@@ -9,12 +9,28 @@ import com.getcapacitor.annotation.CapacitorPlugin;
9
9
  @CapacitorPlugin(name = "TextInteraction")
10
10
  public class TextInteractionPlugin extends Plugin {
11
11
 
12
- private final String pluginVersion = "8.0.42";
12
+ private final String pluginVersion = "8.1.0";
13
+
14
+ private static final String LOCKED_ERROR = "TextInteraction state is locked by config (plugins.TextInteraction.locked)";
13
15
 
14
16
  private TextInteraction implementation = new TextInteraction();
15
17
 
18
+ private boolean locked = false;
19
+
20
+ @Override
21
+ public void load() {
22
+ boolean enabled = getConfig().getBoolean("enabled", true);
23
+ locked = getConfig().getBoolean("locked", false);
24
+ implementation.setEnabled(enabled);
25
+ }
26
+
16
27
  @PluginMethod
17
28
  public void toggle(PluginCall call) {
29
+ if (locked) {
30
+ call.reject(LOCKED_ERROR);
31
+ return;
32
+ }
33
+
18
34
  boolean enabled = call.getBoolean("enabled", false);
19
35
 
20
36
  JSObject ret = new JSObject();
@@ -22,6 +38,13 @@ public class TextInteractionPlugin extends Plugin {
22
38
  call.resolve(ret);
23
39
  }
24
40
 
41
+ @PluginMethod
42
+ public void isEnabled(PluginCall call) {
43
+ JSObject ret = new JSObject();
44
+ ret.put("enabled", implementation.isEnabled());
45
+ call.resolve(ret);
46
+ }
47
+
25
48
  @PluginMethod
26
49
  public void getPluginVersion(final PluginCall call) {
27
50
  try {
package/dist/docs.json CHANGED
@@ -24,6 +24,23 @@
24
24
  ],
25
25
  "slug": "toggle"
26
26
  },
27
+ {
28
+ "name": "isEnabled",
29
+ "signature": "() => Promise<TextInteractionEnabledResult>",
30
+ "parameters": [],
31
+ "returns": "Promise<TextInteractionEnabledResult>",
32
+ "tags": [
33
+ {
34
+ "name": "since",
35
+ "text": "8.0.41"
36
+ }
37
+ ],
38
+ "docs": "Returns whether text interaction is currently enabled.\n\nOn iOS this reflects the WebView preference. On Android and web, toggling text\ninteraction is not supported; the value reflects the plugin configuration state\n(`plugins.TextInteraction.enabled` at startup) rather than a platform change.",
39
+ "complexTypes": [
40
+ "TextInteractionEnabledResult"
41
+ ],
42
+ "slug": "isenabled"
43
+ },
27
44
  {
28
45
  "name": "getPluginVersion",
29
46
  "signature": "() => Promise<{ version: string; }>",
@@ -52,27 +69,7 @@
52
69
  "slug": "textinteractionresult",
53
70
  "docs": "",
54
71
  "tags": [],
55
- "methods": [
56
- {
57
- "name": "getPluginVersion",
58
- "signature": "() => Promise<{ version: string; }>",
59
- "parameters": [],
60
- "returns": "Promise<{ version: string; }>",
61
- "tags": [
62
- {
63
- "name": "returns",
64
- "text": "an Promise with version for this device"
65
- },
66
- {
67
- "name": "throws",
68
- "text": "An error if the something went wrong"
69
- }
70
- ],
71
- "docs": "Get the native Capacitor plugin version",
72
- "complexTypes": [],
73
- "slug": "getpluginversion"
74
- }
75
- ],
72
+ "methods": [],
76
73
  "properties": [
77
74
  {
78
75
  "name": "success",
@@ -98,6 +95,27 @@
98
95
  "type": "boolean"
99
96
  }
100
97
  ]
98
+ },
99
+ {
100
+ "name": "TextInteractionEnabledResult",
101
+ "slug": "textinteractionenabledresult",
102
+ "docs": "",
103
+ "tags": [
104
+ {
105
+ "text": "8.0.41",
106
+ "name": "since"
107
+ }
108
+ ],
109
+ "methods": [],
110
+ "properties": [
111
+ {
112
+ "name": "enabled",
113
+ "tags": [],
114
+ "docs": "Whether text interaction is currently enabled.",
115
+ "complexTypes": [],
116
+ "type": "boolean"
117
+ }
118
+ ]
101
119
  }
102
120
  ],
103
121
  "enums": [],
@@ -1,3 +1,33 @@
1
+ declare module '@capacitor/cli' {
2
+ interface PluginsConfig {
3
+ /**
4
+ * Text interaction plugin configuration.
5
+ */
6
+ TextInteraction?: TextInteractionPluginConfig;
7
+ }
8
+ }
9
+ /**
10
+ * Capacitor config for `plugins.TextInteraction`.
11
+ *
12
+ * @since 8.0.41
13
+ */
14
+ export interface TextInteractionPluginConfig {
15
+ /**
16
+ * When `false`, text interaction is disabled when the app starts.
17
+ *
18
+ * @default true
19
+ * @since 8.0.41
20
+ */
21
+ enabled?: boolean;
22
+ /**
23
+ * When `true`, {@link TextInteractionPlugin.toggle} rejects at runtime and the state
24
+ * can only be controlled via config.
25
+ *
26
+ * @default false
27
+ * @since 8.0.41
28
+ */
29
+ locked?: boolean;
30
+ }
1
31
  export interface TextInteractionPlugin {
2
32
  /**
3
33
  * Toggle text interaction (selection) on the Capacitor WebView.
@@ -8,6 +38,16 @@ export interface TextInteractionPlugin {
8
38
  * iOS only.
9
39
  */
10
40
  toggle(options: TextInteractionOptions): Promise<TextInteractionResult>;
41
+ /**
42
+ * Returns whether text interaction is currently enabled.
43
+ *
44
+ * On iOS this reflects the WebView preference. On Android and web, toggling text
45
+ * interaction is not supported; the value reflects the plugin configuration state
46
+ * (`plugins.TextInteraction.enabled` at startup) rather than a platform change.
47
+ *
48
+ * @since 8.0.41
49
+ */
50
+ isEnabled(): Promise<TextInteractionEnabledResult>;
11
51
  /**
12
52
  * Get the native Capacitor plugin version
13
53
  *
@@ -30,13 +70,13 @@ export interface TextInteractionResult {
30
70
  * `true` when the platform supports toggling text interaction (iOS >= 14.5), otherwise `false`.
31
71
  */
32
72
  success: boolean;
73
+ }
74
+ /**
75
+ * @since 8.0.41
76
+ */
77
+ export interface TextInteractionEnabledResult {
33
78
  /**
34
- * Get the native Capacitor plugin version
35
- *
36
- * @returns {Promise<{ id: string }>} an Promise with version for this device
37
- * @throws An error if the something went wrong
79
+ * Whether text interaction is currently enabled.
38
80
  */
39
- getPluginVersion(): Promise<{
40
- version: string;
41
- }>;
81
+ enabled: boolean;
42
82
  }
@@ -1,2 +1,3 @@
1
+ /// <reference types="@capacitor/cli" />
1
2
  export {};
2
3
  //# sourceMappingURL=definitions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface TextInteractionPlugin {\n /**\n * Toggle text interaction (selection) on the Capacitor WebView.\n *\n * ⚠️ Disabling text interaction prevents all text input controls from working while disabled.\n * Use it sparingly and re-enable when text entry is required.\n *\n * iOS only.\n */\n toggle(options: TextInteractionOptions): Promise<TextInteractionResult>;\n\n /**\n * Get the native Capacitor plugin version\n *\n * @returns {Promise<{ id: string }>} an Promise with version for this device\n * @throws An error if the something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n}\n\nexport interface TextInteractionOptions {\n /**\n * Whether text interaction should be enabled or disabled. Disabling hides the\n * magnifier lens reintroduced with iOS 15.\n */\n enabled: boolean;\n}\n\nexport interface TextInteractionResult {\n /**\n * `true` when the platform supports toggling text interaction (iOS >= 14.5), otherwise `false`.\n */\n success: boolean;\n\n /**\n * Get the native Capacitor plugin version\n *\n * @returns {Promise<{ id: string }>} an Promise with version for this device\n * @throws An error if the something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,wCAAwC","sourcesContent":["/// <reference types=\"@capacitor/cli\" />\n\ndeclare module '@capacitor/cli' {\n export interface PluginsConfig {\n /**\n * Text interaction plugin configuration.\n */\n TextInteraction?: TextInteractionPluginConfig;\n }\n}\n\n/**\n * Capacitor config for `plugins.TextInteraction`.\n *\n * @since 8.0.41\n */\nexport interface TextInteractionPluginConfig {\n /**\n * When `false`, text interaction is disabled when the app starts.\n *\n * @default true\n * @since 8.0.41\n */\n enabled?: boolean;\n\n /**\n * When `true`, {@link TextInteractionPlugin.toggle} rejects at runtime and the state\n * can only be controlled via config.\n *\n * @default false\n * @since 8.0.41\n */\n locked?: boolean;\n}\n\nexport interface TextInteractionPlugin {\n /**\n * Toggle text interaction (selection) on the Capacitor WebView.\n *\n * ⚠️ Disabling text interaction prevents all text input controls from working while disabled.\n * Use it sparingly and re-enable when text entry is required.\n *\n * iOS only.\n */\n toggle(options: TextInteractionOptions): Promise<TextInteractionResult>;\n\n /**\n * Returns whether text interaction is currently enabled.\n *\n * On iOS this reflects the WebView preference. On Android and web, toggling text\n * interaction is not supported; the value reflects the plugin configuration state\n * (`plugins.TextInteraction.enabled` at startup) rather than a platform change.\n *\n * @since 8.0.41\n */\n isEnabled(): Promise<TextInteractionEnabledResult>;\n\n /**\n * Get the native Capacitor plugin version\n *\n * @returns {Promise<{ id: string }>} an Promise with version for this device\n * @throws An error if the something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n}\n\nexport interface TextInteractionOptions {\n /**\n * Whether text interaction should be enabled or disabled. Disabling hides the\n * magnifier lens reintroduced with iOS 15.\n */\n enabled: boolean;\n}\n\nexport interface TextInteractionResult {\n /**\n * `true` when the platform supports toggling text interaction (iOS >= 14.5), otherwise `false`.\n */\n success: boolean;\n}\n\n/**\n * @since 8.0.41\n */\nexport interface TextInteractionEnabledResult {\n /**\n * Whether text interaction is currently enabled.\n */\n enabled: boolean;\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import type { TextInteractionPluginConfig } from './definitions';
2
+ /**
3
+ * Reads `plugins.TextInteraction` for the web implementation when embedded in the WebView.
4
+ */
5
+ export declare function readTextInteractionWebConfig(): TextInteractionPluginConfig;
6
+ export declare const TEXT_INTERACTION_LOCKED_ERROR = "TextInteraction state is locked by config (plugins.TextInteraction.locked)";
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Reads `plugins.TextInteraction` for the web implementation when embedded in the WebView.
3
+ */
4
+ export function readTextInteractionWebConfig() {
5
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
6
+ if (typeof globalThis === 'undefined') {
7
+ return {};
8
+ }
9
+ const globalConfig = globalThis;
10
+ return ((_k = (_g = (_d = (_c = (_b = (_a = globalConfig.Capacitor) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.plugins) === null || _c === void 0 ? void 0 : _c.TextInteraction) !== null && _d !== void 0 ? _d : (_f = (_e = globalConfig.CAPACITOR_CONFIG) === null || _e === void 0 ? void 0 : _e.plugins) === null || _f === void 0 ? void 0 : _f.TextInteraction) !== null && _g !== void 0 ? _g : (_j = (_h = globalConfig.__capacitorConfig) === null || _h === void 0 ? void 0 : _h.plugins) === null || _j === void 0 ? void 0 : _j.TextInteraction) !== null && _k !== void 0 ? _k : {});
11
+ }
12
+ export const TEXT_INTERACTION_LOCKED_ERROR = 'TextInteraction state is locked by config (plugins.TextInteraction.locked)';
13
+ //# sourceMappingURL=web-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-config.js","sourceRoot":"","sources":["../../src/web-config.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,UAAU,4BAA4B;;IAC1C,IAAI,OAAO,UAAU,KAAK,WAAW,EAAE,CAAC;QACtC,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,YAAY,GAAG,UAMpB,CAAC;IAEF,OAAO,CACL,MAAA,MAAA,MAAA,MAAA,MAAA,MAAA,YAAY,CAAC,SAAS,0CAAE,MAAM,0CAAE,OAAO,0CAAE,eAAe,mCACxD,MAAA,MAAA,YAAY,CAAC,gBAAgB,0CAAE,OAAO,0CAAE,eAAe,mCACvD,MAAA,MAAA,YAAY,CAAC,iBAAiB,0CAAE,OAAO,0CAAE,eAAe,mCACxD,EAAE,CACH,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,6BAA6B,GACxC,4EAA4E,CAAC","sourcesContent":["import type { TextInteractionPluginConfig } from './definitions';\n\ntype CapacitorConfigShape = {\n plugins?: {\n TextInteraction?: TextInteractionPluginConfig;\n };\n};\n\n/**\n * Reads `plugins.TextInteraction` for the web implementation when embedded in the WebView.\n */\nexport function readTextInteractionWebConfig(): TextInteractionPluginConfig {\n if (typeof globalThis === 'undefined') {\n return {};\n }\n\n const globalConfig = globalThis as typeof globalThis & {\n CAPACITOR_CONFIG?: CapacitorConfigShape;\n __capacitorConfig?: CapacitorConfigShape;\n Capacitor?: {\n config?: CapacitorConfigShape;\n };\n };\n\n return (\n globalConfig.Capacitor?.config?.plugins?.TextInteraction ??\n globalConfig.CAPACITOR_CONFIG?.plugins?.TextInteraction ??\n globalConfig.__capacitorConfig?.plugins?.TextInteraction ??\n {}\n );\n}\n\nexport const TEXT_INTERACTION_LOCKED_ERROR =\n 'TextInteraction state is locked by config (plugins.TextInteraction.locked)';\n"]}
package/dist/esm/web.d.ts CHANGED
@@ -1,6 +1,10 @@
1
1
  import { WebPlugin } from '@capacitor/core';
2
- import type { TextInteractionPlugin, TextInteractionOptions, TextInteractionResult } from './definitions';
2
+ import type { TextInteractionPlugin, TextInteractionOptions, TextInteractionResult, TextInteractionEnabledResult } from './definitions';
3
3
  export declare class TextInteractionWeb extends WebPlugin implements TextInteractionPlugin {
4
+ private enabled;
5
+ private readonly locked;
6
+ constructor();
7
+ isEnabled(): Promise<TextInteractionEnabledResult>;
4
8
  toggle(_options: TextInteractionOptions): Promise<TextInteractionResult>;
5
9
  getPluginVersion(): Promise<{
6
10
  version: string;
package/dist/esm/web.js CHANGED
@@ -1,6 +1,20 @@
1
- import { WebPlugin } from '@capacitor/core';
1
+ import { CapacitorException, WebPlugin } from '@capacitor/core';
2
+ import { readTextInteractionWebConfig, TEXT_INTERACTION_LOCKED_ERROR } from './web-config';
2
3
  export class TextInteractionWeb extends WebPlugin {
4
+ constructor() {
5
+ var _a, _b;
6
+ super();
7
+ const config = readTextInteractionWebConfig();
8
+ this.enabled = (_a = config.enabled) !== null && _a !== void 0 ? _a : true;
9
+ this.locked = (_b = config.locked) !== null && _b !== void 0 ? _b : false;
10
+ }
11
+ async isEnabled() {
12
+ return { enabled: this.enabled };
13
+ }
3
14
  async toggle(_options) {
15
+ if (this.locked) {
16
+ throw new CapacitorException(TEXT_INTERACTION_LOCKED_ERROR);
17
+ }
4
18
  throw this.unimplemented('TextInteraction.toggle is not available on web');
5
19
  }
6
20
  async getPluginVersion() {
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,kBAAmB,SAAQ,SAAS;IAC/C,KAAK,CAAC,MAAM,CAAC,QAAgC;QAC3C,MAAM,IAAI,CAAC,aAAa,CAAC,gDAAgD,CAAC,CAAC;IAC7E,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { TextInteractionPlugin, TextInteractionOptions, TextInteractionResult } from './definitions';\n\nexport class TextInteractionWeb extends WebPlugin implements TextInteractionPlugin {\n async toggle(_options: TextInteractionOptions): Promise<TextInteractionResult> {\n throw this.unimplemented('TextInteraction.toggle is not available on web');\n }\n\n async getPluginVersion(): Promise<{ version: string }> {\n return { version: 'web' };\n }\n}\n"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAQhE,OAAO,EAAE,4BAA4B,EAAE,6BAA6B,EAAE,MAAM,cAAc,CAAC;AAE3F,MAAM,OAAO,kBAAmB,SAAQ,SAAS;IAI/C;;QACE,KAAK,EAAE,CAAC;QACR,MAAM,MAAM,GAAG,4BAA4B,EAAE,CAAC;QAC9C,IAAI,CAAC,OAAO,GAAG,MAAA,MAAM,CAAC,OAAO,mCAAI,IAAI,CAAC;QACtC,IAAI,CAAC,MAAM,GAAG,MAAA,MAAM,CAAC,MAAM,mCAAI,KAAK,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,SAAS;QACb,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,QAAgC;QAC3C,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,IAAI,kBAAkB,CAAC,6BAA6B,CAAC,CAAC;QAC9D,CAAC;QACD,MAAM,IAAI,CAAC,aAAa,CAAC,gDAAgD,CAAC,CAAC;IAC7E,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF","sourcesContent":["import { CapacitorException, WebPlugin } from '@capacitor/core';\n\nimport type {\n TextInteractionPlugin,\n TextInteractionOptions,\n TextInteractionResult,\n TextInteractionEnabledResult,\n} from './definitions';\nimport { readTextInteractionWebConfig, TEXT_INTERACTION_LOCKED_ERROR } from './web-config';\n\nexport class TextInteractionWeb extends WebPlugin implements TextInteractionPlugin {\n private enabled: boolean;\n private readonly locked: boolean;\n\n constructor() {\n super();\n const config = readTextInteractionWebConfig();\n this.enabled = config.enabled ?? true;\n this.locked = config.locked ?? false;\n }\n\n async isEnabled(): Promise<TextInteractionEnabledResult> {\n return { enabled: this.enabled };\n }\n\n async toggle(_options: TextInteractionOptions): Promise<TextInteractionResult> {\n if (this.locked) {\n throw new CapacitorException(TEXT_INTERACTION_LOCKED_ERROR);\n }\n throw this.unimplemented('TextInteraction.toggle is not available on web');\n }\n\n async getPluginVersion(): Promise<{ version: string }> {\n return { version: 'web' };\n }\n}\n"]}
@@ -6,8 +6,34 @@ const TextInteraction = core.registerPlugin('TextInteraction', {
6
6
  web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.TextInteractionWeb()),
7
7
  });
8
8
 
9
+ /**
10
+ * Reads `plugins.TextInteraction` for the web implementation when embedded in the WebView.
11
+ */
12
+ function readTextInteractionWebConfig() {
13
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
14
+ if (typeof globalThis === 'undefined') {
15
+ return {};
16
+ }
17
+ const globalConfig = globalThis;
18
+ return ((_k = (_g = (_d = (_c = (_b = (_a = globalConfig.Capacitor) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.plugins) === null || _c === void 0 ? void 0 : _c.TextInteraction) !== null && _d !== void 0 ? _d : (_f = (_e = globalConfig.CAPACITOR_CONFIG) === null || _e === void 0 ? void 0 : _e.plugins) === null || _f === void 0 ? void 0 : _f.TextInteraction) !== null && _g !== void 0 ? _g : (_j = (_h = globalConfig.__capacitorConfig) === null || _h === void 0 ? void 0 : _h.plugins) === null || _j === void 0 ? void 0 : _j.TextInteraction) !== null && _k !== void 0 ? _k : {});
19
+ }
20
+ const TEXT_INTERACTION_LOCKED_ERROR = 'TextInteraction state is locked by config (plugins.TextInteraction.locked)';
21
+
9
22
  class TextInteractionWeb extends core.WebPlugin {
23
+ constructor() {
24
+ var _a, _b;
25
+ super();
26
+ const config = readTextInteractionWebConfig();
27
+ this.enabled = (_a = config.enabled) !== null && _a !== void 0 ? _a : true;
28
+ this.locked = (_b = config.locked) !== null && _b !== void 0 ? _b : false;
29
+ }
30
+ async isEnabled() {
31
+ return { enabled: this.enabled };
32
+ }
10
33
  async toggle(_options) {
34
+ if (this.locked) {
35
+ throw new core.CapacitorException(TEXT_INTERACTION_LOCKED_ERROR);
36
+ }
11
37
  throw this.unimplemented('TextInteraction.toggle is not available on web');
12
38
  }
13
39
  async getPluginVersion() {
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst TextInteraction = registerPlugin('TextInteraction', {\n web: () => import('./web').then((m) => new m.TextInteractionWeb()),\n});\nexport * from './definitions';\nexport { TextInteraction };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class TextInteractionWeb extends WebPlugin {\n async toggle(_options) {\n throw this.unimplemented('TextInteraction.toggle is not available on web');\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,eAAe,GAAGA,mBAAc,CAAC,iBAAiB,EAAE;AAC1D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,kBAAkB,EAAE,CAAC;AACtE,CAAC;;ACFM,MAAM,kBAAkB,SAASC,cAAS,CAAC;AAClD,IAAI,MAAM,MAAM,CAAC,QAAQ,EAAE;AAC3B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,gDAAgD,CAAC;AAClF,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;AACjC,IAAI;AACJ;;;;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web-config.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst TextInteraction = registerPlugin('TextInteraction', {\n web: () => import('./web').then((m) => new m.TextInteractionWeb()),\n});\nexport * from './definitions';\nexport { TextInteraction };\n//# sourceMappingURL=index.js.map","/**\n * Reads `plugins.TextInteraction` for the web implementation when embedded in the WebView.\n */\nexport function readTextInteractionWebConfig() {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;\n if (typeof globalThis === 'undefined') {\n return {};\n }\n const globalConfig = globalThis;\n return ((_k = (_g = (_d = (_c = (_b = (_a = globalConfig.Capacitor) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.plugins) === null || _c === void 0 ? void 0 : _c.TextInteraction) !== null && _d !== void 0 ? _d : (_f = (_e = globalConfig.CAPACITOR_CONFIG) === null || _e === void 0 ? void 0 : _e.plugins) === null || _f === void 0 ? void 0 : _f.TextInteraction) !== null && _g !== void 0 ? _g : (_j = (_h = globalConfig.__capacitorConfig) === null || _h === void 0 ? void 0 : _h.plugins) === null || _j === void 0 ? void 0 : _j.TextInteraction) !== null && _k !== void 0 ? _k : {});\n}\nexport const TEXT_INTERACTION_LOCKED_ERROR = 'TextInteraction state is locked by config (plugins.TextInteraction.locked)';\n//# sourceMappingURL=web-config.js.map","import { CapacitorException, WebPlugin } from '@capacitor/core';\nimport { readTextInteractionWebConfig, TEXT_INTERACTION_LOCKED_ERROR } from './web-config';\nexport class TextInteractionWeb extends WebPlugin {\n constructor() {\n var _a, _b;\n super();\n const config = readTextInteractionWebConfig();\n this.enabled = (_a = config.enabled) !== null && _a !== void 0 ? _a : true;\n this.locked = (_b = config.locked) !== null && _b !== void 0 ? _b : false;\n }\n async isEnabled() {\n return { enabled: this.enabled };\n }\n async toggle(_options) {\n if (this.locked) {\n throw new CapacitorException(TEXT_INTERACTION_LOCKED_ERROR);\n }\n throw this.unimplemented('TextInteraction.toggle is not available on web');\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin","CapacitorException"],"mappings":";;;;AACK,MAAC,eAAe,GAAGA,mBAAc,CAAC,iBAAiB,EAAE;AAC1D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,kBAAkB,EAAE,CAAC;AACtE,CAAC;;ACHD;AACA;AACA;AACO,SAAS,4BAA4B,GAAG;AAC/C,IAAI,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;AAC9C,IAAI,IAAI,OAAO,UAAU,KAAK,WAAW,EAAE;AAC3C,QAAQ,OAAO,EAAE;AACjB,IAAI;AACJ,IAAI,MAAM,YAAY,GAAG,UAAU;AACnC,IAAI,QAAQ,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,YAAY,CAAC,SAAS,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,MAAM,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,OAAO,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,eAAe,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,YAAY,CAAC,gBAAgB,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,OAAO,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,eAAe,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,YAAY,CAAC,iBAAiB,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,OAAO,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,eAAe,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,EAAE,GAAG,EAAE;AAClnB;AACO,MAAM,6BAA6B,GAAG,4EAA4E;;ACTlH,MAAM,kBAAkB,SAASC,cAAS,CAAC;AAClD,IAAI,WAAW,GAAG;AAClB,QAAQ,IAAI,EAAE,EAAE,EAAE;AAClB,QAAQ,KAAK,EAAE;AACf,QAAQ,MAAM,MAAM,GAAG,4BAA4B,EAAE;AACrD,QAAQ,IAAI,CAAC,OAAO,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,OAAO,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,EAAE,GAAG,IAAI;AAClF,QAAQ,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,MAAM,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,EAAE,GAAG,KAAK;AACjF,IAAI;AACJ,IAAI,MAAM,SAAS,GAAG;AACtB,QAAQ,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE;AACxC,IAAI;AACJ,IAAI,MAAM,MAAM,CAAC,QAAQ,EAAE;AAC3B,QAAQ,IAAI,IAAI,CAAC,MAAM,EAAE;AACzB,YAAY,MAAM,IAAIC,uBAAkB,CAAC,6BAA6B,CAAC;AACvE,QAAQ;AACR,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,gDAAgD,CAAC;AAClF,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;AACjC,IAAI;AACJ;;;;;;;"}
package/dist/plugin.js CHANGED
@@ -5,8 +5,34 @@ var capacitorTextInteraction = (function (exports, core) {
5
5
  web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.TextInteractionWeb()),
6
6
  });
7
7
 
8
+ /**
9
+ * Reads `plugins.TextInteraction` for the web implementation when embedded in the WebView.
10
+ */
11
+ function readTextInteractionWebConfig() {
12
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
13
+ if (typeof globalThis === 'undefined') {
14
+ return {};
15
+ }
16
+ const globalConfig = globalThis;
17
+ return ((_k = (_g = (_d = (_c = (_b = (_a = globalConfig.Capacitor) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.plugins) === null || _c === void 0 ? void 0 : _c.TextInteraction) !== null && _d !== void 0 ? _d : (_f = (_e = globalConfig.CAPACITOR_CONFIG) === null || _e === void 0 ? void 0 : _e.plugins) === null || _f === void 0 ? void 0 : _f.TextInteraction) !== null && _g !== void 0 ? _g : (_j = (_h = globalConfig.__capacitorConfig) === null || _h === void 0 ? void 0 : _h.plugins) === null || _j === void 0 ? void 0 : _j.TextInteraction) !== null && _k !== void 0 ? _k : {});
18
+ }
19
+ const TEXT_INTERACTION_LOCKED_ERROR = 'TextInteraction state is locked by config (plugins.TextInteraction.locked)';
20
+
8
21
  class TextInteractionWeb extends core.WebPlugin {
22
+ constructor() {
23
+ var _a, _b;
24
+ super();
25
+ const config = readTextInteractionWebConfig();
26
+ this.enabled = (_a = config.enabled) !== null && _a !== void 0 ? _a : true;
27
+ this.locked = (_b = config.locked) !== null && _b !== void 0 ? _b : false;
28
+ }
29
+ async isEnabled() {
30
+ return { enabled: this.enabled };
31
+ }
9
32
  async toggle(_options) {
33
+ if (this.locked) {
34
+ throw new core.CapacitorException(TEXT_INTERACTION_LOCKED_ERROR);
35
+ }
10
36
  throw this.unimplemented('TextInteraction.toggle is not available on web');
11
37
  }
12
38
  async getPluginVersion() {
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst TextInteraction = registerPlugin('TextInteraction', {\n web: () => import('./web').then((m) => new m.TextInteractionWeb()),\n});\nexport * from './definitions';\nexport { TextInteraction };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class TextInteractionWeb extends WebPlugin {\n async toggle(_options) {\n throw this.unimplemented('TextInteraction.toggle is not available on web');\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,eAAe,GAAGA,mBAAc,CAAC,iBAAiB,EAAE;IAC1D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,kBAAkB,EAAE,CAAC;IACtE,CAAC;;ICFM,MAAM,kBAAkB,SAASC,cAAS,CAAC;IAClD,IAAI,MAAM,MAAM,CAAC,QAAQ,EAAE;IAC3B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,gDAAgD,CAAC;IAClF,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;IACjC,IAAI;IACJ;;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web-config.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst TextInteraction = registerPlugin('TextInteraction', {\n web: () => import('./web').then((m) => new m.TextInteractionWeb()),\n});\nexport * from './definitions';\nexport { TextInteraction };\n//# sourceMappingURL=index.js.map","/**\n * Reads `plugins.TextInteraction` for the web implementation when embedded in the WebView.\n */\nexport function readTextInteractionWebConfig() {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;\n if (typeof globalThis === 'undefined') {\n return {};\n }\n const globalConfig = globalThis;\n return ((_k = (_g = (_d = (_c = (_b = (_a = globalConfig.Capacitor) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.plugins) === null || _c === void 0 ? void 0 : _c.TextInteraction) !== null && _d !== void 0 ? _d : (_f = (_e = globalConfig.CAPACITOR_CONFIG) === null || _e === void 0 ? void 0 : _e.plugins) === null || _f === void 0 ? void 0 : _f.TextInteraction) !== null && _g !== void 0 ? _g : (_j = (_h = globalConfig.__capacitorConfig) === null || _h === void 0 ? void 0 : _h.plugins) === null || _j === void 0 ? void 0 : _j.TextInteraction) !== null && _k !== void 0 ? _k : {});\n}\nexport const TEXT_INTERACTION_LOCKED_ERROR = 'TextInteraction state is locked by config (plugins.TextInteraction.locked)';\n//# sourceMappingURL=web-config.js.map","import { CapacitorException, WebPlugin } from '@capacitor/core';\nimport { readTextInteractionWebConfig, TEXT_INTERACTION_LOCKED_ERROR } from './web-config';\nexport class TextInteractionWeb extends WebPlugin {\n constructor() {\n var _a, _b;\n super();\n const config = readTextInteractionWebConfig();\n this.enabled = (_a = config.enabled) !== null && _a !== void 0 ? _a : true;\n this.locked = (_b = config.locked) !== null && _b !== void 0 ? _b : false;\n }\n async isEnabled() {\n return { enabled: this.enabled };\n }\n async toggle(_options) {\n if (this.locked) {\n throw new CapacitorException(TEXT_INTERACTION_LOCKED_ERROR);\n }\n throw this.unimplemented('TextInteraction.toggle is not available on web');\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin","CapacitorException"],"mappings":";;;AACK,UAAC,eAAe,GAAGA,mBAAc,CAAC,iBAAiB,EAAE;IAC1D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,kBAAkB,EAAE,CAAC;IACtE,CAAC;;ICHD;IACA;IACA;IACO,SAAS,4BAA4B,GAAG;IAC/C,IAAI,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;IAC9C,IAAI,IAAI,OAAO,UAAU,KAAK,WAAW,EAAE;IAC3C,QAAQ,OAAO,EAAE;IACjB,IAAI;IACJ,IAAI,MAAM,YAAY,GAAG,UAAU;IACnC,IAAI,QAAQ,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,YAAY,CAAC,SAAS,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,MAAM,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,OAAO,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,eAAe,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,YAAY,CAAC,gBAAgB,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,OAAO,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,eAAe,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,YAAY,CAAC,iBAAiB,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,OAAO,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,eAAe,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,EAAE,GAAG,EAAE;IAClnB;IACO,MAAM,6BAA6B,GAAG,4EAA4E;;ICTlH,MAAM,kBAAkB,SAASC,cAAS,CAAC;IAClD,IAAI,WAAW,GAAG;IAClB,QAAQ,IAAI,EAAE,EAAE,EAAE;IAClB,QAAQ,KAAK,EAAE;IACf,QAAQ,MAAM,MAAM,GAAG,4BAA4B,EAAE;IACrD,QAAQ,IAAI,CAAC,OAAO,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,OAAO,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,EAAE,GAAG,IAAI;IAClF,QAAQ,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,MAAM,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,EAAE,GAAG,KAAK;IACjF,IAAI;IACJ,IAAI,MAAM,SAAS,GAAG;IACtB,QAAQ,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE;IACxC,IAAI;IACJ,IAAI,MAAM,MAAM,CAAC,QAAQ,EAAE;IAC3B,QAAQ,IAAI,IAAI,CAAC,MAAM,EAAE;IACzB,YAAY,MAAM,IAAIC,uBAAkB,CAAC,6BAA6B,CAAC;IACvE,QAAQ;IACR,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,gDAAgD,CAAC;IAClF,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;IACjC,IAAI;IACJ;;;;;;;;;;;"}
@@ -2,13 +2,38 @@ import Foundation
2
2
  import WebKit
3
3
 
4
4
  @objc public class TextInteraction: NSObject {
5
- @objc public func toggle(_ enabled: Bool, webView: WKWebView?) -> Bool {
5
+ private var configuredEnabled: Bool = true
6
+
7
+ @objc public func setConfiguredEnabled(_ enabled: Bool) {
8
+ configuredEnabled = enabled
9
+ }
10
+
11
+ @objc public func applyConfiguredEnabled(webView: WKWebView?) -> Bool {
12
+ guard let webView else {
13
+ return false
14
+ }
15
+
16
+ return setEnabled(configuredEnabled, webView: webView)
17
+ }
18
+
19
+ @objc public func isEnabled(webView: WKWebView?) -> Bool {
20
+ if let webView {
21
+ return webView.configuration.preferences.isTextInteractionEnabled
22
+ }
23
+ return configuredEnabled
24
+ }
25
+
26
+ @objc public func setEnabled(_ enabled: Bool, webView: WKWebView?) -> Bool {
6
27
  guard let webView else {
7
28
  return false
8
29
  }
9
30
 
10
- // Ensure text interaction matches the requested state.
31
+ configuredEnabled = enabled
11
32
  webView.configuration.preferences.isTextInteractionEnabled = enabled
12
33
  return true
13
34
  }
35
+
36
+ @objc public func toggle(_ enabled: Bool, webView: WKWebView?) -> Bool {
37
+ return setEnabled(enabled, webView: webView)
38
+ }
14
39
  }
@@ -7,16 +7,35 @@ import Capacitor
7
7
  */
8
8
  @objc(TextInteractionPlugin)
9
9
  public class TextInteractionPlugin: CAPPlugin, CAPBridgedPlugin {
10
- private let pluginVersion: String = "8.0.42"
10
+ private let pluginVersion: String = "8.1.0"
11
11
  public let identifier = "TextInteractionPlugin"
12
12
  public let jsName = "TextInteraction"
13
13
  public let pluginMethods: [CAPPluginMethod] = [
14
14
  CAPPluginMethod(name: "toggle", returnType: CAPPluginReturnPromise),
15
+ CAPPluginMethod(name: "isEnabled", returnType: CAPPluginReturnPromise),
15
16
  CAPPluginMethod(name: "getPluginVersion", returnType: CAPPluginReturnPromise)
16
17
  ]
17
18
  private let implementation = TextInteraction()
19
+ private var locked = false
20
+
21
+ private static let lockedError = "TextInteraction state is locked by config (plugins.TextInteraction.locked)"
22
+
23
+ @objc override public func load() {
24
+ locked = getConfig().getBoolean("locked", false)
25
+ let enabled = getConfig().getBoolean("enabled", true)
26
+ implementation.setConfiguredEnabled(enabled)
27
+
28
+ DispatchQueue.main.async {
29
+ _ = self.implementation.applyConfiguredEnabled(webView: self.bridge?.webView)
30
+ }
31
+ }
18
32
 
19
33
  @objc func toggle(_ call: CAPPluginCall) {
34
+ if locked {
35
+ call.reject(TextInteractionPlugin.lockedError)
36
+ return
37
+ }
38
+
20
39
  let enabled = call.getBool("enabled") ?? false
21
40
 
22
41
  DispatchQueue.main.async {
@@ -27,6 +46,14 @@ public class TextInteractionPlugin: CAPPlugin, CAPBridgedPlugin {
27
46
  }
28
47
  }
29
48
 
49
+ @objc func isEnabled(_ call: CAPPluginCall) {
50
+ DispatchQueue.main.async {
51
+ call.resolve([
52
+ "enabled": self.implementation.isEnabled(webView: self.bridge?.webView)
53
+ ])
54
+ }
55
+ }
56
+
30
57
  @objc func getPluginVersion(_ call: CAPPluginCall) {
31
58
  call.resolve(["version": self.pluginVersion])
32
59
  }
@@ -3,6 +3,14 @@ import WebKit
3
3
  @testable import TextInteractionPlugin
4
4
 
5
5
  class TextInteractionTests: XCTestCase {
6
+ func testIsEnabledReflectsState() {
7
+ let implementation = TextInteraction()
8
+ XCTAssertTrue(implementation.isEnabled(webView: nil))
9
+
10
+ implementation.setConfiguredEnabled(false)
11
+ XCTAssertFalse(implementation.isEnabled(webView: nil))
12
+ }
13
+
6
14
  func testToggleEnablesTextInteraction() {
7
15
  let expectation = expectation(description: "Text interaction toggled")
8
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-textinteraction",
3
- "version": "8.0.42",
3
+ "version": "8.1.0",
4
4
  "description": "Toggle text interaction in Capacitor based iOS apps.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -56,6 +56,7 @@
56
56
  "changelog:ai": "node scripts/generate-ai-changelog.mjs"
57
57
  },
58
58
  "devDependencies": {
59
+ "@capacitor/cli": "^8.0.0",
59
60
  "@capacitor/android": "^8.0.0",
60
61
  "@capacitor/core": "^8.0.0",
61
62
  "@capacitor/docgen": "^0.3.1",