@capgo/capacitor-textinteraction 7.0.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/CapgoCapacitorTextinteraction.podspec +17 -0
- package/Package.swift +28 -0
- package/README.md +79 -0
- package/android/build.gradle +58 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/app/capgo/plugin/textinteraction/TextInteraction.java +11 -0
- package/android/src/main/java/app/capgo/plugin/textinteraction/TextInteractionPlugin.java +22 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +67 -0
- package/dist/esm/definitions.d.ts +24 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +5 -0
- package/dist/esm/web.js +7 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +21 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +24 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/TextInteractionPlugin/TextInteraction.swift +18 -0
- package/ios/Sources/TextInteractionPlugin/TextInteractionPlugin.swift +27 -0
- package/ios/Tests/TextInteractionPluginTests/TextInteractionPluginTests.swift +25 -0
- package/package.json +84 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = 'CapgoCapacitorTextinteraction'
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.license = package['license']
|
|
10
|
+
s.homepage = package['repository']['url']
|
|
11
|
+
s.author = package['author']
|
|
12
|
+
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
|
+
s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
+
s.ios.deployment_target = '14.0'
|
|
15
|
+
s.dependency 'Capacitor'
|
|
16
|
+
s.swift_version = '5.1'
|
|
17
|
+
end
|
package/Package.swift
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// swift-tools-version: 5.9
|
|
2
|
+
import PackageDescription
|
|
3
|
+
|
|
4
|
+
let package = Package(
|
|
5
|
+
name: "CapgoCapacitorTextinteraction",
|
|
6
|
+
platforms: [.iOS(.v14)],
|
|
7
|
+
products: [
|
|
8
|
+
.library(
|
|
9
|
+
name: "CapgoCapacitorTextinteraction",
|
|
10
|
+
targets: ["TextInteractionPlugin"])
|
|
11
|
+
],
|
|
12
|
+
dependencies: [
|
|
13
|
+
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.0.0")
|
|
14
|
+
],
|
|
15
|
+
targets: [
|
|
16
|
+
.target(
|
|
17
|
+
name: "TextInteractionPlugin",
|
|
18
|
+
dependencies: [
|
|
19
|
+
.product(name: "Capacitor", package: "capacitor-swift-pm"),
|
|
20
|
+
.product(name: "Cordova", package: "capacitor-swift-pm")
|
|
21
|
+
],
|
|
22
|
+
path: "ios/Sources/TextInteractionPlugin"),
|
|
23
|
+
.testTarget(
|
|
24
|
+
name: "TextInteractionPluginTests",
|
|
25
|
+
dependencies: ["TextInteractionPlugin"],
|
|
26
|
+
path: "ios/Tests/TextInteractionPluginTests")
|
|
27
|
+
]
|
|
28
|
+
)
|
package/README.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# @capgo/capacitor-textinteraction
|
|
2
|
+
<a href="https://capgo.app/"><img src='https://raw.githubusercontent.com/Cap-go/capgo/main/assets/capgo_banner.png' alt='Capgo - Instant updates for capacitor'/></a>
|
|
3
|
+
|
|
4
|
+
<div align="center">
|
|
5
|
+
<h2><a href="https://capgo.app/?ref=plugin"> ➡️ Get Instant updates for your App with Capgo</a></h2>
|
|
6
|
+
<h2><a href="https://capgo.app/consulting/?ref=plugin"> Missing a feature? We’ll build the plugin for you 💪</a></h2>
|
|
7
|
+
</div>
|
|
8
|
+
Toggle text interaction in Capacitor based iOS apps.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @capgo/capacitor-textinteraction
|
|
14
|
+
npx cap sync
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { TextInteraction } from '@capgo/capacitor-textinteraction';
|
|
21
|
+
|
|
22
|
+
// Disable the iOS magnifier lens while the WebView is visible
|
|
23
|
+
await TextInteraction.toggle({ enabled: false });
|
|
24
|
+
|
|
25
|
+
// Remember to re-enable before presenting any text inputs
|
|
26
|
+
await TextInteraction.toggle({ enabled: true });
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## API
|
|
30
|
+
|
|
31
|
+
<docgen-index>
|
|
32
|
+
|
|
33
|
+
* [`toggle(...)`](#toggle)
|
|
34
|
+
* [Interfaces](#interfaces)
|
|
35
|
+
|
|
36
|
+
</docgen-index>
|
|
37
|
+
|
|
38
|
+
<docgen-api>
|
|
39
|
+
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
40
|
+
|
|
41
|
+
### toggle(...)
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
toggle(options: TextInteractionOptions) => Promise<TextInteractionResult>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Toggle text interaction (selection) on the Capacitor WebView.
|
|
48
|
+
|
|
49
|
+
⚠️ Disabling text interaction prevents all text input controls from working while disabled.
|
|
50
|
+
Use it sparingly and re-enable when text entry is required.
|
|
51
|
+
|
|
52
|
+
iOS only.
|
|
53
|
+
|
|
54
|
+
| Param | Type |
|
|
55
|
+
| ------------- | ------------------------------------------------------------------------- |
|
|
56
|
+
| **`options`** | <code><a href="#textinteractionoptions">TextInteractionOptions</a></code> |
|
|
57
|
+
|
|
58
|
+
**Returns:** <code>Promise<<a href="#textinteractionresult">TextInteractionResult</a>></code>
|
|
59
|
+
|
|
60
|
+
--------------------
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
### Interfaces
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
#### TextInteractionResult
|
|
67
|
+
|
|
68
|
+
| Prop | Type | Description |
|
|
69
|
+
| ------------- | -------------------- | ------------------------------------------------------------------------------------------------ |
|
|
70
|
+
| **`success`** | <code>boolean</code> | `true` when the platform supports toggling text interaction (iOS >= 14.5), otherwise `false`. |
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
#### TextInteractionOptions
|
|
74
|
+
|
|
75
|
+
| Prop | Type | Description |
|
|
76
|
+
| ------------- | -------------------- | -------------------------------------------------------------------------------------------------------------------- |
|
|
77
|
+
| **`enabled`** | <code>boolean</code> | Whether text interaction should be enabled or disabled. Disabling hides the magnifier lens reintroduced with iOS 15. |
|
|
78
|
+
|
|
79
|
+
</docgen-api>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
ext {
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.0'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.2.1'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.6.1'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
buildscript {
|
|
9
|
+
repositories {
|
|
10
|
+
google()
|
|
11
|
+
mavenCentral()
|
|
12
|
+
}
|
|
13
|
+
dependencies {
|
|
14
|
+
classpath 'com.android.tools.build:gradle:8.7.2'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
apply plugin: 'com.android.library'
|
|
19
|
+
|
|
20
|
+
android {
|
|
21
|
+
namespace "app.capgo.plugin.textinteraction"
|
|
22
|
+
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
|
|
23
|
+
defaultConfig {
|
|
24
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
|
|
25
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 35
|
|
26
|
+
versionCode 1
|
|
27
|
+
versionName "1.0"
|
|
28
|
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
29
|
+
}
|
|
30
|
+
buildTypes {
|
|
31
|
+
release {
|
|
32
|
+
minifyEnabled false
|
|
33
|
+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
lintOptions {
|
|
37
|
+
abortOnError false
|
|
38
|
+
}
|
|
39
|
+
compileOptions {
|
|
40
|
+
sourceCompatibility JavaVersion.VERSION_21
|
|
41
|
+
targetCompatibility JavaVersion.VERSION_21
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
repositories {
|
|
46
|
+
google()
|
|
47
|
+
mavenCentral()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
dependencies {
|
|
52
|
+
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
53
|
+
implementation project(':capacitor-android')
|
|
54
|
+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
55
|
+
testImplementation "junit:junit:$junitVersion"
|
|
56
|
+
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
57
|
+
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
58
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
package app.capgo.plugin.textinteraction;
|
|
2
|
+
|
|
3
|
+
import com.getcapacitor.Logger;
|
|
4
|
+
|
|
5
|
+
public class TextInteraction {
|
|
6
|
+
|
|
7
|
+
public boolean toggle(boolean enabled) {
|
|
8
|
+
Logger.info("TextInteraction", "toggle called on Android with enabled=" + enabled + ". This platform is not supported.");
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
package app.capgo.plugin.textinteraction;
|
|
2
|
+
|
|
3
|
+
import com.getcapacitor.JSObject;
|
|
4
|
+
import com.getcapacitor.Plugin;
|
|
5
|
+
import com.getcapacitor.PluginCall;
|
|
6
|
+
import com.getcapacitor.PluginMethod;
|
|
7
|
+
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
8
|
+
|
|
9
|
+
@CapacitorPlugin(name = "TextInteraction")
|
|
10
|
+
public class TextInteractionPlugin extends Plugin {
|
|
11
|
+
|
|
12
|
+
private TextInteraction implementation = new TextInteraction();
|
|
13
|
+
|
|
14
|
+
@PluginMethod
|
|
15
|
+
public void toggle(PluginCall call) {
|
|
16
|
+
boolean enabled = call.getBoolean("enabled", false);
|
|
17
|
+
|
|
18
|
+
JSObject ret = new JSObject();
|
|
19
|
+
ret.put("success", implementation.toggle(enabled));
|
|
20
|
+
call.resolve(ret);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
File without changes
|
package/dist/docs.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"api": {
|
|
3
|
+
"name": "TextInteractionPlugin",
|
|
4
|
+
"slug": "textinteractionplugin",
|
|
5
|
+
"docs": "",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"methods": [
|
|
8
|
+
{
|
|
9
|
+
"name": "toggle",
|
|
10
|
+
"signature": "(options: TextInteractionOptions) => Promise<TextInteractionResult>",
|
|
11
|
+
"parameters": [
|
|
12
|
+
{
|
|
13
|
+
"name": "options",
|
|
14
|
+
"docs": "",
|
|
15
|
+
"type": "TextInteractionOptions"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"returns": "Promise<TextInteractionResult>",
|
|
19
|
+
"tags": [],
|
|
20
|
+
"docs": "Toggle text interaction (selection) on the Capacitor WebView.\n\n⚠️ Disabling text interaction prevents all text input controls from working while disabled.\nUse it sparingly and re-enable when text entry is required.\n\niOS only.",
|
|
21
|
+
"complexTypes": [
|
|
22
|
+
"TextInteractionResult",
|
|
23
|
+
"TextInteractionOptions"
|
|
24
|
+
],
|
|
25
|
+
"slug": "toggle"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"properties": []
|
|
29
|
+
},
|
|
30
|
+
"interfaces": [
|
|
31
|
+
{
|
|
32
|
+
"name": "TextInteractionResult",
|
|
33
|
+
"slug": "textinteractionresult",
|
|
34
|
+
"docs": "",
|
|
35
|
+
"tags": [],
|
|
36
|
+
"methods": [],
|
|
37
|
+
"properties": [
|
|
38
|
+
{
|
|
39
|
+
"name": "success",
|
|
40
|
+
"tags": [],
|
|
41
|
+
"docs": "`true` when the platform supports toggling text interaction (iOS >= 14.5), otherwise `false`.",
|
|
42
|
+
"complexTypes": [],
|
|
43
|
+
"type": "boolean"
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"name": "TextInteractionOptions",
|
|
49
|
+
"slug": "textinteractionoptions",
|
|
50
|
+
"docs": "",
|
|
51
|
+
"tags": [],
|
|
52
|
+
"methods": [],
|
|
53
|
+
"properties": [
|
|
54
|
+
{
|
|
55
|
+
"name": "enabled",
|
|
56
|
+
"tags": [],
|
|
57
|
+
"docs": "Whether text interaction should be enabled or disabled. Disabling hides the\nmagnifier lens reintroduced with iOS 15.",
|
|
58
|
+
"complexTypes": [],
|
|
59
|
+
"type": "boolean"
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
"enums": [],
|
|
65
|
+
"typeAliases": [],
|
|
66
|
+
"pluginConfigs": []
|
|
67
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface TextInteractionPlugin {
|
|
2
|
+
/**
|
|
3
|
+
* Toggle text interaction (selection) on the Capacitor WebView.
|
|
4
|
+
*
|
|
5
|
+
* ⚠️ Disabling text interaction prevents all text input controls from working while disabled.
|
|
6
|
+
* Use it sparingly and re-enable when text entry is required.
|
|
7
|
+
*
|
|
8
|
+
* iOS only.
|
|
9
|
+
*/
|
|
10
|
+
toggle(options: TextInteractionOptions): Promise<TextInteractionResult>;
|
|
11
|
+
}
|
|
12
|
+
export interface TextInteractionOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Whether text interaction should be enabled or disabled. Disabling hides the
|
|
15
|
+
* magnifier lens reintroduced with iOS 15.
|
|
16
|
+
*/
|
|
17
|
+
enabled: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface TextInteractionResult {
|
|
20
|
+
/**
|
|
21
|
+
* `true` when the platform supports toggling text interaction (iOS >= 14.5), otherwise `false`.
|
|
22
|
+
*/
|
|
23
|
+
success: boolean;
|
|
24
|
+
}
|
|
@@ -0,0 +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\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"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { registerPlugin } from '@capacitor/core';
|
|
2
|
+
const TextInteraction = registerPlugin('TextInteraction', {
|
|
3
|
+
web: () => import('./web').then((m) => new m.TextInteractionWeb()),
|
|
4
|
+
});
|
|
5
|
+
export * from './definitions';
|
|
6
|
+
export { TextInteraction };
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,eAAe,GAAG,cAAc,CAAwB,iBAAiB,EAAE;IAC/E,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,kBAAkB,EAAE,CAAC;CACnE,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { TextInteractionPlugin } from './definitions';\n\nconst TextInteraction = registerPlugin<TextInteractionPlugin>('TextInteraction', {\n web: () => import('./web').then((m) => new m.TextInteractionWeb()),\n});\n\nexport * from './definitions';\nexport { TextInteraction };\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
import type { TextInteractionPlugin, TextInteractionOptions, TextInteractionResult } from './definitions';
|
|
3
|
+
export declare class TextInteractionWeb extends WebPlugin implements TextInteractionPlugin {
|
|
4
|
+
toggle(_options: TextInteractionOptions): Promise<TextInteractionResult>;
|
|
5
|
+
}
|
package/dist/esm/web.js
ADDED
|
@@ -0,0 +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;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"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@capacitor/core');
|
|
4
|
+
|
|
5
|
+
const TextInteraction = core.registerPlugin('TextInteraction', {
|
|
6
|
+
web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.TextInteractionWeb()),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
class TextInteractionWeb extends core.WebPlugin {
|
|
10
|
+
async toggle(_options) {
|
|
11
|
+
throw this.unimplemented('TextInteraction.toggle is not available on web');
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
16
|
+
__proto__: null,
|
|
17
|
+
TextInteractionWeb: TextInteractionWeb
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
exports.TextInteraction = TextInteraction;
|
|
21
|
+
//# sourceMappingURL=plugin.cjs.js.map
|
|
@@ -0,0 +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}\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;;;;;;;;;"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var capacitorTextInteraction = (function (exports, core) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const TextInteraction = core.registerPlugin('TextInteraction', {
|
|
5
|
+
web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.TextInteractionWeb()),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
class TextInteractionWeb extends core.WebPlugin {
|
|
9
|
+
async toggle(_options) {
|
|
10
|
+
throw this.unimplemented('TextInteraction.toggle is not available on web');
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
15
|
+
__proto__: null,
|
|
16
|
+
TextInteractionWeb: TextInteractionWeb
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
exports.TextInteraction = TextInteraction;
|
|
20
|
+
|
|
21
|
+
return exports;
|
|
22
|
+
|
|
23
|
+
})({}, capacitorExports);
|
|
24
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +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}\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;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import WebKit
|
|
3
|
+
|
|
4
|
+
@objc public class TextInteraction: NSObject {
|
|
5
|
+
@objc public func toggle(_ enabled: Bool, webView: WKWebView?) -> Bool {
|
|
6
|
+
guard #available(iOS 14.5, *) else {
|
|
7
|
+
return false
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
guard let webView else {
|
|
11
|
+
return false
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Ensure text interaction matches the requested state.
|
|
15
|
+
webView.configuration.preferences.isTextInteractionEnabled = enabled
|
|
16
|
+
return true
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Please read the Capacitor iOS Plugin Development Guide
|
|
6
|
+
* here: https://capacitorjs.com/docs/plugins/ios
|
|
7
|
+
*/
|
|
8
|
+
@objc(TextInteractionPlugin)
|
|
9
|
+
public class TextInteractionPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
10
|
+
public let identifier = "TextInteractionPlugin"
|
|
11
|
+
public let jsName = "TextInteraction"
|
|
12
|
+
public let pluginMethods: [CAPPluginMethod] = [
|
|
13
|
+
CAPPluginMethod(name: "toggle", returnType: CAPPluginReturnPromise)
|
|
14
|
+
]
|
|
15
|
+
private let implementation = TextInteraction()
|
|
16
|
+
|
|
17
|
+
@objc func toggle(_ call: CAPPluginCall) {
|
|
18
|
+
let enabled = call.getBool("enabled") ?? false
|
|
19
|
+
|
|
20
|
+
DispatchQueue.main.async {
|
|
21
|
+
let success = self.implementation.toggle(enabled, webView: self.bridge?.webView)
|
|
22
|
+
call.resolve([
|
|
23
|
+
"success": success
|
|
24
|
+
])
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import XCTest
|
|
2
|
+
import WebKit
|
|
3
|
+
@testable import TextInteractionPlugin
|
|
4
|
+
|
|
5
|
+
class TextInteractionTests: XCTestCase {
|
|
6
|
+
func testToggleEnablesTextInteraction() {
|
|
7
|
+
guard #available(iOS 14.5, *) else {
|
|
8
|
+
return
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
let expectation = expectation(description: "Text interaction toggled")
|
|
12
|
+
|
|
13
|
+
DispatchQueue.main.async {
|
|
14
|
+
let implementation = TextInteraction()
|
|
15
|
+
let webView = WKWebView()
|
|
16
|
+
let success = implementation.toggle(true, webView: webView)
|
|
17
|
+
|
|
18
|
+
XCTAssertTrue(success)
|
|
19
|
+
XCTAssertTrue(webView.configuration.preferences.isTextInteractionEnabled)
|
|
20
|
+
expectation.fulfill()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
wait(for: [expectation], timeout: 1.0)
|
|
24
|
+
}
|
|
25
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@capgo/capacitor-textinteraction",
|
|
3
|
+
"version": "7.0.0",
|
|
4
|
+
"description": "Toggle text interaction in Capacitor based iOS apps.",
|
|
5
|
+
"main": "dist/plugin.cjs.js",
|
|
6
|
+
"module": "dist/esm/index.js",
|
|
7
|
+
"types": "dist/esm/index.d.ts",
|
|
8
|
+
"unpkg": "dist/plugin.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"android/src/main/",
|
|
11
|
+
"android/build.gradle",
|
|
12
|
+
"dist/",
|
|
13
|
+
"ios/Sources",
|
|
14
|
+
"ios/Tests",
|
|
15
|
+
"Package.swift",
|
|
16
|
+
"CapgoCapacitorTextinteraction.podspec"
|
|
17
|
+
],
|
|
18
|
+
"author": "Martin Donadieu <martin@capgo.app>",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/Cap-go/capacitor-textinteraction.git"
|
|
23
|
+
},
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/Cap-go/capacitor-textinteraction/issues"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"capacitor",
|
|
29
|
+
"plugin",
|
|
30
|
+
"native",
|
|
31
|
+
"ios",
|
|
32
|
+
"text",
|
|
33
|
+
"interaction",
|
|
34
|
+
"keyboard"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
|
|
38
|
+
"verify:ios": "xcodebuild -scheme CapgoCapacitorTextinteraction -destination generic/platform=iOS",
|
|
39
|
+
"verify:android": "cd android && ./gradlew clean build test && cd ..",
|
|
40
|
+
"verify:web": "npm run build",
|
|
41
|
+
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
|
|
42
|
+
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
|
|
43
|
+
"eslint": "eslint . --ext ts",
|
|
44
|
+
"prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
|
|
45
|
+
"swiftlint": "node-swiftlint",
|
|
46
|
+
"docgen": "docgen --api TextInteractionPlugin --output-readme README.md --output-json dist/docs.json",
|
|
47
|
+
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
|
|
48
|
+
"clean": "rimraf ./dist",
|
|
49
|
+
"watch": "tsc --watch",
|
|
50
|
+
"prepublishOnly": "npm run build"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@capacitor/android": "^7.0.0",
|
|
54
|
+
"@capacitor/core": "^7.0.0",
|
|
55
|
+
"@capacitor/docgen": "^0.3.0",
|
|
56
|
+
"@capacitor/ios": "^7.0.0",
|
|
57
|
+
"@ionic/eslint-config": "^0.4.0",
|
|
58
|
+
"@ionic/prettier-config": "^4.0.0",
|
|
59
|
+
"@ionic/swiftlint-config": "^2.0.0",
|
|
60
|
+
"eslint": "^8.57.0",
|
|
61
|
+
"prettier": "^3.4.2",
|
|
62
|
+
"prettier-plugin-java": "^2.6.6",
|
|
63
|
+
"rimraf": "^6.0.1",
|
|
64
|
+
"rollup": "^4.30.1",
|
|
65
|
+
"swiftlint": "^2.0.0",
|
|
66
|
+
"typescript": "~4.1.5"
|
|
67
|
+
},
|
|
68
|
+
"peerDependencies": {
|
|
69
|
+
"@capacitor/core": ">=7.0.0"
|
|
70
|
+
},
|
|
71
|
+
"prettier": "@ionic/prettier-config",
|
|
72
|
+
"swiftlint": "@ionic/swiftlint-config",
|
|
73
|
+
"eslintConfig": {
|
|
74
|
+
"extends": "@ionic/eslint-config/recommended"
|
|
75
|
+
},
|
|
76
|
+
"capacitor": {
|
|
77
|
+
"ios": {
|
|
78
|
+
"src": "ios"
|
|
79
|
+
},
|
|
80
|
+
"android": {
|
|
81
|
+
"src": "android"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|