@atlaskit/editor-plugin-interaction 1.0.1

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/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # @atlaskit/editor-plugin-interaction
2
+
3
+ ## 1.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#140394](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/140394)
8
+ [`aa5fe04b853bf`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/aa5fe04b853bf) -
9
+ [ED-27253] Introduce interaction plugin to track first interaction on page
10
+ - Updated dependencies
package/LICENSE.md ADDED
@@ -0,0 +1,11 @@
1
+ Copyright 2023 Atlassian Pty Ltd
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
4
+ compliance with the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is
9
+ distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
10
+ implied. See the License for the specific language governing permissions and limitations under the
11
+ License.
package/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # Editor Plugin Interaction
2
+
3
+ Interaction plugin for @atlaskit/editor-core
4
+
5
+ **Note:** This component is designed for internal Atlassian development.
6
+ External contributors will be able to use this component but will not be able to submit issues.
7
+
8
+ ## Install
9
+ ---
10
+ - **Install** - *yarn add @atlaskit/editor-plugin-interaction*
11
+ - **npm** - [@atlaskit/editor-plugin-interaction](https://www.npmjs.com/package/@atlaskit/editor-plugin-interaction)
12
+ - **Source** - [Bitbucket](https://bitbucket.org/atlassian/atlassian-frontend/src/master/packages/editor/editor-plugin-interaction)
13
+ - **Bundle** - [unpkg.com](https://unpkg.com/@atlaskit/editor-plugin-interaction/dist/)
14
+
15
+ ## Usage
16
+ ---
17
+ **Internal use only**
18
+
19
+ @atlaskit/editor-plugin-interaction is intended for internal use by the @atlaskit/editor-core and as a plugin dependency of the Editor within your product.
20
+
21
+ Direct use of this component is not supported.
22
+
23
+ Please see [Atlaskit - Editor plugin interaction](https://atlaskit.atlassian.com/packages/editor/editor-plugin-interaction) for documentation and examples for this package.
24
+
25
+ ## Support
26
+ ---
27
+ For internal Atlassian, visit the slack channel [#help-editor](https://atlassian.slack.com/archives/CFG3PSQ9E) for support or visit [go/editor-help](https://go/editor-help) to submit a bug.
28
+ ## License
29
+ ---
30
+ Please see [Atlassian Frontend - License](https://hello.atlassian.net/wiki/spaces/AF/pages/2589099144/Documentation#License) for more licensing information.
@@ -0,0 +1,27 @@
1
+ {
2
+ "extends": "../../../../tsconfig.entry-points.confluence.json",
3
+ "compilerOptions": {
4
+ "target": "es5",
5
+ "composite": true,
6
+ "outDir": "../dist",
7
+ "rootDir": "../"
8
+ },
9
+ "include": [
10
+ "../src/**/*.ts",
11
+ "../src/**/*.tsx"
12
+ ],
13
+ "exclude": [
14
+ "../src/**/__tests__/*",
15
+ "../src/**/*.test.*",
16
+ "../src/**/test.*",
17
+ "../src/**/examples.*"
18
+ ],
19
+ "references": [
20
+ {
21
+ "path": "../../editor-common/afm-cc/tsconfig.json"
22
+ },
23
+ {
24
+ "path": "../../../design-system/tokens/afm-cc/tsconfig.json"
25
+ }
26
+ ]
27
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "extends": "../../../../tsconfig.entry-points.jira.json",
3
+ "compilerOptions": {
4
+ "target": "es5",
5
+ "outDir": "../../../../../tsDist/@atlaskit__editor-plugin-interaction/app",
6
+ "rootDir": "../",
7
+ "composite": true
8
+ },
9
+ "include": [
10
+ "../src/**/*.ts",
11
+ "../src/**/*.tsx"
12
+ ],
13
+ "exclude": [
14
+ "../src/**/__tests__/*",
15
+ "../src/**/*.test.*",
16
+ "../src/**/test.*",
17
+ "../src/**/examples.*"
18
+ ],
19
+ "references": [
20
+ {
21
+ "path": "../../editor-common/afm-jira/tsconfig.json"
22
+ },
23
+ {
24
+ "path": "../../../design-system/tokens/afm-jira/tsconfig.json"
25
+ }
26
+ ]
27
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "extends": "../../../../tsconfig.entry-points.post-office.json",
3
+ "compilerOptions": {
4
+ "target": "es5",
5
+ "outDir": "../../../../../post-office/tsDist/@atlaskit__editor-plugin-interaction/app",
6
+ "rootDir": "../",
7
+ "composite": true
8
+ },
9
+ "include": [
10
+ "../src/**/*.ts",
11
+ "../src/**/*.tsx"
12
+ ],
13
+ "exclude": [
14
+ "../src/**/__tests__/*",
15
+ "../src/**/*.test.*",
16
+ "../src/**/test.*",
17
+ "../src/**/examples.*"
18
+ ],
19
+ "references": [
20
+ {
21
+ "path": "../../editor-common/afm-post-office/tsconfig.json"
22
+ },
23
+ {
24
+ "path": "../../../design-system/tokens/afm-post-office/tsconfig.json"
25
+ }
26
+ ]
27
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "extends": "../tsconfig",
3
+ "compilerOptions": {
4
+ "target": "es5",
5
+ "paths": {}
6
+ },
7
+ "include": [
8
+ "../src/**/*.ts",
9
+ "../src/**/*.tsx"
10
+ ],
11
+ "exclude": [
12
+ "../src/**/__tests__/*",
13
+ "../src/**/*.test.*",
14
+ "../src/**/test.*",
15
+ "../src/**/examples.*"
16
+ ]
17
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "interactionPlugin", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _interactionPlugin.interactionPlugin;
10
+ }
11
+ });
12
+ var _interactionPlugin = require("./interactionPlugin");
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.interactionPlugin = void 0;
7
+ var _main = require("./pm-plugins/main");
8
+ var interactionPlugin = exports.interactionPlugin = function interactionPlugin(_ref) {
9
+ var api = _ref.api;
10
+ return {
11
+ name: 'interaction',
12
+ getSharedState: function getSharedState(editorState) {
13
+ var _key$getState;
14
+ if (!editorState) {
15
+ return {
16
+ hasHadInteraction: false
17
+ };
18
+ }
19
+ return {
20
+ hasHadInteraction: Boolean((_key$getState = _main.key.getState(editorState)) === null || _key$getState === void 0 ? void 0 : _key$getState.hasHadInteraction)
21
+ };
22
+ },
23
+ pmPlugins: function pmPlugins() {
24
+ return [{
25
+ name: 'interactionHandlerPlugin',
26
+ plugin: _main.createPlugin
27
+ }];
28
+ }
29
+ };
30
+ };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.key = exports.createPlugin = void 0;
8
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
9
+ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
10
+ var _state = require("@atlaskit/editor-prosemirror/state");
11
+ var key = exports.key = new _state.PluginKey('interactionPluginHandler');
12
+ var handleInteraction = function handleInteraction(view) {
13
+ var interactionState = key.getState(view.state);
14
+ if (!(interactionState !== null && interactionState !== void 0 && interactionState.hasHadInteraction)) {
15
+ view.dispatch(view.state.tr.setMeta(key, {
16
+ hasHadInteraction: true
17
+ }));
18
+ }
19
+ return false;
20
+ };
21
+ var createPlugin = exports.createPlugin = function createPlugin() {
22
+ return new _safePlugin.SafePlugin({
23
+ key: key,
24
+ state: {
25
+ init: function init() {
26
+ return {
27
+ hasHadInteraction: false
28
+ };
29
+ },
30
+ apply: function apply(tr, oldPluginState) {
31
+ var meta = tr.getMeta(key);
32
+ if ((0, _typeof2.default)(meta) === 'object') {
33
+ if (meta.hasHadInteraction !== oldPluginState.hasHadInteraction) {
34
+ return {
35
+ hasHadInteraction: meta.hasHadInteraction
36
+ };
37
+ }
38
+ }
39
+ return oldPluginState;
40
+ }
41
+ },
42
+ props: {
43
+ handleDOMEvents: {
44
+ mousedown: handleInteraction,
45
+ keyup: handleInteraction,
46
+ drop: handleInteraction
47
+ }
48
+ }
49
+ });
50
+ };
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,4 @@
1
+ /* eslint-disable @atlaskit/editor/no-re-export */
2
+ // Entry file in package.json
3
+
4
+ export { interactionPlugin } from './interactionPlugin';
@@ -0,0 +1,25 @@
1
+ import { createPlugin, key } from './pm-plugins/main';
2
+ export const interactionPlugin = ({
3
+ api
4
+ }) => {
5
+ return {
6
+ name: 'interaction',
7
+ getSharedState(editorState) {
8
+ var _key$getState;
9
+ if (!editorState) {
10
+ return {
11
+ hasHadInteraction: false
12
+ };
13
+ }
14
+ return {
15
+ hasHadInteraction: Boolean((_key$getState = key.getState(editorState)) === null || _key$getState === void 0 ? void 0 : _key$getState.hasHadInteraction)
16
+ };
17
+ },
18
+ pmPlugins() {
19
+ return [{
20
+ name: 'interactionHandlerPlugin',
21
+ plugin: createPlugin
22
+ }];
23
+ }
24
+ };
25
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,40 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
+ export const key = new PluginKey('interactionPluginHandler');
4
+ const handleInteraction = view => {
5
+ const interactionState = key.getState(view.state);
6
+ if (!(interactionState !== null && interactionState !== void 0 && interactionState.hasHadInteraction)) {
7
+ view.dispatch(view.state.tr.setMeta(key, {
8
+ hasHadInteraction: true
9
+ }));
10
+ }
11
+ return false;
12
+ };
13
+ export const createPlugin = () => new SafePlugin({
14
+ key,
15
+ state: {
16
+ init() {
17
+ return {
18
+ hasHadInteraction: false
19
+ };
20
+ },
21
+ apply(tr, oldPluginState) {
22
+ const meta = tr.getMeta(key);
23
+ if (typeof meta === 'object') {
24
+ if (meta.hasHadInteraction !== oldPluginState.hasHadInteraction) {
25
+ return {
26
+ hasHadInteraction: meta.hasHadInteraction
27
+ };
28
+ }
29
+ }
30
+ return oldPluginState;
31
+ }
32
+ },
33
+ props: {
34
+ handleDOMEvents: {
35
+ mousedown: handleInteraction,
36
+ keyup: handleInteraction,
37
+ drop: handleInteraction
38
+ }
39
+ }
40
+ });
File without changes
@@ -0,0 +1,4 @@
1
+ /* eslint-disable @atlaskit/editor/no-re-export */
2
+ // Entry file in package.json
3
+
4
+ export { interactionPlugin } from './interactionPlugin';
@@ -0,0 +1,24 @@
1
+ import { createPlugin, key } from './pm-plugins/main';
2
+ export var interactionPlugin = function interactionPlugin(_ref) {
3
+ var api = _ref.api;
4
+ return {
5
+ name: 'interaction',
6
+ getSharedState: function getSharedState(editorState) {
7
+ var _key$getState;
8
+ if (!editorState) {
9
+ return {
10
+ hasHadInteraction: false
11
+ };
12
+ }
13
+ return {
14
+ hasHadInteraction: Boolean((_key$getState = key.getState(editorState)) === null || _key$getState === void 0 ? void 0 : _key$getState.hasHadInteraction)
15
+ };
16
+ },
17
+ pmPlugins: function pmPlugins() {
18
+ return [{
19
+ name: 'interactionHandlerPlugin',
20
+ plugin: createPlugin
21
+ }];
22
+ }
23
+ };
24
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,43 @@
1
+ import _typeof from "@babel/runtime/helpers/typeof";
2
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
4
+ export var key = new PluginKey('interactionPluginHandler');
5
+ var handleInteraction = function handleInteraction(view) {
6
+ var interactionState = key.getState(view.state);
7
+ if (!(interactionState !== null && interactionState !== void 0 && interactionState.hasHadInteraction)) {
8
+ view.dispatch(view.state.tr.setMeta(key, {
9
+ hasHadInteraction: true
10
+ }));
11
+ }
12
+ return false;
13
+ };
14
+ export var createPlugin = function createPlugin() {
15
+ return new SafePlugin({
16
+ key: key,
17
+ state: {
18
+ init: function init() {
19
+ return {
20
+ hasHadInteraction: false
21
+ };
22
+ },
23
+ apply: function apply(tr, oldPluginState) {
24
+ var meta = tr.getMeta(key);
25
+ if (_typeof(meta) === 'object') {
26
+ if (meta.hasHadInteraction !== oldPluginState.hasHadInteraction) {
27
+ return {
28
+ hasHadInteraction: meta.hasHadInteraction
29
+ };
30
+ }
31
+ }
32
+ return oldPluginState;
33
+ }
34
+ },
35
+ props: {
36
+ handleDOMEvents: {
37
+ mousedown: handleInteraction,
38
+ keyup: handleInteraction,
39
+ drop: handleInteraction
40
+ }
41
+ }
42
+ });
43
+ };
File without changes
@@ -0,0 +1,3 @@
1
+ export { interactionPlugin } from './interactionPlugin';
2
+ export type { InteractionPlugin } from './interactionPluginType';
3
+ export type { InteractionState } from './types';
@@ -0,0 +1,2 @@
1
+ import { type InteractionPlugin } from './interactionPluginType';
2
+ export declare const interactionPlugin: InteractionPlugin;
@@ -0,0 +1,5 @@
1
+ import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
2
+ import { type InteractionState } from './types';
3
+ export type InteractionPlugin = NextEditorPlugin<'interaction', {
4
+ sharedState: InteractionState;
5
+ }>;
@@ -0,0 +1,5 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
+ import { type InteractionState } from '../types';
4
+ export declare const key: PluginKey<InteractionState>;
5
+ export declare const createPlugin: () => SafePlugin<InteractionState>;
@@ -0,0 +1,3 @@
1
+ export type InteractionState = {
2
+ hasHadInteraction: boolean;
3
+ };
@@ -0,0 +1,3 @@
1
+ export { interactionPlugin } from './interactionPlugin';
2
+ export type { InteractionPlugin } from './interactionPluginType';
3
+ export type { InteractionState } from './types';
@@ -0,0 +1,2 @@
1
+ import { type InteractionPlugin } from './interactionPluginType';
2
+ export declare const interactionPlugin: InteractionPlugin;
@@ -0,0 +1,5 @@
1
+ import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
2
+ import { type InteractionState } from './types';
3
+ export type InteractionPlugin = NextEditorPlugin<'interaction', {
4
+ sharedState: InteractionState;
5
+ }>;
@@ -0,0 +1,5 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
+ import { type InteractionState } from '../types';
4
+ export declare const key: PluginKey<InteractionState>;
5
+ export declare const createPlugin: () => SafePlugin<InteractionState>;
@@ -0,0 +1,3 @@
1
+ export type InteractionState = {
2
+ hasHadInteraction: boolean;
3
+ };
package/package.json ADDED
@@ -0,0 +1,79 @@
1
+ {
2
+ "name": "@atlaskit/editor-plugin-interaction",
3
+ "version": "1.0.1",
4
+ "description": "Interaction plugin for @atlaskit/editor-core",
5
+ "author": "Atlassian Pty Ltd",
6
+ "license": "Apache-2.0",
7
+ "publishConfig": {
8
+ "registry": "https://registry.npmjs.org/"
9
+ },
10
+ "atlassian": {
11
+ "team": "Editor: Jenga",
12
+ "singleton": true,
13
+ "runReact18": true
14
+ },
15
+ "repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
16
+ "main": "dist/cjs/index.js",
17
+ "module": "dist/esm/index.js",
18
+ "module:es2019": "dist/es2019/index.js",
19
+ "types": "dist/types/index.d.ts",
20
+ "sideEffects": false,
21
+ "atlaskit:src": "src/index.ts",
22
+ "af:exports": {
23
+ ".": "./src/index.ts"
24
+ },
25
+ "dependencies": {
26
+ "@atlaskit/editor-common": "^103.9.0",
27
+ "@atlaskit/editor-prosemirror": "7.0.0",
28
+ "@babel/runtime": "^7.0.0"
29
+ },
30
+ "peerDependencies": {
31
+ "@atlaskit/tokens": "^4.8.0",
32
+ "react": "^18.2.0",
33
+ "react-dom": "^18.2.0"
34
+ },
35
+ "devDependencies": {
36
+ "typescript": "~5.4.2"
37
+ },
38
+ "techstack": {
39
+ "@atlassian/frontend": {
40
+ "code-structure": [
41
+ "editor-plugin"
42
+ ],
43
+ "import-structure": [
44
+ "atlassian-conventions"
45
+ ],
46
+ "circular-dependencies": [
47
+ "file-and-folder-level"
48
+ ]
49
+ },
50
+ "@repo/internal": {
51
+ "dom-events": "use-bind-event-listener",
52
+ "analytics": [
53
+ "analytics-next"
54
+ ],
55
+ "design-tokens": [
56
+ "color"
57
+ ],
58
+ "theming": [
59
+ "react-context"
60
+ ],
61
+ "ui-components": [
62
+ "lite-mode"
63
+ ],
64
+ "deprecation": "no-deprecated-imports",
65
+ "styling": [
66
+ "emotion",
67
+ "compiled"
68
+ ],
69
+ "imports": [
70
+ "import-no-extraneous-disable-for-examples-and-docs"
71
+ ],
72
+ "stricter": {
73
+ "no-unused-dependencies": {
74
+ "checkDevDependencies": true
75
+ }
76
+ }
77
+ }
78
+ }
79
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "../../../tsconfig.json",
3
+ "include": [
4
+ "src/**/*.ts",
5
+ "src/**/*.tsx"
6
+ ],
7
+ "compilerOptions": {
8
+ }
9
+ }