@atlaskit/editor-plugin-editor-disabled 0.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/CHANGELOG.md ADDED
@@ -0,0 +1 @@
1
+ # @atlaskit/editor-plugin-editor-disabled
package/LICENSE.md ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2023 Atlassian Pty Ltd
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # EditorPluginEditorDisabled
2
+
3
+ Editor disabled plugin for @atlaskit/editor-core
4
+
5
+ ## Usage
6
+
7
+ `import { editorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';`
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "editorDisabledPlugin", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _plugin.editorDisabledPlugin;
10
+ }
11
+ });
12
+ var _plugin = require("./plugin");
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.editorDisabledPlugin = void 0;
7
+ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
8
+ var _utils = require("@atlaskit/editor-common/utils");
9
+ var _state = require("@atlaskit/editor-prosemirror/state");
10
+ var pluginKey = new _state.PluginKey('editorDisabledPlugin');
11
+ function reducer(_pluginState, meta) {
12
+ return meta;
13
+ }
14
+ var _pluginFactory = (0, _utils.pluginFactory)(pluginKey, reducer),
15
+ createPluginState = _pluginFactory.createPluginState,
16
+ getPluginState = _pluginFactory.getPluginState;
17
+
18
+ /*
19
+ Stores the state of the editor enabled/disabled for panel and floating
20
+ toolbar to subscribe to through <WithPluginState>. Otherwise the NodeViews
21
+ won't re-render when it changes.
22
+ */
23
+ function createPlugin(dispatch) {
24
+ return new _safePlugin.SafePlugin({
25
+ key: pluginKey,
26
+ state: createPluginState(dispatch, {
27
+ editorDisabled: false
28
+ }),
29
+ view: function view() {
30
+ return {
31
+ update: function update(view) {
32
+ if (getPluginState(view.state).editorDisabled !== !view.editable) {
33
+ var tr = view.state.tr.setMeta(pluginKey, {
34
+ editorDisabled: !view.editable
35
+ });
36
+ tr.setMeta('isLocal', true);
37
+ view.dispatch(tr);
38
+ }
39
+ }
40
+ };
41
+ }
42
+ });
43
+ }
44
+ var editorDisabledPlugin = function editorDisabledPlugin() {
45
+ return {
46
+ name: 'editorDisabled',
47
+ getSharedState: function getSharedState(editorState) {
48
+ if (!editorState) {
49
+ return {
50
+ editorDisabled: false
51
+ };
52
+ }
53
+ var pluginState = pluginKey.getState(editorState);
54
+ if (!pluginState) {
55
+ return {
56
+ editorDisabled: false
57
+ };
58
+ }
59
+ return pluginState;
60
+ },
61
+ pmPlugins: function pmPlugins() {
62
+ return [{
63
+ name: 'editorDisabled',
64
+ plugin: function plugin(_ref) {
65
+ var dispatch = _ref.dispatch;
66
+ return createPlugin(dispatch);
67
+ }
68
+ }];
69
+ }
70
+ };
71
+ };
72
+ exports.editorDisabledPlugin = editorDisabledPlugin;
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "@atlaskit/editor-plugin-editor-disabled",
3
+ "version": "0.1.0",
4
+ "sideEffects": false
5
+ }
@@ -0,0 +1 @@
1
+ export { editorDisabledPlugin } from './plugin';
@@ -0,0 +1,61 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { pluginFactory } from '@atlaskit/editor-common/utils';
3
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
4
+ const pluginKey = new PluginKey('editorDisabledPlugin');
5
+ function reducer(_pluginState, meta) {
6
+ return meta;
7
+ }
8
+ const {
9
+ createPluginState,
10
+ getPluginState
11
+ } = pluginFactory(pluginKey, reducer);
12
+
13
+ /*
14
+ Stores the state of the editor enabled/disabled for panel and floating
15
+ toolbar to subscribe to through <WithPluginState>. Otherwise the NodeViews
16
+ won't re-render when it changes.
17
+ */
18
+ function createPlugin(dispatch) {
19
+ return new SafePlugin({
20
+ key: pluginKey,
21
+ state: createPluginState(dispatch, {
22
+ editorDisabled: false
23
+ }),
24
+ view: () => {
25
+ return {
26
+ update(view) {
27
+ if (getPluginState(view.state).editorDisabled !== !view.editable) {
28
+ const tr = view.state.tr.setMeta(pluginKey, {
29
+ editorDisabled: !view.editable
30
+ });
31
+ tr.setMeta('isLocal', true);
32
+ view.dispatch(tr);
33
+ }
34
+ }
35
+ };
36
+ }
37
+ });
38
+ }
39
+ export const editorDisabledPlugin = () => ({
40
+ name: 'editorDisabled',
41
+ getSharedState(editorState) {
42
+ if (!editorState) {
43
+ return {
44
+ editorDisabled: false
45
+ };
46
+ }
47
+ const pluginState = pluginKey.getState(editorState);
48
+ if (!pluginState) {
49
+ return {
50
+ editorDisabled: false
51
+ };
52
+ }
53
+ return pluginState;
54
+ },
55
+ pmPlugins: () => [{
56
+ name: 'editorDisabled',
57
+ plugin: ({
58
+ dispatch
59
+ }) => createPlugin(dispatch)
60
+ }]
61
+ });
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "@atlaskit/editor-plugin-editor-disabled",
3
+ "version": "0.1.0",
4
+ "sideEffects": false
5
+ }
@@ -0,0 +1 @@
1
+ export { editorDisabledPlugin } from './plugin';
@@ -0,0 +1,65 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { pluginFactory } from '@atlaskit/editor-common/utils';
3
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
4
+ var pluginKey = new PluginKey('editorDisabledPlugin');
5
+ function reducer(_pluginState, meta) {
6
+ return meta;
7
+ }
8
+ var _pluginFactory = pluginFactory(pluginKey, reducer),
9
+ createPluginState = _pluginFactory.createPluginState,
10
+ getPluginState = _pluginFactory.getPluginState;
11
+
12
+ /*
13
+ Stores the state of the editor enabled/disabled for panel and floating
14
+ toolbar to subscribe to through <WithPluginState>. Otherwise the NodeViews
15
+ won't re-render when it changes.
16
+ */
17
+ function createPlugin(dispatch) {
18
+ return new SafePlugin({
19
+ key: pluginKey,
20
+ state: createPluginState(dispatch, {
21
+ editorDisabled: false
22
+ }),
23
+ view: function view() {
24
+ return {
25
+ update: function update(view) {
26
+ if (getPluginState(view.state).editorDisabled !== !view.editable) {
27
+ var tr = view.state.tr.setMeta(pluginKey, {
28
+ editorDisabled: !view.editable
29
+ });
30
+ tr.setMeta('isLocal', true);
31
+ view.dispatch(tr);
32
+ }
33
+ }
34
+ };
35
+ }
36
+ });
37
+ }
38
+ export var editorDisabledPlugin = function editorDisabledPlugin() {
39
+ return {
40
+ name: 'editorDisabled',
41
+ getSharedState: function getSharedState(editorState) {
42
+ if (!editorState) {
43
+ return {
44
+ editorDisabled: false
45
+ };
46
+ }
47
+ var pluginState = pluginKey.getState(editorState);
48
+ if (!pluginState) {
49
+ return {
50
+ editorDisabled: false
51
+ };
52
+ }
53
+ return pluginState;
54
+ },
55
+ pmPlugins: function pmPlugins() {
56
+ return [{
57
+ name: 'editorDisabled',
58
+ plugin: function plugin(_ref) {
59
+ var dispatch = _ref.dispatch;
60
+ return createPlugin(dispatch);
61
+ }
62
+ }];
63
+ }
64
+ };
65
+ };
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "@atlaskit/editor-plugin-editor-disabled",
3
+ "version": "0.1.0",
4
+ "sideEffects": false
5
+ }
@@ -0,0 +1,2 @@
1
+ export { editorDisabledPlugin } from './plugin';
2
+ export type { EditorDisabledPluginState, EditorDisabledPlugin } from './plugin';
@@ -0,0 +1,8 @@
1
+ import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
2
+ export type EditorDisabledPluginState = {
3
+ editorDisabled: boolean;
4
+ };
5
+ export type EditorDisabledPlugin = NextEditorPlugin<'editorDisabled', {
6
+ sharedState: EditorDisabledPluginState;
7
+ }>;
8
+ export declare const editorDisabledPlugin: EditorDisabledPlugin;
@@ -0,0 +1,2 @@
1
+ export { editorDisabledPlugin } from './plugin';
2
+ export type { EditorDisabledPluginState, EditorDisabledPlugin } from './plugin';
@@ -0,0 +1,8 @@
1
+ import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
2
+ export type EditorDisabledPluginState = {
3
+ editorDisabled: boolean;
4
+ };
5
+ export type EditorDisabledPlugin = NextEditorPlugin<'editorDisabled', {
6
+ sharedState: EditorDisabledPluginState;
7
+ }>;
8
+ export declare const editorDisabledPlugin: EditorDisabledPlugin;
package/package.json ADDED
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "@atlaskit/editor-plugin-editor-disabled",
3
+ "version": "0.1.0",
4
+ "description": "Editor disabled 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",
12
+ "singleton": true,
13
+ "releaseModel": "continuous"
14
+ },
15
+ "repository": "https://bitbucket.org/atlassian/atlassian-frontend",
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": "^74.20.0",
27
+ "@atlaskit/editor-prosemirror": "1.0.2",
28
+ "@babel/runtime": "^7.0.0"
29
+ },
30
+ "peerDependencies": {
31
+ "react": "^16.8.0"
32
+ },
33
+ "devDependencies": {
34
+ "@atlaskit/editor-test-helpers": "^18.10.0",
35
+ "@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
36
+ "@testing-library/react": "^12.1.5",
37
+ "react-dom": "^16.8.0",
38
+ "typescript": "~4.9.5",
39
+ "wait-for-expect": "^1.2.0"
40
+ },
41
+ "techstack": {
42
+ "@atlassian/frontend": {
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": [
65
+ "no-deprecated-imports"
66
+ ],
67
+ "styling": [
68
+ "static",
69
+ "emotion"
70
+ ]
71
+ }
72
+ },
73
+ "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0"
74
+ }
package/report.api.md ADDED
@@ -0,0 +1,51 @@
1
+ <!-- API Report Version: 2.3 -->
2
+
3
+ ## API Report File for "@atlaskit/editor-plugin-editor-disabled"
4
+
5
+ > Do not edit this file. This report is auto-generated using [API Extractor](https://api-extractor.com/).
6
+ > [Learn more about API reports](https://hello.atlassian.net/wiki/spaces/UR/pages/1825484529/Package+API+Reports)
7
+
8
+ ### Table of contents
9
+
10
+ - [Main Entry Types](#main-entry-types)
11
+ - [Peer Dependencies](#peer-dependencies)
12
+
13
+ ### Main Entry Types
14
+
15
+ <!--SECTION START: Main Entry Types-->
16
+
17
+ ```ts
18
+ import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
19
+
20
+ // @public (undocumented)
21
+ export type EditorDisabledPlugin = NextEditorPlugin<
22
+ 'editorDisabled',
23
+ {
24
+ sharedState: EditorDisabledPluginState;
25
+ }
26
+ >;
27
+
28
+ // @public (undocumented)
29
+ export const editorDisabledPlugin: EditorDisabledPlugin;
30
+
31
+ // @public (undocumented)
32
+ export type EditorDisabledPluginState = {
33
+ editorDisabled: boolean;
34
+ };
35
+
36
+ // (No @packageDocumentation comment for this package)
37
+ ```
38
+
39
+ <!--SECTION END: Main Entry Types-->
40
+
41
+ ### Peer Dependencies
42
+
43
+ <!--SECTION START: Peer Dependencies-->
44
+
45
+ ```json
46
+ {
47
+ "react": "^16.8.0"
48
+ }
49
+ ```
50
+
51
+ <!--SECTION END: Peer Dependencies-->
@@ -0,0 +1,24 @@
1
+ ## API Report File for "@atlaskit/editor-plugin-editor-disabled"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+
7
+ import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
8
+
9
+ // @public (undocumented)
10
+ export type EditorDisabledPlugin = NextEditorPlugin<'editorDisabled', {
11
+ sharedState: EditorDisabledPluginState;
12
+ }>;
13
+
14
+ // @public (undocumented)
15
+ export const editorDisabledPlugin: EditorDisabledPlugin;
16
+
17
+ // @public (undocumented)
18
+ export type EditorDisabledPluginState = {
19
+ editorDisabled: boolean;
20
+ };
21
+
22
+ // (No @packageDocumentation comment for this package)
23
+
24
+ ```