@atlaskit/editor-plugin-guideline 0.3.1 → 0.3.3
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 +13 -0
- package/README.md +97 -2
- package/dist/cjs/guideline.js +11 -5
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/guideline.js +7 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/guideline.js +10 -3
- package/dist/esm/version.json +1 -1
- package/dist/types/guideline.d.ts +2 -0
- package/dist/types/types.d.ts +2 -1
- package/dist/types-ts4.5/guideline.d.ts +2 -0
- package/dist/types-ts4.5/types.d.ts +2 -1
- package/package.json +5 -10
- package/report.api.md +2 -1
- package/tmp/api-report-tmp.d.ts +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-guideline
|
|
2
2
|
|
|
3
|
+
## 0.3.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`e118dc7562b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/e118dc7562b) - ED-18897 guideline interface to use css tokens.
|
|
8
|
+
|
|
9
|
+
## 0.3.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`73b5128036b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/73b5128036b) - [ED-17082] Mark package as a singleton one
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
3
16
|
## 0.3.1
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -4,6 +4,101 @@ guideline plugin for @atlaskit/editor-core
|
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
7
|
-
`
|
|
7
|
+
See `packages/editor/editor-plugin-guideline/src/types.ts` for detailed guideline config interface.
|
|
8
|
+
|
|
9
|
+
Example usage:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
pluginInjectionApi?.dependencies?.guideline?.actions?.displayGuideline(view)({
|
|
13
|
+
guidelines: [{
|
|
14
|
+
key: "guideline_01"
|
|
15
|
+
position: {
|
|
16
|
+
x: -100
|
|
17
|
+
}; // The position of the guideline
|
|
18
|
+
active: true,
|
|
19
|
+
style: "dashed",
|
|
20
|
+
color: "rgba(0, 0, 0, 0.2)"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
key: "guideline_02"
|
|
24
|
+
position: {
|
|
25
|
+
x: 300
|
|
26
|
+
};
|
|
27
|
+
show: false,
|
|
28
|
+
}]
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
A guideline config consists of three parts:
|
|
33
|
+
- A unique key (required)
|
|
34
|
+
- Position (required)
|
|
35
|
+
- State/Style (optional)
|
|
36
|
+
|
|
37
|
+
This plugin was designed to be "dumb". Meaning that it only contains very basic logics to render the guidelines. Commonly used configurations and utils will be reside in the `editor-common` package.
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
## Position:
|
|
42
|
+
|
|
43
|
+
The following diagram shows:
|
|
44
|
+
- The layout of the guideline display area
|
|
45
|
+
- The position of a guideline for a given X value.
|
|
46
|
+
<pre>
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
│ editor width │
|
|
51
|
+
│------------------- max 1800px --------------------│
|
|
52
|
+
│ │
|
|
53
|
+
│ center line (when position x=0) │
|
|
54
|
+
│ │ │
|
|
55
|
+
│--------- x < 0 ---------│--------- x > 0 ---------│
|
|
56
|
+
│ │ │
|
|
57
|
+
┌────────────┬────────────┬────────────┬────────────┐
|
|
58
|
+
│ │ │ │ │
|
|
59
|
+
│ │ │ │ │
|
|
60
|
+
│ │ │ │ │
|
|
61
|
+
│ │-- 380px ---│--- 380px --│ │
|
|
62
|
+
│ │ │ │ │
|
|
63
|
+
│ │ │ │ │
|
|
64
|
+
│ │ │ │ │
|
|
65
|
+
└────────────┴────────────┴────────────┴────────────┘
|
|
66
|
+
│ editor content │
|
|
67
|
+
│-------- max 760px ------│
|
|
68
|
+
│---------- or 1800px in full-width mode ----------│
|
|
69
|
+
|
|
70
|
+
</pre>
|
|
71
|
+
|
|
72
|
+
The position value is defined as follow:
|
|
73
|
+
`type Position = { x: number };`
|
|
74
|
+
* When x is 0, a vertical line is displayed at the center of the editor (see the diagram above).
|
|
75
|
+
* A negative value will move the line to the left, up to minus half of the editor width.
|
|
76
|
+
* A positive value will move the line to the right, up to half of the editor width.
|
|
77
|
+
* If a `x` value is outside of the visible range, if will be ignored. (See the todo section)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
## State/Style
|
|
81
|
+
|
|
82
|
+
We have the follow state/style configurations
|
|
83
|
+
```
|
|
84
|
+
type GuidelineConfig = {
|
|
85
|
+
...
|
|
86
|
+
active?: boolean;
|
|
87
|
+
show?: boolean;
|
|
88
|
+
style?: 'dashed' | 'solid'; // default solid
|
|
89
|
+
color?: CSSToken;
|
|
90
|
+
};
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
- `active` default `false`, equivalent to the `highlight` state in the `grid` plugin.
|
|
94
|
+
- `style` default `solid`, and we also support `dashed`
|
|
95
|
+
- `show` default `true` and you can also hide a guideline, could be useful when you need animations.
|
|
96
|
+
- `color`: default `undefined` you can override the color of a guideline with a valid `css` color
|
|
97
|
+
|
|
98
|
+
## TODO
|
|
99
|
+
- [ ] Add unit/vr tests
|
|
100
|
+
- [ ] Handle guidelines which are outside of visitable range.
|
|
101
|
+
- [ ] Implement the Grid plug option, `shouldCalcBreakoutGridLines?: boolean;`
|
|
102
|
+
- [ ] Retire the exist Grid plugin. and replace it with this plugin. Plugins currently use the grid plugin: media, table and card.
|
|
103
|
+
- [ ] Investigate a better way to handle the `color` attribute, to avoid a fragmented experiences in the Editor.
|
|
8
104
|
|
|
9
|
-
Detailed docs and example usage can be found [here](https://atlaskit.atlassian.com/packages/editor/editor-plugin-guideline).
|
package/dist/cjs/guideline.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.Guideline = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
7
9
|
var _react = require("@emotion/react");
|
|
8
10
|
var _colors = require("@atlaskit/theme/colors");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
12
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } /** @jsx jsx */
|
|
11
13
|
var BasicGuidelineStyles = (0, _react.css)({
|
|
12
14
|
borderLeft: "1px solid ".concat("var(--ds-border, ".concat(_colors.N30A, ")")),
|
|
13
15
|
position: 'absolute',
|
|
14
16
|
width: '1px',
|
|
15
17
|
height: '100%',
|
|
16
18
|
zIndex: 0,
|
|
19
|
+
transform: 'translateX(-50%)',
|
|
17
20
|
opacity: 1,
|
|
18
21
|
transition: 'border-color 0.15s linear, opacity 0.15s linear'
|
|
19
22
|
});
|
|
@@ -31,13 +34,16 @@ var Guideline = function Guideline(props) {
|
|
|
31
34
|
active = props.active,
|
|
32
35
|
_props$show = props.show,
|
|
33
36
|
show = _props$show === void 0 ? true : _props$show,
|
|
34
|
-
style = props.style
|
|
37
|
+
style = props.style,
|
|
38
|
+
color = props.color;
|
|
35
39
|
return (0, _react.jsx)("div", {
|
|
36
40
|
css: [BasicGuidelineStyles, active && ActiveGuidelineStyles, !show && HiddenGuidelineStyles, style === 'dashed' && DashedGuidelineStyles],
|
|
37
41
|
className: "guideline",
|
|
38
|
-
style: {
|
|
42
|
+
style: _objectSpread({
|
|
39
43
|
left: "".concat(position, "px")
|
|
40
|
-
}
|
|
44
|
+
}, color && {
|
|
45
|
+
borderColor: "".concat(color)
|
|
46
|
+
})
|
|
41
47
|
});
|
|
42
48
|
};
|
|
43
49
|
exports.Guideline = Guideline;
|
package/dist/cjs/version.json
CHANGED
package/dist/es2019/guideline.js
CHANGED
|
@@ -7,6 +7,7 @@ const BasicGuidelineStyles = css({
|
|
|
7
7
|
width: '1px',
|
|
8
8
|
height: '100%',
|
|
9
9
|
zIndex: 0,
|
|
10
|
+
transform: 'translateX(-50%)',
|
|
10
11
|
opacity: 1,
|
|
11
12
|
transition: 'border-color 0.15s linear, opacity 0.15s linear'
|
|
12
13
|
});
|
|
@@ -24,13 +25,17 @@ export const Guideline = props => {
|
|
|
24
25
|
position,
|
|
25
26
|
active,
|
|
26
27
|
show = true,
|
|
27
|
-
style
|
|
28
|
+
style,
|
|
29
|
+
color
|
|
28
30
|
} = props;
|
|
29
31
|
return jsx("div", {
|
|
30
32
|
css: [BasicGuidelineStyles, active && ActiveGuidelineStyles, !show && HiddenGuidelineStyles, style === 'dashed' && DashedGuidelineStyles],
|
|
31
33
|
className: "guideline",
|
|
32
34
|
style: {
|
|
33
|
-
left: `${position}px
|
|
35
|
+
left: `${position}px`,
|
|
36
|
+
...(color && {
|
|
37
|
+
borderColor: `${color}`
|
|
38
|
+
})
|
|
34
39
|
}
|
|
35
40
|
});
|
|
36
41
|
};
|
package/dist/es2019/version.json
CHANGED
package/dist/esm/guideline.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1
4
|
/** @jsx jsx */
|
|
2
5
|
import { css, jsx } from '@emotion/react';
|
|
3
6
|
import { B200, N30A } from '@atlaskit/theme/colors';
|
|
@@ -7,6 +10,7 @@ var BasicGuidelineStyles = css({
|
|
|
7
10
|
width: '1px',
|
|
8
11
|
height: '100%',
|
|
9
12
|
zIndex: 0,
|
|
13
|
+
transform: 'translateX(-50%)',
|
|
10
14
|
opacity: 1,
|
|
11
15
|
transition: 'border-color 0.15s linear, opacity 0.15s linear'
|
|
12
16
|
});
|
|
@@ -24,12 +28,15 @@ export var Guideline = function Guideline(props) {
|
|
|
24
28
|
active = props.active,
|
|
25
29
|
_props$show = props.show,
|
|
26
30
|
show = _props$show === void 0 ? true : _props$show,
|
|
27
|
-
style = props.style
|
|
31
|
+
style = props.style,
|
|
32
|
+
color = props.color;
|
|
28
33
|
return jsx("div", {
|
|
29
34
|
css: [BasicGuidelineStyles, active && ActiveGuidelineStyles, !show && HiddenGuidelineStyles, style === 'dashed' && DashedGuidelineStyles],
|
|
30
35
|
className: "guideline",
|
|
31
|
-
style: {
|
|
36
|
+
style: _objectSpread({
|
|
32
37
|
left: "".concat(position, "px")
|
|
33
|
-
}
|
|
38
|
+
}, color && {
|
|
39
|
+
borderColor: "".concat(color)
|
|
40
|
+
})
|
|
34
41
|
});
|
|
35
42
|
};
|
package/dist/esm/version.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { jsx } from '@emotion/react';
|
|
3
|
+
import { CSSToken } from '@atlaskit/tokens';
|
|
3
4
|
type Props = {
|
|
4
5
|
position: number;
|
|
5
6
|
active?: boolean;
|
|
6
7
|
show?: boolean;
|
|
7
8
|
style?: 'dashed' | 'solid';
|
|
9
|
+
color?: CSSToken;
|
|
8
10
|
};
|
|
9
11
|
export declare const Guideline: (props: Props) => jsx.JSX.Element;
|
|
10
12
|
export {};
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EditorView } from 'prosemirror-view';
|
|
2
|
+
import { CSSToken } from '@atlaskit/tokens';
|
|
2
3
|
export type Position = {
|
|
3
4
|
x: number;
|
|
4
5
|
};
|
|
@@ -8,7 +9,7 @@ type GuidelineConfig = {
|
|
|
8
9
|
active?: boolean;
|
|
9
10
|
show?: boolean;
|
|
10
11
|
style?: 'dashed' | 'solid';
|
|
11
|
-
color?:
|
|
12
|
+
color?: CSSToken;
|
|
12
13
|
};
|
|
13
14
|
type GuidelinePluginState = {
|
|
14
15
|
guidelines: GuidelineConfig[];
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { jsx } from '@emotion/react';
|
|
3
|
+
import { CSSToken } from '@atlaskit/tokens';
|
|
3
4
|
type Props = {
|
|
4
5
|
position: number;
|
|
5
6
|
active?: boolean;
|
|
6
7
|
show?: boolean;
|
|
7
8
|
style?: 'dashed' | 'solid';
|
|
9
|
+
color?: CSSToken;
|
|
8
10
|
};
|
|
9
11
|
export declare const Guideline: (props: Props) => jsx.JSX.Element;
|
|
10
12
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EditorView } from 'prosemirror-view';
|
|
2
|
+
import { CSSToken } from '@atlaskit/tokens';
|
|
2
3
|
export type Position = {
|
|
3
4
|
x: number;
|
|
4
5
|
};
|
|
@@ -8,7 +9,7 @@ type GuidelineConfig = {
|
|
|
8
9
|
active?: boolean;
|
|
9
10
|
show?: boolean;
|
|
10
11
|
style?: 'dashed' | 'solid';
|
|
11
|
-
color?:
|
|
12
|
+
color?: CSSToken;
|
|
12
13
|
};
|
|
13
14
|
type GuidelinePluginState = {
|
|
14
15
|
guidelines: GuidelineConfig[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-guideline",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "guideline plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"registry": "https://registry.npmjs.org/"
|
|
9
9
|
},
|
|
10
10
|
"atlassian": {
|
|
11
|
-
"team": "Editor",
|
|
11
|
+
"team": "Editor Media Experience: Porygon",
|
|
12
|
+
"singleton": true,
|
|
12
13
|
"releaseModel": "continuous"
|
|
13
14
|
},
|
|
14
15
|
"repository": "https://bitbucket.org/atlassian/atlassian-frontend",
|
|
@@ -22,11 +23,11 @@
|
|
|
22
23
|
".": "./src/index.ts"
|
|
23
24
|
},
|
|
24
25
|
"dependencies": {
|
|
25
|
-
"@atlaskit/editor-common": "^74.
|
|
26
|
+
"@atlaskit/editor-common": "^74.15.0",
|
|
26
27
|
"@atlaskit/editor-plugin-width": "^0.1.0",
|
|
27
28
|
"@atlaskit/editor-shared-styles": "^2.4.0",
|
|
28
29
|
"@atlaskit/theme": "^12.5.0",
|
|
29
|
-
"@atlaskit/tokens": "^1.
|
|
30
|
+
"@atlaskit/tokens": "^1.11.0",
|
|
30
31
|
"@babel/runtime": "^7.0.0",
|
|
31
32
|
"@emotion/react": "^11.7.1",
|
|
32
33
|
"prosemirror-state": "1.3.4",
|
|
@@ -36,12 +37,6 @@
|
|
|
36
37
|
"react": "^16.8.0"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
|
-
"@atlaskit/docs": "*",
|
|
40
|
-
"@atlaskit/editor-core": "^185.1.0",
|
|
41
|
-
"@atlaskit/editor-test-helpers": "^18.5.0",
|
|
42
|
-
"@atlaskit/ssr": "*",
|
|
43
|
-
"@atlaskit/visual-regression": "*",
|
|
44
|
-
"@atlaskit/webdriver-runner": "*",
|
|
45
40
|
"@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
|
|
46
41
|
"@testing-library/react": "^12.1.5",
|
|
47
42
|
"react-dom": "^16.8.0",
|
package/report.api.md
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
<!--SECTION START: Main Entry Types-->
|
|
16
16
|
|
|
17
17
|
```ts
|
|
18
|
+
import { CSSToken } from '@atlaskit/tokens';
|
|
18
19
|
import { EditorView } from 'prosemirror-view';
|
|
19
20
|
import { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
20
21
|
import type { widthPlugin } from '@atlaskit/editor-plugin-width';
|
|
@@ -32,7 +33,7 @@ export type GuidelineConfig = {
|
|
|
32
33
|
active?: boolean;
|
|
33
34
|
show?: boolean;
|
|
34
35
|
style?: 'dashed' | 'solid';
|
|
35
|
-
color?:
|
|
36
|
+
color?: CSSToken;
|
|
36
37
|
};
|
|
37
38
|
|
|
38
39
|
// @public (undocumented)
|
package/tmp/api-report-tmp.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
6
|
|
|
7
|
+
import { CSSToken } from '@atlaskit/tokens';
|
|
7
8
|
import { EditorView } from 'prosemirror-view';
|
|
8
9
|
import { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
9
10
|
import type { widthPlugin } from '@atlaskit/editor-plugin-width';
|
|
@@ -21,7 +22,7 @@ export type GuidelineConfig = {
|
|
|
21
22
|
active?: boolean;
|
|
22
23
|
show?: boolean;
|
|
23
24
|
style?: 'dashed' | 'solid';
|
|
24
|
-
color?:
|
|
25
|
+
color?: CSSToken;
|
|
25
26
|
};
|
|
26
27
|
|
|
27
28
|
// @public (undocumented)
|