@atlaskit/editor-plugin-guideline 0.3.0 → 0.3.2
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 +14 -0
- package/README.md +97 -2
- package/dist/cjs/plugin.js +2 -2
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugin.js +2 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugin.js +2 -2
- package/dist/esm/version.json +1 -1
- package/dist/types/guildelineContainer.d.ts +1 -1
- package/dist/types-ts4.5/guildelineContainer.d.ts +1 -1
- package/package.json +7 -12
- package/report.api.md +4 -28
- package/tmp/api-report-tmp.d.ts +48 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-guideline
|
|
2
2
|
|
|
3
|
+
## 0.3.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`73b5128036b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/73b5128036b) - [ED-17082] Mark package as a singleton one
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
10
|
+
## 0.3.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [`7cd4abcdc0d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7cd4abcdc0d) - Fix workaround in `editor-plugin-width`. This involved removing `WidthEmitter` in `editor-core`, removing `containerWidth` from `WidthPluginState`. This change also introduces `usePluginHook` for an `EditorPlugin` - this enables a react hook to be mounted for plugins (in all appearances).
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 0.3.0
|
|
4
18
|
|
|
5
19
|
### Minor 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?: string;
|
|
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/plugin.js
CHANGED
|
@@ -59,7 +59,7 @@ var ContentComponent = function ContentComponent(_ref) {
|
|
|
59
59
|
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['width', 'guideline']),
|
|
60
60
|
widthState = _useSharedPluginState.widthState,
|
|
61
61
|
guidelineState = _useSharedPluginState.guidelineState;
|
|
62
|
-
if (!widthState || !widthState.
|
|
62
|
+
if (!widthState || !widthState.width || !widthState.lineLength || !guidelineState || !guidelineState.guidelines || guidelineState.guidelines.length === 0) {
|
|
63
63
|
return null;
|
|
64
64
|
}
|
|
65
65
|
return (0, _react.jsx)("div", {
|
|
@@ -68,7 +68,7 @@ var ContentComponent = function ContentComponent(_ref) {
|
|
|
68
68
|
guidelines: guidelineState.guidelines,
|
|
69
69
|
height: editorView.dom.scrollHeight,
|
|
70
70
|
centerOffset: (0, _utils.getEditorCenterX)(editorView),
|
|
71
|
-
|
|
71
|
+
width: widthState.width,
|
|
72
72
|
editorWidth: widthState.lineLength
|
|
73
73
|
}));
|
|
74
74
|
};
|
package/dist/cjs/version.json
CHANGED
package/dist/es2019/plugin.js
CHANGED
|
@@ -53,7 +53,7 @@ const ContentComponent = ({
|
|
|
53
53
|
widthState,
|
|
54
54
|
guidelineState
|
|
55
55
|
} = useSharedPluginState(api, ['width', 'guideline']);
|
|
56
|
-
if (!widthState || !widthState.
|
|
56
|
+
if (!widthState || !widthState.width || !widthState.lineLength || !guidelineState || !guidelineState.guidelines || guidelineState.guidelines.length === 0) {
|
|
57
57
|
return null;
|
|
58
58
|
}
|
|
59
59
|
return jsx("div", {
|
|
@@ -62,7 +62,7 @@ const ContentComponent = ({
|
|
|
62
62
|
guidelines: guidelineState.guidelines,
|
|
63
63
|
height: editorView.dom.scrollHeight,
|
|
64
64
|
centerOffset: getEditorCenterX(editorView),
|
|
65
|
-
|
|
65
|
+
width: widthState.width,
|
|
66
66
|
editorWidth: widthState.lineLength
|
|
67
67
|
}));
|
|
68
68
|
};
|
package/dist/es2019/version.json
CHANGED
package/dist/esm/plugin.js
CHANGED
|
@@ -51,7 +51,7 @@ var ContentComponent = function ContentComponent(_ref) {
|
|
|
51
51
|
var _useSharedPluginState = useSharedPluginState(api, ['width', 'guideline']),
|
|
52
52
|
widthState = _useSharedPluginState.widthState,
|
|
53
53
|
guidelineState = _useSharedPluginState.guidelineState;
|
|
54
|
-
if (!widthState || !widthState.
|
|
54
|
+
if (!widthState || !widthState.width || !widthState.lineLength || !guidelineState || !guidelineState.guidelines || guidelineState.guidelines.length === 0) {
|
|
55
55
|
return null;
|
|
56
56
|
}
|
|
57
57
|
return jsx("div", {
|
|
@@ -60,7 +60,7 @@ var ContentComponent = function ContentComponent(_ref) {
|
|
|
60
60
|
guidelines: guidelineState.guidelines,
|
|
61
61
|
height: editorView.dom.scrollHeight,
|
|
62
62
|
centerOffset: getEditorCenterX(editorView),
|
|
63
|
-
|
|
63
|
+
width: widthState.width,
|
|
64
64
|
editorWidth: widthState.lineLength
|
|
65
65
|
}));
|
|
66
66
|
};
|
package/dist/esm/version.json
CHANGED
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.2",
|
|
4
4
|
"description": "guideline plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
"registry": "https://registry.npmjs.org/"
|
|
9
9
|
},
|
|
10
10
|
"atlassian": {
|
|
11
|
-
"team": "Editor",
|
|
12
|
-
"
|
|
11
|
+
"team": "Editor Media Experience: Porygon",
|
|
12
|
+
"singleton": true,
|
|
13
|
+
"releaseModel": "continuous"
|
|
13
14
|
},
|
|
14
15
|
"repository": "https://bitbucket.org/atlassian/atlassian-frontend",
|
|
15
16
|
"main": "dist/cjs/index.js",
|
|
@@ -22,11 +23,11 @@
|
|
|
22
23
|
".": "./src/index.ts"
|
|
23
24
|
},
|
|
24
25
|
"dependencies": {
|
|
25
|
-
"@atlaskit/editor-common": "^74.
|
|
26
|
-
"@atlaskit/editor-plugin-width": "^0.0
|
|
26
|
+
"@atlaskit/editor-common": "^74.9.0",
|
|
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.9.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
|
@@ -28,23 +28,13 @@ type DisplayGuideline = (view: EditorView) => DisplayGrid;
|
|
|
28
28
|
// @public (undocumented)
|
|
29
29
|
export type GuidelineConfig = {
|
|
30
30
|
key: string;
|
|
31
|
-
position:
|
|
31
|
+
position: Position;
|
|
32
32
|
active?: boolean;
|
|
33
33
|
show?: boolean;
|
|
34
34
|
style?: 'dashed' | 'solid';
|
|
35
35
|
color?: string;
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
// @public (undocumented)
|
|
39
|
-
enum GuidelineContainerArea {
|
|
40
|
-
// (undocumented)
|
|
41
|
-
EditorContent = 'editorContent',
|
|
42
|
-
// (undocumented)
|
|
43
|
-
EditorLeftMargin = 'editorLeftMargin',
|
|
44
|
-
// (undocumented)
|
|
45
|
-
EditorRightMargin = 'editorRightMargin',
|
|
46
|
-
}
|
|
47
|
-
|
|
48
38
|
// @public (undocumented)
|
|
49
39
|
export const guidelinePlugin: NextEditorPlugin<
|
|
50
40
|
'guideline',
|
|
@@ -63,23 +53,9 @@ type GuidelinePluginState = {
|
|
|
63
53
|
};
|
|
64
54
|
|
|
65
55
|
// @public (undocumented)
|
|
66
|
-
type
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// @public (undocumented)
|
|
71
|
-
type PositionSide =
|
|
72
|
-
| {
|
|
73
|
-
left: PositionValue;
|
|
74
|
-
right?: never;
|
|
75
|
-
}
|
|
76
|
-
| {
|
|
77
|
-
right: PositionValue;
|
|
78
|
-
left?: never;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
// @public (undocumented)
|
|
82
|
-
type PositionValue = 0 | `${number}%` | `${number}px`;
|
|
56
|
+
type Position = {
|
|
57
|
+
x: number;
|
|
58
|
+
};
|
|
83
59
|
|
|
84
60
|
// (No @packageDocumentation comment for this package)
|
|
85
61
|
```
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
## API Report File for "@atlaskit/editor-plugin-guideline"
|
|
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 { EditorView } from 'prosemirror-view';
|
|
8
|
+
import { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
9
|
+
import type { widthPlugin } from '@atlaskit/editor-plugin-width';
|
|
10
|
+
|
|
11
|
+
// @public (undocumented)
|
|
12
|
+
type DisplayGrid = (props: Required<GuidelinePluginState>) => boolean;
|
|
13
|
+
|
|
14
|
+
// @public (undocumented)
|
|
15
|
+
type DisplayGuideline = (view: EditorView) => DisplayGrid;
|
|
16
|
+
|
|
17
|
+
// @public (undocumented)
|
|
18
|
+
export type GuidelineConfig = {
|
|
19
|
+
key: string;
|
|
20
|
+
position: Position;
|
|
21
|
+
active?: boolean;
|
|
22
|
+
show?: boolean;
|
|
23
|
+
style?: 'dashed' | 'solid';
|
|
24
|
+
color?: string;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// @public (undocumented)
|
|
28
|
+
export const guidelinePlugin: NextEditorPlugin<'guideline', {
|
|
29
|
+
dependencies: [typeof widthPlugin];
|
|
30
|
+
sharedState: GuidelinePluginState | null;
|
|
31
|
+
actions: {
|
|
32
|
+
displayGuideline: DisplayGuideline;
|
|
33
|
+
};
|
|
34
|
+
}>;
|
|
35
|
+
|
|
36
|
+
// @public (undocumented)
|
|
37
|
+
type GuidelinePluginState = {
|
|
38
|
+
guidelines: GuidelineConfig[];
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// @public (undocumented)
|
|
42
|
+
type Position = {
|
|
43
|
+
x: number;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// (No @packageDocumentation comment for this package)
|
|
47
|
+
|
|
48
|
+
```
|