@atlaskit/editor-plugin-guideline 8.0.3 → 8.0.4
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 +8 -0
- package/README.md +65 -52
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-guideline
|
|
2
2
|
|
|
3
|
+
## 8.0.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`3da5fc5ff18bc`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3da5fc5ff18bc) -
|
|
8
|
+
Update README.md and 0-intro.tsx
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
3
11
|
## 8.0.3
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,52 +1,68 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Editor Plugin Guideline
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Guideline plugin for @atlaskit/editor-core
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The Guideline plugin provides the ability to display vertical guidelines in the editor. Guidelines are rendered as vertical lines at specified positions and can be customized with different styles and states. This plugin was designed to contain only basic logic to render guidelines. Commonly used configurations and utilities reside in the `editor-common` package.
|
|
8
|
+
|
|
9
|
+
## Key features
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
- **Display guidelines** - Render vertical guidelines at specified positions within the editor
|
|
12
|
+
- **Flexible positioning** - Position guidelines using coordinate values relative to the editor center
|
|
13
|
+
- **Customizable styles** - Configure line style (solid/dashed), color, and cap style
|
|
14
|
+
- **State management** - Control visibility and active states of individual guidelines
|
|
15
|
+
- **Plugin integration** - Works with the width plugin to calculate correct positioning
|
|
8
16
|
|
|
9
|
-
|
|
17
|
+
## Install
|
|
10
18
|
|
|
11
19
|
```
|
|
20
|
+
yarn add @atlaskit/editor-plugin-guideline
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
- **npm** - [@atlaskit/editor-plugin-guideline](https://www.npmjs.com/package/@atlaskit/editor-plugin-guideline)
|
|
24
|
+
- **Source** - [Bitbucket](https://bitbucket.org/atlassian/atlassian-frontend/src/master/packages/editor/editor-plugin-guideline)
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
### Basic Example
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
12
31
|
pluginInjectionApi?.dependencies?.guideline?.actions?.displayGuideline(view)({
|
|
13
32
|
guidelines: [{
|
|
14
|
-
key: "guideline_01"
|
|
33
|
+
key: "guideline_01",
|
|
15
34
|
position: {
|
|
16
35
|
x: -100
|
|
17
|
-
}
|
|
36
|
+
},
|
|
18
37
|
active: true,
|
|
19
38
|
style: "dashed",
|
|
20
39
|
color: "rgba(0, 0, 0, 0.2)"
|
|
21
40
|
},
|
|
22
41
|
{
|
|
23
|
-
key: "guideline_02"
|
|
42
|
+
key: "guideline_02",
|
|
24
43
|
position: {
|
|
25
44
|
x: 300
|
|
26
|
-
}
|
|
27
|
-
show: false
|
|
45
|
+
},
|
|
46
|
+
show: false
|
|
28
47
|
}]
|
|
29
48
|
});
|
|
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.
|
|
49
|
+
```
|
|
38
50
|
|
|
51
|
+
### Guideline Configuration
|
|
39
52
|
|
|
53
|
+
A guideline config consists of three parts:
|
|
40
54
|
|
|
41
|
-
|
|
55
|
+
- **Key** (required) - A unique identifier for the guideline
|
|
56
|
+
- **Position** (required) - The x-coordinate position of the guideline
|
|
57
|
+
- **State/Style** (optional) - Display state and styling options
|
|
42
58
|
|
|
43
|
-
|
|
44
|
-
- The layout of the guideline display area
|
|
45
|
-
- The position of a guideline for a given X value.
|
|
46
|
-
<pre>
|
|
59
|
+
### Position
|
|
47
60
|
|
|
61
|
+
The position value is defined as: `type Position = { x: number };`
|
|
48
62
|
|
|
63
|
+
Position diagram:
|
|
49
64
|
|
|
65
|
+
```
|
|
50
66
|
│ editor width │
|
|
51
67
|
│------------------- max 1800px --------------------│
|
|
52
68
|
│ │
|
|
@@ -66,43 +82,40 @@ The following diagram shows:
|
|
|
66
82
|
│ editor content │
|
|
67
83
|
│-------- max 760px ------│
|
|
68
84
|
│---------- or 1800px in full-width mode ----------│
|
|
69
|
-
|
|
70
|
-
</pre>
|
|
85
|
+
```
|
|
71
86
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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)
|
|
87
|
+
- When `x` is 0, a vertical line is displayed at the center of the editor
|
|
88
|
+
- Negative values move the line left (up to minus half of the editor width)
|
|
89
|
+
- Positive values move the line right (up to half of the editor width)
|
|
90
|
+
- Guidelines outside the visible range are ignored
|
|
78
91
|
|
|
92
|
+
### State and Style
|
|
79
93
|
|
|
80
|
-
|
|
94
|
+
Configure guidelines with the following state and style options:
|
|
81
95
|
|
|
82
|
-
|
|
83
|
-
```
|
|
96
|
+
```typescript
|
|
84
97
|
type GuidelineConfig = {
|
|
85
|
-
...
|
|
86
|
-
active?: boolean;
|
|
87
|
-
show?: boolean;
|
|
88
|
-
styles
|
|
89
|
-
lineStyle?: 'dashed' | 'solid';
|
|
90
|
-
color?: CSSToken;
|
|
91
|
-
capStyle?: 'line'
|
|
98
|
+
// ...
|
|
99
|
+
active?: boolean; // default false
|
|
100
|
+
show?: boolean; // default true
|
|
101
|
+
styles?: {
|
|
102
|
+
lineStyle?: 'dashed' | 'solid'; // default 'solid'
|
|
103
|
+
color?: CSSToken; // default undefined
|
|
104
|
+
capStyle?: 'line' // default undefined
|
|
92
105
|
}
|
|
93
106
|
};
|
|
94
107
|
```
|
|
95
108
|
|
|
96
|
-
- `active`
|
|
97
|
-
- `show`
|
|
98
|
-
- `styles.color
|
|
99
|
-
- `styles.lineStyle`
|
|
100
|
-
- `styles.capStyle`
|
|
109
|
+
- `active` - Equivalent to the highlight state in the grid plugin
|
|
110
|
+
- `show` - Hide a guideline (useful for animations)
|
|
111
|
+
- `styles.color` - Override the guideline color with a valid CSS color
|
|
112
|
+
- `styles.lineStyle` - Line style can be 'solid' or 'dashed'
|
|
113
|
+
- `styles.capStyle` - Line cap style, supports 'line'
|
|
114
|
+
|
|
115
|
+
## Support
|
|
116
|
+
|
|
117
|
+
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.
|
|
101
118
|
|
|
102
|
-
##
|
|
103
|
-
- [ ] Add unit/vr tests
|
|
104
|
-
- [ ] Handle guidelines which are outside of visitable range.
|
|
105
|
-
- [ ] Implement the Grid plug option, `shouldCalcBreakoutGridLines?: boolean;`
|
|
106
|
-
- [ ] Retire the exist Grid plugin. and replace it with this plugin. Plugins currently use the grid plugin: media, table and card.
|
|
107
|
-
- [ ] Investigate a better way to handle the `color` attribute, to avoid a fragmented experiences in the Editor.
|
|
119
|
+
## License
|
|
108
120
|
|
|
121
|
+
Please see [Atlassian Frontend - License](https://hello.atlassian.net/wiki/spaces/AF/pages/2589099144/Documentation#License) for more licensing information.
|