@atlaskit/editor-plugin-guideline 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-guideline
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,9 @@
1
+ # EditorPluginGuideline
2
+
3
+ guideline plugin for @atlaskit/editor-core
4
+
5
+ ## Usage
6
+
7
+ `import EditorPluginGuideline from '@atlaskit/editor-plugin-guideline';`
8
+
9
+ Detailed docs and example usage can be found [here](https://atlaskit.atlassian.com/packages/editor/editor-plugin-guideline).
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "guidelinePlugin", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _plugin.guidelinePlugin;
10
+ }
11
+ });
12
+ var _plugin = require("./plugin");
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.guidelinePlugin = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _prosemirrorState = require("prosemirror-state");
10
+ var _hooks = require("@atlaskit/editor-common/hooks");
11
+ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
12
+ var key = new _prosemirrorState.PluginKey('guidelinePlugin');
13
+ var displayGuideline = function displayGuideline(_view) {};
14
+ var EMPTY_STATE = {
15
+ guidelines: []
16
+ };
17
+ var guidelinePMPlugin = new _safePlugin.SafePlugin({
18
+ key: key,
19
+ state: {
20
+ init: function init() {
21
+ return EMPTY_STATE;
22
+ },
23
+ apply: function apply(tr, currentPluginState) {
24
+ var nextPluginState = tr.getMeta(key);
25
+ if (nextPluginState) {
26
+ return nextPluginState;
27
+ }
28
+ return currentPluginState;
29
+ }
30
+ }
31
+ });
32
+ var ContentComponent = function ContentComponent(_ref) {
33
+ var api = _ref.api,
34
+ editorView = _ref.editorView,
35
+ options = _ref.options;
36
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['width', 'guideline']),
37
+ widthState = _useSharedPluginState.widthState,
38
+ guidelineState = _useSharedPluginState.guidelineState;
39
+ if (!guidelineState || !widthState) {
40
+ return null;
41
+ }
42
+ return /*#__PURE__*/_react.default.createElement("div", null);
43
+ };
44
+ var guidelinePlugin = function guidelinePlugin(options, api) {
45
+ return {
46
+ name: 'guideline',
47
+ getSharedState: function getSharedState(editorState) {
48
+ if (!editorState) {
49
+ return null;
50
+ }
51
+ return key.getState(editorState);
52
+ },
53
+ actions: {
54
+ displayGuideline: displayGuideline
55
+ },
56
+ pmPlugins: function pmPlugins() {
57
+ return [{
58
+ name: 'guideline',
59
+ plugin: function plugin() {
60
+ return guidelinePMPlugin;
61
+ }
62
+ }];
63
+ },
64
+ contentComponent: function contentComponent(_ref2) {
65
+ var editorView = _ref2.editorView;
66
+ return /*#__PURE__*/_react.default.createElement(ContentComponent, {
67
+ editorView: editorView,
68
+ options: options,
69
+ api: api
70
+ });
71
+ }
72
+ };
73
+ };
74
+ exports.guidelinePlugin = guidelinePlugin;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "@atlaskit/editor-plugin-guideline",
3
+ "version": "0.1.0",
4
+ "sideEffects": false
5
+ }
@@ -0,0 +1 @@
1
+ export { guidelinePlugin } from './plugin';
@@ -0,0 +1,63 @@
1
+ import React from 'react';
2
+ import { PluginKey } from 'prosemirror-state';
3
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
5
+ const key = new PluginKey('guidelinePlugin');
6
+ const displayGuideline = _view => {};
7
+ const EMPTY_STATE = {
8
+ guidelines: []
9
+ };
10
+ const guidelinePMPlugin = new SafePlugin({
11
+ key,
12
+ state: {
13
+ init() {
14
+ return EMPTY_STATE;
15
+ },
16
+ apply(tr, currentPluginState) {
17
+ const nextPluginState = tr.getMeta(key);
18
+ if (nextPluginState) {
19
+ return nextPluginState;
20
+ }
21
+ return currentPluginState;
22
+ }
23
+ }
24
+ });
25
+ const ContentComponent = ({
26
+ api,
27
+ editorView,
28
+ options
29
+ }) => {
30
+ const {
31
+ widthState,
32
+ guidelineState
33
+ } = useSharedPluginState(api, ['width', 'guideline']);
34
+ if (!guidelineState || !widthState) {
35
+ return null;
36
+ }
37
+ return /*#__PURE__*/React.createElement("div", null);
38
+ };
39
+ export const guidelinePlugin = (options, api) => ({
40
+ name: 'guideline',
41
+ getSharedState(editorState) {
42
+ if (!editorState) {
43
+ return null;
44
+ }
45
+ return key.getState(editorState);
46
+ },
47
+ actions: {
48
+ displayGuideline: displayGuideline
49
+ },
50
+ pmPlugins() {
51
+ return [{
52
+ name: 'guideline',
53
+ plugin: () => guidelinePMPlugin
54
+ }];
55
+ },
56
+ contentComponent: ({
57
+ editorView
58
+ }) => /*#__PURE__*/React.createElement(ContentComponent, {
59
+ editorView: editorView,
60
+ options: options,
61
+ api: api
62
+ })
63
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "@atlaskit/editor-plugin-guideline",
3
+ "version": "0.1.0",
4
+ "sideEffects": false
5
+ }
@@ -0,0 +1 @@
1
+ export { guidelinePlugin } from './plugin';
@@ -0,0 +1,66 @@
1
+ import React from 'react';
2
+ import { PluginKey } from 'prosemirror-state';
3
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
5
+ var key = new PluginKey('guidelinePlugin');
6
+ var displayGuideline = function displayGuideline(_view) {};
7
+ var EMPTY_STATE = {
8
+ guidelines: []
9
+ };
10
+ var guidelinePMPlugin = new SafePlugin({
11
+ key: key,
12
+ state: {
13
+ init: function init() {
14
+ return EMPTY_STATE;
15
+ },
16
+ apply: function apply(tr, currentPluginState) {
17
+ var nextPluginState = tr.getMeta(key);
18
+ if (nextPluginState) {
19
+ return nextPluginState;
20
+ }
21
+ return currentPluginState;
22
+ }
23
+ }
24
+ });
25
+ var ContentComponent = function ContentComponent(_ref) {
26
+ var api = _ref.api,
27
+ editorView = _ref.editorView,
28
+ options = _ref.options;
29
+ var _useSharedPluginState = useSharedPluginState(api, ['width', 'guideline']),
30
+ widthState = _useSharedPluginState.widthState,
31
+ guidelineState = _useSharedPluginState.guidelineState;
32
+ if (!guidelineState || !widthState) {
33
+ return null;
34
+ }
35
+ return /*#__PURE__*/React.createElement("div", null);
36
+ };
37
+ export var guidelinePlugin = function guidelinePlugin(options, api) {
38
+ return {
39
+ name: 'guideline',
40
+ getSharedState: function getSharedState(editorState) {
41
+ if (!editorState) {
42
+ return null;
43
+ }
44
+ return key.getState(editorState);
45
+ },
46
+ actions: {
47
+ displayGuideline: displayGuideline
48
+ },
49
+ pmPlugins: function pmPlugins() {
50
+ return [{
51
+ name: 'guideline',
52
+ plugin: function plugin() {
53
+ return guidelinePMPlugin;
54
+ }
55
+ }];
56
+ },
57
+ contentComponent: function contentComponent(_ref2) {
58
+ var editorView = _ref2.editorView;
59
+ return /*#__PURE__*/React.createElement(ContentComponent, {
60
+ editorView: editorView,
61
+ options: options,
62
+ api: api
63
+ });
64
+ }
65
+ };
66
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "@atlaskit/editor-plugin-guideline",
3
+ "version": "0.1.0",
4
+ "sideEffects": false
5
+ }
@@ -0,0 +1 @@
1
+ export { guidelinePlugin } from './plugin';
@@ -0,0 +1,10 @@
1
+ import { NextEditorPlugin } from '@atlaskit/editor-common/types';
2
+ import type { widthPlugin } from '@atlaskit/editor-plugin-width';
3
+ import { DisplayGuideline, GuidelinePluginState } from './types';
4
+ export declare const guidelinePlugin: NextEditorPlugin<'guideline', {
5
+ dependencies: [typeof widthPlugin];
6
+ sharedState: GuidelinePluginState | null;
7
+ actions: {
8
+ displayGuideline: DisplayGuideline;
9
+ };
10
+ }>;
@@ -0,0 +1,15 @@
1
+ import { EditorView } from 'prosemirror-view';
2
+ type Guideline = {
3
+ key?: string;
4
+ active?: boolean;
5
+ show?: boolean;
6
+ style?: 'dashed' | 'solid';
7
+ color?: string;
8
+ };
9
+ type GuidelinePluginState = {
10
+ guidelines: Guideline[];
11
+ };
12
+ interface GuidelinePluginOptions {
13
+ }
14
+ type DisplayGuideline = (view: EditorView) => void;
15
+ export type { GuidelinePluginState, GuidelinePluginOptions, Guideline, DisplayGuideline, };
@@ -0,0 +1 @@
1
+ export { guidelinePlugin } from './plugin';
@@ -0,0 +1,12 @@
1
+ import { NextEditorPlugin } from '@atlaskit/editor-common/types';
2
+ import type { widthPlugin } from '@atlaskit/editor-plugin-width';
3
+ import { DisplayGuideline, GuidelinePluginState } from './types';
4
+ export declare const guidelinePlugin: NextEditorPlugin<'guideline', {
5
+ dependencies: [
6
+ typeof widthPlugin
7
+ ];
8
+ sharedState: GuidelinePluginState | null;
9
+ actions: {
10
+ displayGuideline: DisplayGuideline;
11
+ };
12
+ }>;
@@ -0,0 +1,15 @@
1
+ import { EditorView } from 'prosemirror-view';
2
+ type Guideline = {
3
+ key?: string;
4
+ active?: boolean;
5
+ show?: boolean;
6
+ style?: 'dashed' | 'solid';
7
+ color?: string;
8
+ };
9
+ type GuidelinePluginState = {
10
+ guidelines: Guideline[];
11
+ };
12
+ interface GuidelinePluginOptions {
13
+ }
14
+ type DisplayGuideline = (view: EditorView) => void;
15
+ export type { GuidelinePluginState, GuidelinePluginOptions, Guideline, DisplayGuideline, };
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "@atlaskit/editor-plugin-guideline",
3
+ "version": "0.1.0",
4
+ "description": "guideline 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
+ "releaseModel": "scheduled"
13
+ },
14
+ "repository": "https://bitbucket.org/atlassian/atlassian-frontend",
15
+ "main": "dist/cjs/index.js",
16
+ "module": "dist/esm/index.js",
17
+ "module:es2019": "dist/es2019/index.js",
18
+ "types": "dist/types/index.d.ts",
19
+ "sideEffects": false,
20
+ "atlaskit:src": "src/index.ts",
21
+ "af:exports": {
22
+ ".": "./src/index.ts"
23
+ },
24
+ "dependencies": {
25
+ "@atlaskit/editor-common": "^74.2.0",
26
+ "@atlaskit/editor-plugin-width": "^0.0.1",
27
+ "@babel/runtime": "^7.0.0",
28
+ "prosemirror-state": "1.3.4",
29
+ "prosemirror-view": "1.23.7"
30
+ },
31
+ "peerDependencies": {
32
+ "react": "^16.8.0"
33
+ },
34
+ "devDependencies": {
35
+ "@atlaskit/docs": "*",
36
+ "@atlaskit/editor-core": "^184.0.0",
37
+ "@atlaskit/editor-test-helpers": "^18.2.0",
38
+ "@atlaskit/ssr": "*",
39
+ "@atlaskit/visual-regression": "*",
40
+ "@atlaskit/webdriver-runner": "*",
41
+ "@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
42
+ "@testing-library/react": "^12.1.5",
43
+ "react-dom": "^16.8.0",
44
+ "typescript": "~4.9.5",
45
+ "wait-for-expect": "^1.2.0"
46
+ },
47
+ "techstack": {
48
+ "@atlassian/frontend": {
49
+ "import-structure": [
50
+ "atlassian-conventions"
51
+ ],
52
+ "circular-dependencies": [
53
+ "file-and-folder-level"
54
+ ]
55
+ },
56
+ "@repo/internal": {
57
+ "dom-events": "use-bind-event-listener",
58
+ "analytics": [
59
+ "analytics-next"
60
+ ],
61
+ "design-tokens": [
62
+ "color"
63
+ ],
64
+ "theming": [
65
+ "react-context"
66
+ ],
67
+ "ui-components": [
68
+ "lite-mode"
69
+ ],
70
+ "deprecation": [
71
+ "no-deprecated-imports"
72
+ ],
73
+ "styling": [
74
+ "static",
75
+ "emotion"
76
+ ]
77
+ }
78
+ },
79
+ "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0"
80
+ }
package/report.api.md ADDED
@@ -0,0 +1,66 @@
1
+ <!-- API Report Version: 2.3 -->
2
+
3
+ ## API Report File for "@atlaskit/editor-plugin-guideline"
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 { EditorView } from 'prosemirror-view';
19
+ import { NextEditorPlugin } from '@atlaskit/editor-common/types';
20
+ import type { widthPlugin } from '@atlaskit/editor-plugin-width';
21
+
22
+ // @public (undocumented)
23
+ type DisplayGuideline = (view: EditorView) => void;
24
+
25
+ // @public (undocumented)
26
+ type Guideline = {
27
+ key?: string;
28
+ active?: boolean;
29
+ show?: boolean;
30
+ style?: 'dashed' | 'solid';
31
+ color?: string;
32
+ };
33
+
34
+ // @public (undocumented)
35
+ export const guidelinePlugin: NextEditorPlugin<
36
+ 'guideline',
37
+ {
38
+ dependencies: [typeof widthPlugin];
39
+ sharedState: GuidelinePluginState | null;
40
+ actions: {
41
+ displayGuideline: DisplayGuideline;
42
+ };
43
+ }
44
+ >;
45
+
46
+ // @public (undocumented)
47
+ type GuidelinePluginState = {
48
+ guidelines: Guideline[];
49
+ };
50
+
51
+ // (No @packageDocumentation comment for this package)
52
+ ```
53
+
54
+ <!--SECTION END: Main Entry Types-->
55
+
56
+ ### Peer Dependencies
57
+
58
+ <!--SECTION START: Peer Dependencies-->
59
+
60
+ ```json
61
+ {
62
+ "react": "^16.8.0"
63
+ }
64
+ ```
65
+
66
+ <!--SECTION END: Peer Dependencies-->