@atlaskit/editor-plugin-guideline 0.1.0 → 0.3.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 +22 -0
- package/dist/cjs/guideline.js +43 -0
- package/dist/cjs/guildelineContainer.js +59 -0
- package/dist/cjs/plugin.js +38 -7
- package/dist/cjs/utils.js +59 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/guideline.js +36 -0
- package/dist/es2019/guildelineContainer.js +48 -0
- package/dist/es2019/plugin.js +36 -6
- package/dist/es2019/utils.js +46 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/guideline.js +35 -0
- package/dist/esm/guildelineContainer.js +50 -0
- package/dist/esm/plugin.js +36 -6
- package/dist/esm/utils.js +50 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/guideline.d.ts +10 -0
- package/dist/types/guildelineContainer.d.ts +11 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/plugin.d.ts +1 -0
- package/dist/types/types.d.ts +10 -5
- package/dist/types/utils.d.ts +10 -0
- package/dist/types-ts4.5/guideline.d.ts +10 -0
- package/dist/types-ts4.5/guildelineContainer.d.ts +11 -0
- package/dist/types-ts4.5/index.d.ts +1 -0
- package/dist/types-ts4.5/plugin.d.ts +1 -0
- package/dist/types-ts4.5/types.d.ts +10 -5
- package/dist/types-ts4.5/utils.d.ts +10 -0
- package/package.json +8 -4
- package/report.api.md +37 -4
package/CHANGELOG.md
CHANGED
|
@@ -1 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-guideline
|
|
2
|
+
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`d7aa08972c6`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d7aa08972c6) - add style handler for the editor guideline plugin
|
|
8
|
+
- [`1dadcae5b09`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1dadcae5b09) - COLLAB-2623 Updated API to newest interface and added utils to create default gridlines
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
14
|
+
## 0.2.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- [`d8f19b90c43`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d8f19b90c43) - COLLAB-2622 Update editor-plugin-guideline to support position config.
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- [`2625e4baea0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/2625e4baea0) - COLLAB-2622 Setup React components for future works.
|
|
23
|
+
- Updated dependencies
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Guideline = void 0;
|
|
7
|
+
var _react = require("@emotion/react");
|
|
8
|
+
var _colors = require("@atlaskit/theme/colors");
|
|
9
|
+
/** @jsx jsx */
|
|
10
|
+
|
|
11
|
+
var BasicGuidelineStyles = (0, _react.css)({
|
|
12
|
+
borderLeft: "1px solid ".concat("var(--ds-border, ".concat(_colors.N30A, ")")),
|
|
13
|
+
position: 'absolute',
|
|
14
|
+
width: '1px',
|
|
15
|
+
height: '100%',
|
|
16
|
+
zIndex: 0,
|
|
17
|
+
opacity: 1,
|
|
18
|
+
transition: 'border-color 0.15s linear, opacity 0.15s linear'
|
|
19
|
+
});
|
|
20
|
+
var ActiveGuidelineStyles = (0, _react.css)({
|
|
21
|
+
borderColor: "var(--ds-border-focused, ".concat(_colors.B200, ")")
|
|
22
|
+
});
|
|
23
|
+
var HiddenGuidelineStyles = (0, _react.css)({
|
|
24
|
+
opacity: 0
|
|
25
|
+
});
|
|
26
|
+
var DashedGuidelineStyles = (0, _react.css)({
|
|
27
|
+
borderLeftStyle: 'dashed'
|
|
28
|
+
});
|
|
29
|
+
var Guideline = function Guideline(props) {
|
|
30
|
+
var position = props.position,
|
|
31
|
+
active = props.active,
|
|
32
|
+
_props$show = props.show,
|
|
33
|
+
show = _props$show === void 0 ? true : _props$show,
|
|
34
|
+
style = props.style;
|
|
35
|
+
return (0, _react.jsx)("div", {
|
|
36
|
+
css: [BasicGuidelineStyles, active && ActiveGuidelineStyles, !show && HiddenGuidelineStyles, style === 'dashed' && DashedGuidelineStyles],
|
|
37
|
+
className: "guideline",
|
|
38
|
+
style: {
|
|
39
|
+
left: "".concat(position, "px")
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
exports.Guideline = Guideline;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.GuidelineContainer = void 0;
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var _react = require("react");
|
|
10
|
+
var _react2 = require("@emotion/react");
|
|
11
|
+
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
12
|
+
var _guideline = require("./guideline");
|
|
13
|
+
/** @jsx jsx */
|
|
14
|
+
|
|
15
|
+
var guidelineContainerStyles = (0, _react2.css)({
|
|
16
|
+
position: 'fixed',
|
|
17
|
+
height: '100vh',
|
|
18
|
+
width: '100%',
|
|
19
|
+
display: 'grid',
|
|
20
|
+
pointerEvents: 'none',
|
|
21
|
+
border: 'none',
|
|
22
|
+
maxWidth: "".concat(_editorSharedStyles.akEditorFullWidthLayoutWidth, "px")
|
|
23
|
+
});
|
|
24
|
+
var GuidelineContainer = function GuidelineContainer(props) {
|
|
25
|
+
var guidelines = props.guidelines,
|
|
26
|
+
height = props.height,
|
|
27
|
+
editorWidth = props.editorWidth,
|
|
28
|
+
centerOffset = props.centerOffset;
|
|
29
|
+
var _useState = (0, _react.useState)(0),
|
|
30
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
31
|
+
offset = _useState2[0],
|
|
32
|
+
setOffset = _useState2[1];
|
|
33
|
+
var ref = (0, _react.useRef)(null);
|
|
34
|
+
(0, _react.useLayoutEffect)(function () {
|
|
35
|
+
var _ref$current;
|
|
36
|
+
var rect = ref === null || ref === void 0 ? void 0 : (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.getBoundingClientRect();
|
|
37
|
+
if (rect) {
|
|
38
|
+
// X pixels from guideline container left to editor center.
|
|
39
|
+
setOffset(centerOffset - rect.x);
|
|
40
|
+
}
|
|
41
|
+
}, [centerOffset, guidelines, editorWidth]);
|
|
42
|
+
return (0, _react2.jsx)("div", {
|
|
43
|
+
ref: ref,
|
|
44
|
+
css: guidelineContainerStyles,
|
|
45
|
+
style: {
|
|
46
|
+
height: height
|
|
47
|
+
},
|
|
48
|
+
"data-testid": "guidelineContainer"
|
|
49
|
+
}, guidelines.map(function (guideline) {
|
|
50
|
+
return (0, _react2.jsx)(_guideline.Guideline, {
|
|
51
|
+
key: guideline.key,
|
|
52
|
+
position: guideline.position.x + offset,
|
|
53
|
+
active: guideline.active,
|
|
54
|
+
show: guideline.show,
|
|
55
|
+
style: guideline.style
|
|
56
|
+
});
|
|
57
|
+
}));
|
|
58
|
+
};
|
|
59
|
+
exports.GuidelineContainer = GuidelineContainer;
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -1,19 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
|
-
exports.guidelinePlugin = void 0;
|
|
8
|
-
var _react =
|
|
6
|
+
exports.guidelinePlugin = exports.EMPTY_STATE = void 0;
|
|
7
|
+
var _react = require("@emotion/react");
|
|
9
8
|
var _prosemirrorState = require("prosemirror-state");
|
|
10
9
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
11
10
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
11
|
+
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
12
|
+
var _guildelineContainer = require("./guildelineContainer");
|
|
13
|
+
var _utils = require("./utils");
|
|
14
|
+
/** @jsx jsx */
|
|
15
|
+
|
|
16
|
+
var guidelineStyles = (0, _react.css)({
|
|
17
|
+
position: 'absolute',
|
|
18
|
+
width: '100%',
|
|
19
|
+
left: 0,
|
|
20
|
+
right: 0,
|
|
21
|
+
transform: "scale(1)",
|
|
22
|
+
zIndex: "".concat(_editorSharedStyles.akEditorGridLineZIndex, ";"),
|
|
23
|
+
display: 'flex',
|
|
24
|
+
justifyContent: 'center'
|
|
25
|
+
});
|
|
12
26
|
var key = new _prosemirrorState.PluginKey('guidelinePlugin');
|
|
13
|
-
var displayGuideline = function displayGuideline(
|
|
27
|
+
var displayGuideline = function displayGuideline(view) {
|
|
28
|
+
return function (props) {
|
|
29
|
+
var dispatch = view.dispatch,
|
|
30
|
+
state = view.state;
|
|
31
|
+
var tr = state.tr.setMeta(key, props);
|
|
32
|
+
dispatch(tr);
|
|
33
|
+
return true;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
14
36
|
var EMPTY_STATE = {
|
|
15
37
|
guidelines: []
|
|
16
38
|
};
|
|
39
|
+
exports.EMPTY_STATE = EMPTY_STATE;
|
|
17
40
|
var guidelinePMPlugin = new _safePlugin.SafePlugin({
|
|
18
41
|
key: key,
|
|
19
42
|
state: {
|
|
@@ -36,10 +59,18 @@ var ContentComponent = function ContentComponent(_ref) {
|
|
|
36
59
|
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['width', 'guideline']),
|
|
37
60
|
widthState = _useSharedPluginState.widthState,
|
|
38
61
|
guidelineState = _useSharedPluginState.guidelineState;
|
|
39
|
-
if (!guidelineState || !
|
|
62
|
+
if (!widthState || !widthState.containerWidth || !widthState.lineLength || !guidelineState || !guidelineState.guidelines || guidelineState.guidelines.length === 0) {
|
|
40
63
|
return null;
|
|
41
64
|
}
|
|
42
|
-
return
|
|
65
|
+
return (0, _react.jsx)("div", {
|
|
66
|
+
css: guidelineStyles
|
|
67
|
+
}, (0, _react.jsx)(_guildelineContainer.GuidelineContainer, {
|
|
68
|
+
guidelines: guidelineState.guidelines,
|
|
69
|
+
height: editorView.dom.scrollHeight,
|
|
70
|
+
centerOffset: (0, _utils.getEditorCenterX)(editorView),
|
|
71
|
+
containerWidth: widthState.containerWidth,
|
|
72
|
+
editorWidth: widthState.lineLength
|
|
73
|
+
}));
|
|
43
74
|
};
|
|
44
75
|
var guidelinePlugin = function guidelinePlugin(options, api) {
|
|
45
76
|
return {
|
|
@@ -63,7 +94,7 @@ var guidelinePlugin = function guidelinePlugin(options, api) {
|
|
|
63
94
|
},
|
|
64
95
|
contentComponent: function contentComponent(_ref2) {
|
|
65
96
|
var editorView = _ref2.editorView;
|
|
66
|
-
return
|
|
97
|
+
return (0, _react.jsx)(ContentComponent, {
|
|
67
98
|
editorView: editorView,
|
|
68
99
|
options: options,
|
|
69
100
|
api: api
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.innerGuidelines = exports.getEditorCenterX = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
10
|
+
/**
|
|
11
|
+
* This function calculates the Editor's x axis of the center point
|
|
12
|
+
* in relation to the viewport
|
|
13
|
+
* @param editorView
|
|
14
|
+
* @returns x axis in number
|
|
15
|
+
*/
|
|
16
|
+
var getEditorCenterX = function getEditorCenterX(editorView) {
|
|
17
|
+
var editorRect = editorView.dom.getBoundingClientRect();
|
|
18
|
+
return editorRect.width / 2 + editorRect.x;
|
|
19
|
+
};
|
|
20
|
+
exports.getEditorCenterX = getEditorCenterX;
|
|
21
|
+
var defaultGrids = [-6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6];
|
|
22
|
+
var innerGuidelines = function innerGuidelines(editorContainerWidth) {
|
|
23
|
+
var editorWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _editorSharedStyles.akEditorDefaultLayoutWidth;
|
|
24
|
+
var wideSpacing = editorWidth * _editorSharedStyles.breakoutWideScaleRatio / 2;
|
|
25
|
+
var fullWidthPadding = (_editorSharedStyles.akEditorBreakoutPadding + editorWidth - _editorSharedStyles.akEditorDefaultLayoutWidth) / 2;
|
|
26
|
+
var containerWidth = Math.min(editorContainerWidth, _editorSharedStyles.akEditorFullWidthLayoutWidth) / 2 - fullWidthPadding;
|
|
27
|
+
var fullWidthGuidelines = [{
|
|
28
|
+
key: "full_width_left",
|
|
29
|
+
position: {
|
|
30
|
+
x: -containerWidth
|
|
31
|
+
}
|
|
32
|
+
}, {
|
|
33
|
+
key: "full_width_right",
|
|
34
|
+
position: {
|
|
35
|
+
x: containerWidth
|
|
36
|
+
}
|
|
37
|
+
}];
|
|
38
|
+
var wideGuidelines = [{
|
|
39
|
+
key: "wide_left",
|
|
40
|
+
position: {
|
|
41
|
+
x: -wideSpacing
|
|
42
|
+
}
|
|
43
|
+
}, {
|
|
44
|
+
key: "wide_right",
|
|
45
|
+
position: {
|
|
46
|
+
x: wideSpacing
|
|
47
|
+
}
|
|
48
|
+
}];
|
|
49
|
+
var gridGuidelines = defaultGrids.map(function (val, index) {
|
|
50
|
+
return {
|
|
51
|
+
key: "grid_".concat(index),
|
|
52
|
+
position: {
|
|
53
|
+
x: val / 12 * editorWidth
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
return [].concat((0, _toConsumableArray2.default)(gridGuidelines), wideGuidelines, fullWidthGuidelines);
|
|
58
|
+
};
|
|
59
|
+
exports.innerGuidelines = innerGuidelines;
|
package/dist/cjs/version.json
CHANGED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { css, jsx } from '@emotion/react';
|
|
3
|
+
import { B200, N30A } from '@atlaskit/theme/colors';
|
|
4
|
+
const BasicGuidelineStyles = css({
|
|
5
|
+
borderLeft: `1px solid ${`var(--ds-border, ${N30A})`}`,
|
|
6
|
+
position: 'absolute',
|
|
7
|
+
width: '1px',
|
|
8
|
+
height: '100%',
|
|
9
|
+
zIndex: 0,
|
|
10
|
+
opacity: 1,
|
|
11
|
+
transition: 'border-color 0.15s linear, opacity 0.15s linear'
|
|
12
|
+
});
|
|
13
|
+
const ActiveGuidelineStyles = css({
|
|
14
|
+
borderColor: `var(--ds-border-focused, ${B200})`
|
|
15
|
+
});
|
|
16
|
+
const HiddenGuidelineStyles = css({
|
|
17
|
+
opacity: 0
|
|
18
|
+
});
|
|
19
|
+
const DashedGuidelineStyles = css({
|
|
20
|
+
borderLeftStyle: 'dashed'
|
|
21
|
+
});
|
|
22
|
+
export const Guideline = props => {
|
|
23
|
+
const {
|
|
24
|
+
position,
|
|
25
|
+
active,
|
|
26
|
+
show = true,
|
|
27
|
+
style
|
|
28
|
+
} = props;
|
|
29
|
+
return jsx("div", {
|
|
30
|
+
css: [BasicGuidelineStyles, active && ActiveGuidelineStyles, !show && HiddenGuidelineStyles, style === 'dashed' && DashedGuidelineStyles],
|
|
31
|
+
className: "guideline",
|
|
32
|
+
style: {
|
|
33
|
+
left: `${position}px`
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { useLayoutEffect, useRef, useState } from 'react';
|
|
3
|
+
import { css, jsx } from '@emotion/react';
|
|
4
|
+
import { akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
5
|
+
import { Guideline } from './guideline';
|
|
6
|
+
const guidelineContainerStyles = css({
|
|
7
|
+
position: 'fixed',
|
|
8
|
+
height: '100vh',
|
|
9
|
+
width: '100%',
|
|
10
|
+
display: 'grid',
|
|
11
|
+
pointerEvents: 'none',
|
|
12
|
+
border: 'none',
|
|
13
|
+
maxWidth: `${akEditorFullWidthLayoutWidth}px`
|
|
14
|
+
});
|
|
15
|
+
export const GuidelineContainer = props => {
|
|
16
|
+
const {
|
|
17
|
+
guidelines,
|
|
18
|
+
height,
|
|
19
|
+
editorWidth,
|
|
20
|
+
centerOffset
|
|
21
|
+
} = props;
|
|
22
|
+
const [offset, setOffset] = useState(0);
|
|
23
|
+
const ref = useRef(null);
|
|
24
|
+
useLayoutEffect(() => {
|
|
25
|
+
var _ref$current;
|
|
26
|
+
const rect = ref === null || ref === void 0 ? void 0 : (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.getBoundingClientRect();
|
|
27
|
+
if (rect) {
|
|
28
|
+
// X pixels from guideline container left to editor center.
|
|
29
|
+
setOffset(centerOffset - rect.x);
|
|
30
|
+
}
|
|
31
|
+
}, [centerOffset, guidelines, editorWidth]);
|
|
32
|
+
return jsx("div", {
|
|
33
|
+
ref: ref,
|
|
34
|
+
css: guidelineContainerStyles,
|
|
35
|
+
style: {
|
|
36
|
+
height
|
|
37
|
+
},
|
|
38
|
+
"data-testid": "guidelineContainer"
|
|
39
|
+
}, guidelines.map(guideline => {
|
|
40
|
+
return jsx(Guideline, {
|
|
41
|
+
key: guideline.key,
|
|
42
|
+
position: guideline.position.x + offset,
|
|
43
|
+
active: guideline.active,
|
|
44
|
+
show: guideline.show,
|
|
45
|
+
style: guideline.style
|
|
46
|
+
});
|
|
47
|
+
}));
|
|
48
|
+
};
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -1,10 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { css, jsx } from '@emotion/react';
|
|
2
3
|
import { PluginKey } from 'prosemirror-state';
|
|
3
4
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
4
5
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
6
|
+
import { akEditorGridLineZIndex } from '@atlaskit/editor-shared-styles';
|
|
7
|
+
import { GuidelineContainer } from './guildelineContainer';
|
|
8
|
+
import { getEditorCenterX } from './utils';
|
|
9
|
+
const guidelineStyles = css({
|
|
10
|
+
position: 'absolute',
|
|
11
|
+
width: '100%',
|
|
12
|
+
left: 0,
|
|
13
|
+
right: 0,
|
|
14
|
+
transform: `scale(1)`,
|
|
15
|
+
zIndex: `${akEditorGridLineZIndex};`,
|
|
16
|
+
display: 'flex',
|
|
17
|
+
justifyContent: 'center'
|
|
18
|
+
});
|
|
5
19
|
const key = new PluginKey('guidelinePlugin');
|
|
6
|
-
const displayGuideline =
|
|
7
|
-
const
|
|
20
|
+
const displayGuideline = view => props => {
|
|
21
|
+
const {
|
|
22
|
+
dispatch,
|
|
23
|
+
state
|
|
24
|
+
} = view;
|
|
25
|
+
const tr = state.tr.setMeta(key, props);
|
|
26
|
+
dispatch(tr);
|
|
27
|
+
return true;
|
|
28
|
+
};
|
|
29
|
+
export const EMPTY_STATE = {
|
|
8
30
|
guidelines: []
|
|
9
31
|
};
|
|
10
32
|
const guidelinePMPlugin = new SafePlugin({
|
|
@@ -31,10 +53,18 @@ const ContentComponent = ({
|
|
|
31
53
|
widthState,
|
|
32
54
|
guidelineState
|
|
33
55
|
} = useSharedPluginState(api, ['width', 'guideline']);
|
|
34
|
-
if (!guidelineState || !
|
|
56
|
+
if (!widthState || !widthState.containerWidth || !widthState.lineLength || !guidelineState || !guidelineState.guidelines || guidelineState.guidelines.length === 0) {
|
|
35
57
|
return null;
|
|
36
58
|
}
|
|
37
|
-
return
|
|
59
|
+
return jsx("div", {
|
|
60
|
+
css: guidelineStyles
|
|
61
|
+
}, jsx(GuidelineContainer, {
|
|
62
|
+
guidelines: guidelineState.guidelines,
|
|
63
|
+
height: editorView.dom.scrollHeight,
|
|
64
|
+
centerOffset: getEditorCenterX(editorView),
|
|
65
|
+
containerWidth: widthState.containerWidth,
|
|
66
|
+
editorWidth: widthState.lineLength
|
|
67
|
+
}));
|
|
38
68
|
};
|
|
39
69
|
export const guidelinePlugin = (options, api) => ({
|
|
40
70
|
name: 'guideline',
|
|
@@ -55,7 +85,7 @@ export const guidelinePlugin = (options, api) => ({
|
|
|
55
85
|
},
|
|
56
86
|
contentComponent: ({
|
|
57
87
|
editorView
|
|
58
|
-
}) =>
|
|
88
|
+
}) => jsx(ContentComponent, {
|
|
59
89
|
editorView: editorView,
|
|
60
90
|
options: options,
|
|
61
91
|
api: api
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { akEditorBreakoutPadding, akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, breakoutWideScaleRatio } from '@atlaskit/editor-shared-styles';
|
|
2
|
+
/**
|
|
3
|
+
* This function calculates the Editor's x axis of the center point
|
|
4
|
+
* in relation to the viewport
|
|
5
|
+
* @param editorView
|
|
6
|
+
* @returns x axis in number
|
|
7
|
+
*/
|
|
8
|
+
export const getEditorCenterX = editorView => {
|
|
9
|
+
const editorRect = editorView.dom.getBoundingClientRect();
|
|
10
|
+
return editorRect.width / 2 + editorRect.x;
|
|
11
|
+
};
|
|
12
|
+
const defaultGrids = [-6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6];
|
|
13
|
+
export const innerGuidelines = (editorContainerWidth, editorWidth = akEditorDefaultLayoutWidth) => {
|
|
14
|
+
const wideSpacing = editorWidth * breakoutWideScaleRatio / 2;
|
|
15
|
+
const fullWidthPadding = (akEditorBreakoutPadding + editorWidth - akEditorDefaultLayoutWidth) / 2;
|
|
16
|
+
const containerWidth = Math.min(editorContainerWidth, akEditorFullWidthLayoutWidth) / 2 - fullWidthPadding;
|
|
17
|
+
const fullWidthGuidelines = [{
|
|
18
|
+
key: `full_width_left`,
|
|
19
|
+
position: {
|
|
20
|
+
x: -containerWidth
|
|
21
|
+
}
|
|
22
|
+
}, {
|
|
23
|
+
key: `full_width_right`,
|
|
24
|
+
position: {
|
|
25
|
+
x: containerWidth
|
|
26
|
+
}
|
|
27
|
+
}];
|
|
28
|
+
const wideGuidelines = [{
|
|
29
|
+
key: `wide_left`,
|
|
30
|
+
position: {
|
|
31
|
+
x: -wideSpacing
|
|
32
|
+
}
|
|
33
|
+
}, {
|
|
34
|
+
key: `wide_right`,
|
|
35
|
+
position: {
|
|
36
|
+
x: wideSpacing
|
|
37
|
+
}
|
|
38
|
+
}];
|
|
39
|
+
const gridGuidelines = defaultGrids.map((val, index) => ({
|
|
40
|
+
key: `grid_${index}`,
|
|
41
|
+
position: {
|
|
42
|
+
x: val / 12 * editorWidth
|
|
43
|
+
}
|
|
44
|
+
}));
|
|
45
|
+
return [...gridGuidelines, ...wideGuidelines, ...fullWidthGuidelines];
|
|
46
|
+
};
|
package/dist/es2019/version.json
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { css, jsx } from '@emotion/react';
|
|
3
|
+
import { B200, N30A } from '@atlaskit/theme/colors';
|
|
4
|
+
var BasicGuidelineStyles = css({
|
|
5
|
+
borderLeft: "1px solid ".concat("var(--ds-border, ".concat(N30A, ")")),
|
|
6
|
+
position: 'absolute',
|
|
7
|
+
width: '1px',
|
|
8
|
+
height: '100%',
|
|
9
|
+
zIndex: 0,
|
|
10
|
+
opacity: 1,
|
|
11
|
+
transition: 'border-color 0.15s linear, opacity 0.15s linear'
|
|
12
|
+
});
|
|
13
|
+
var ActiveGuidelineStyles = css({
|
|
14
|
+
borderColor: "var(--ds-border-focused, ".concat(B200, ")")
|
|
15
|
+
});
|
|
16
|
+
var HiddenGuidelineStyles = css({
|
|
17
|
+
opacity: 0
|
|
18
|
+
});
|
|
19
|
+
var DashedGuidelineStyles = css({
|
|
20
|
+
borderLeftStyle: 'dashed'
|
|
21
|
+
});
|
|
22
|
+
export var Guideline = function Guideline(props) {
|
|
23
|
+
var position = props.position,
|
|
24
|
+
active = props.active,
|
|
25
|
+
_props$show = props.show,
|
|
26
|
+
show = _props$show === void 0 ? true : _props$show,
|
|
27
|
+
style = props.style;
|
|
28
|
+
return jsx("div", {
|
|
29
|
+
css: [BasicGuidelineStyles, active && ActiveGuidelineStyles, !show && HiddenGuidelineStyles, style === 'dashed' && DashedGuidelineStyles],
|
|
30
|
+
className: "guideline",
|
|
31
|
+
style: {
|
|
32
|
+
left: "".concat(position, "px")
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
/** @jsx jsx */
|
|
3
|
+
import { useLayoutEffect, useRef, useState } from 'react';
|
|
4
|
+
import { css, jsx } from '@emotion/react';
|
|
5
|
+
import { akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
6
|
+
import { Guideline } from './guideline';
|
|
7
|
+
var guidelineContainerStyles = css({
|
|
8
|
+
position: 'fixed',
|
|
9
|
+
height: '100vh',
|
|
10
|
+
width: '100%',
|
|
11
|
+
display: 'grid',
|
|
12
|
+
pointerEvents: 'none',
|
|
13
|
+
border: 'none',
|
|
14
|
+
maxWidth: "".concat(akEditorFullWidthLayoutWidth, "px")
|
|
15
|
+
});
|
|
16
|
+
export var GuidelineContainer = function GuidelineContainer(props) {
|
|
17
|
+
var guidelines = props.guidelines,
|
|
18
|
+
height = props.height,
|
|
19
|
+
editorWidth = props.editorWidth,
|
|
20
|
+
centerOffset = props.centerOffset;
|
|
21
|
+
var _useState = useState(0),
|
|
22
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
23
|
+
offset = _useState2[0],
|
|
24
|
+
setOffset = _useState2[1];
|
|
25
|
+
var ref = useRef(null);
|
|
26
|
+
useLayoutEffect(function () {
|
|
27
|
+
var _ref$current;
|
|
28
|
+
var rect = ref === null || ref === void 0 ? void 0 : (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.getBoundingClientRect();
|
|
29
|
+
if (rect) {
|
|
30
|
+
// X pixels from guideline container left to editor center.
|
|
31
|
+
setOffset(centerOffset - rect.x);
|
|
32
|
+
}
|
|
33
|
+
}, [centerOffset, guidelines, editorWidth]);
|
|
34
|
+
return jsx("div", {
|
|
35
|
+
ref: ref,
|
|
36
|
+
css: guidelineContainerStyles,
|
|
37
|
+
style: {
|
|
38
|
+
height: height
|
|
39
|
+
},
|
|
40
|
+
"data-testid": "guidelineContainer"
|
|
41
|
+
}, guidelines.map(function (guideline) {
|
|
42
|
+
return jsx(Guideline, {
|
|
43
|
+
key: guideline.key,
|
|
44
|
+
position: guideline.position.x + offset,
|
|
45
|
+
active: guideline.active,
|
|
46
|
+
show: guideline.show,
|
|
47
|
+
style: guideline.style
|
|
48
|
+
});
|
|
49
|
+
}));
|
|
50
|
+
};
|
package/dist/esm/plugin.js
CHANGED
|
@@ -1,10 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { css, jsx } from '@emotion/react';
|
|
2
3
|
import { PluginKey } from 'prosemirror-state';
|
|
3
4
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
4
5
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
6
|
+
import { akEditorGridLineZIndex } from '@atlaskit/editor-shared-styles';
|
|
7
|
+
import { GuidelineContainer } from './guildelineContainer';
|
|
8
|
+
import { getEditorCenterX } from './utils';
|
|
9
|
+
var guidelineStyles = css({
|
|
10
|
+
position: 'absolute',
|
|
11
|
+
width: '100%',
|
|
12
|
+
left: 0,
|
|
13
|
+
right: 0,
|
|
14
|
+
transform: "scale(1)",
|
|
15
|
+
zIndex: "".concat(akEditorGridLineZIndex, ";"),
|
|
16
|
+
display: 'flex',
|
|
17
|
+
justifyContent: 'center'
|
|
18
|
+
});
|
|
5
19
|
var key = new PluginKey('guidelinePlugin');
|
|
6
|
-
var displayGuideline = function displayGuideline(
|
|
7
|
-
|
|
20
|
+
var displayGuideline = function displayGuideline(view) {
|
|
21
|
+
return function (props) {
|
|
22
|
+
var dispatch = view.dispatch,
|
|
23
|
+
state = view.state;
|
|
24
|
+
var tr = state.tr.setMeta(key, props);
|
|
25
|
+
dispatch(tr);
|
|
26
|
+
return true;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export var EMPTY_STATE = {
|
|
8
30
|
guidelines: []
|
|
9
31
|
};
|
|
10
32
|
var guidelinePMPlugin = new SafePlugin({
|
|
@@ -29,10 +51,18 @@ var ContentComponent = function ContentComponent(_ref) {
|
|
|
29
51
|
var _useSharedPluginState = useSharedPluginState(api, ['width', 'guideline']),
|
|
30
52
|
widthState = _useSharedPluginState.widthState,
|
|
31
53
|
guidelineState = _useSharedPluginState.guidelineState;
|
|
32
|
-
if (!guidelineState || !
|
|
54
|
+
if (!widthState || !widthState.containerWidth || !widthState.lineLength || !guidelineState || !guidelineState.guidelines || guidelineState.guidelines.length === 0) {
|
|
33
55
|
return null;
|
|
34
56
|
}
|
|
35
|
-
return
|
|
57
|
+
return jsx("div", {
|
|
58
|
+
css: guidelineStyles
|
|
59
|
+
}, jsx(GuidelineContainer, {
|
|
60
|
+
guidelines: guidelineState.guidelines,
|
|
61
|
+
height: editorView.dom.scrollHeight,
|
|
62
|
+
centerOffset: getEditorCenterX(editorView),
|
|
63
|
+
containerWidth: widthState.containerWidth,
|
|
64
|
+
editorWidth: widthState.lineLength
|
|
65
|
+
}));
|
|
36
66
|
};
|
|
37
67
|
export var guidelinePlugin = function guidelinePlugin(options, api) {
|
|
38
68
|
return {
|
|
@@ -56,7 +86,7 @@ export var guidelinePlugin = function guidelinePlugin(options, api) {
|
|
|
56
86
|
},
|
|
57
87
|
contentComponent: function contentComponent(_ref2) {
|
|
58
88
|
var editorView = _ref2.editorView;
|
|
59
|
-
return
|
|
89
|
+
return jsx(ContentComponent, {
|
|
60
90
|
editorView: editorView,
|
|
61
91
|
options: options,
|
|
62
92
|
api: api
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import { akEditorBreakoutPadding, akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, breakoutWideScaleRatio } from '@atlaskit/editor-shared-styles';
|
|
3
|
+
/**
|
|
4
|
+
* This function calculates the Editor's x axis of the center point
|
|
5
|
+
* in relation to the viewport
|
|
6
|
+
* @param editorView
|
|
7
|
+
* @returns x axis in number
|
|
8
|
+
*/
|
|
9
|
+
export var getEditorCenterX = function getEditorCenterX(editorView) {
|
|
10
|
+
var editorRect = editorView.dom.getBoundingClientRect();
|
|
11
|
+
return editorRect.width / 2 + editorRect.x;
|
|
12
|
+
};
|
|
13
|
+
var defaultGrids = [-6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6];
|
|
14
|
+
export var innerGuidelines = function innerGuidelines(editorContainerWidth) {
|
|
15
|
+
var editorWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : akEditorDefaultLayoutWidth;
|
|
16
|
+
var wideSpacing = editorWidth * breakoutWideScaleRatio / 2;
|
|
17
|
+
var fullWidthPadding = (akEditorBreakoutPadding + editorWidth - akEditorDefaultLayoutWidth) / 2;
|
|
18
|
+
var containerWidth = Math.min(editorContainerWidth, akEditorFullWidthLayoutWidth) / 2 - fullWidthPadding;
|
|
19
|
+
var fullWidthGuidelines = [{
|
|
20
|
+
key: "full_width_left",
|
|
21
|
+
position: {
|
|
22
|
+
x: -containerWidth
|
|
23
|
+
}
|
|
24
|
+
}, {
|
|
25
|
+
key: "full_width_right",
|
|
26
|
+
position: {
|
|
27
|
+
x: containerWidth
|
|
28
|
+
}
|
|
29
|
+
}];
|
|
30
|
+
var wideGuidelines = [{
|
|
31
|
+
key: "wide_left",
|
|
32
|
+
position: {
|
|
33
|
+
x: -wideSpacing
|
|
34
|
+
}
|
|
35
|
+
}, {
|
|
36
|
+
key: "wide_right",
|
|
37
|
+
position: {
|
|
38
|
+
x: wideSpacing
|
|
39
|
+
}
|
|
40
|
+
}];
|
|
41
|
+
var gridGuidelines = defaultGrids.map(function (val, index) {
|
|
42
|
+
return {
|
|
43
|
+
key: "grid_".concat(index),
|
|
44
|
+
position: {
|
|
45
|
+
x: val / 12 * editorWidth
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
return [].concat(_toConsumableArray(gridGuidelines), wideGuidelines, fullWidthGuidelines);
|
|
50
|
+
};
|
package/dist/esm/version.json
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx } from '@emotion/react';
|
|
2
|
+
import { GuidelineConfig } from './types';
|
|
3
|
+
type ContainerProps = {
|
|
4
|
+
guidelines: GuidelineConfig[];
|
|
5
|
+
height: number;
|
|
6
|
+
centerOffset: number;
|
|
7
|
+
containerWidth: number;
|
|
8
|
+
editorWidth: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const GuidelineContainer: (props: ContainerProps) => jsx.JSX.Element;
|
|
11
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/plugin.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { widthPlugin } from '@atlaskit/editor-plugin-width';
|
|
3
3
|
import { DisplayGuideline, GuidelinePluginState } from './types';
|
|
4
|
+
export declare const EMPTY_STATE: GuidelinePluginState;
|
|
4
5
|
export declare const guidelinePlugin: NextEditorPlugin<'guideline', {
|
|
5
6
|
dependencies: [typeof widthPlugin];
|
|
6
7
|
sharedState: GuidelinePluginState | null;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { EditorView } from 'prosemirror-view';
|
|
2
|
-
type
|
|
3
|
-
|
|
2
|
+
export type Position = {
|
|
3
|
+
x: number;
|
|
4
|
+
};
|
|
5
|
+
type GuidelineConfig = {
|
|
6
|
+
key: string;
|
|
7
|
+
position: Position;
|
|
4
8
|
active?: boolean;
|
|
5
9
|
show?: boolean;
|
|
6
10
|
style?: 'dashed' | 'solid';
|
|
7
11
|
color?: string;
|
|
8
12
|
};
|
|
9
13
|
type GuidelinePluginState = {
|
|
10
|
-
guidelines:
|
|
14
|
+
guidelines: GuidelineConfig[];
|
|
11
15
|
};
|
|
12
16
|
interface GuidelinePluginOptions {
|
|
13
17
|
}
|
|
14
|
-
type
|
|
15
|
-
|
|
18
|
+
type DisplayGrid = (props: Required<GuidelinePluginState>) => boolean;
|
|
19
|
+
type DisplayGuideline = (view: EditorView) => DisplayGrid;
|
|
20
|
+
export type { GuidelinePluginState, GuidelinePluginOptions, GuidelineConfig, DisplayGuideline, };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { EditorView } from 'prosemirror-view';
|
|
2
|
+
import { GuidelineConfig } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* This function calculates the Editor's x axis of the center point
|
|
5
|
+
* in relation to the viewport
|
|
6
|
+
* @param editorView
|
|
7
|
+
* @returns x axis in number
|
|
8
|
+
*/
|
|
9
|
+
export declare const getEditorCenterX: (editorView: EditorView) => number;
|
|
10
|
+
export declare const innerGuidelines: (editorContainerWidth: number, editorWidth?: number) => GuidelineConfig[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx } from '@emotion/react';
|
|
2
|
+
import { GuidelineConfig } from './types';
|
|
3
|
+
type ContainerProps = {
|
|
4
|
+
guidelines: GuidelineConfig[];
|
|
5
|
+
height: number;
|
|
6
|
+
centerOffset: number;
|
|
7
|
+
containerWidth: number;
|
|
8
|
+
editorWidth: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const GuidelineContainer: (props: ContainerProps) => jsx.JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { widthPlugin } from '@atlaskit/editor-plugin-width';
|
|
3
3
|
import { DisplayGuideline, GuidelinePluginState } from './types';
|
|
4
|
+
export declare const EMPTY_STATE: GuidelinePluginState;
|
|
4
5
|
export declare const guidelinePlugin: NextEditorPlugin<'guideline', {
|
|
5
6
|
dependencies: [
|
|
6
7
|
typeof widthPlugin
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { EditorView } from 'prosemirror-view';
|
|
2
|
-
type
|
|
3
|
-
|
|
2
|
+
export type Position = {
|
|
3
|
+
x: number;
|
|
4
|
+
};
|
|
5
|
+
type GuidelineConfig = {
|
|
6
|
+
key: string;
|
|
7
|
+
position: Position;
|
|
4
8
|
active?: boolean;
|
|
5
9
|
show?: boolean;
|
|
6
10
|
style?: 'dashed' | 'solid';
|
|
7
11
|
color?: string;
|
|
8
12
|
};
|
|
9
13
|
type GuidelinePluginState = {
|
|
10
|
-
guidelines:
|
|
14
|
+
guidelines: GuidelineConfig[];
|
|
11
15
|
};
|
|
12
16
|
interface GuidelinePluginOptions {
|
|
13
17
|
}
|
|
14
|
-
type
|
|
15
|
-
|
|
18
|
+
type DisplayGrid = (props: Required<GuidelinePluginState>) => boolean;
|
|
19
|
+
type DisplayGuideline = (view: EditorView) => DisplayGrid;
|
|
20
|
+
export type { GuidelinePluginState, GuidelinePluginOptions, GuidelineConfig, DisplayGuideline, };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { EditorView } from 'prosemirror-view';
|
|
2
|
+
import { GuidelineConfig } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* This function calculates the Editor's x axis of the center point
|
|
5
|
+
* in relation to the viewport
|
|
6
|
+
* @param editorView
|
|
7
|
+
* @returns x axis in number
|
|
8
|
+
*/
|
|
9
|
+
export declare const getEditorCenterX: (editorView: EditorView) => number;
|
|
10
|
+
export declare const innerGuidelines: (editorContainerWidth: number, editorWidth?: number) => GuidelineConfig[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-guideline",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "guideline plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -22,9 +22,13 @@
|
|
|
22
22
|
".": "./src/index.ts"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@atlaskit/editor-common": "^74.
|
|
25
|
+
"@atlaskit/editor-common": "^74.4.0",
|
|
26
26
|
"@atlaskit/editor-plugin-width": "^0.0.1",
|
|
27
|
+
"@atlaskit/editor-shared-styles": "^2.4.0",
|
|
28
|
+
"@atlaskit/theme": "^12.5.0",
|
|
29
|
+
"@atlaskit/tokens": "^1.4.2",
|
|
27
30
|
"@babel/runtime": "^7.0.0",
|
|
31
|
+
"@emotion/react": "^11.7.1",
|
|
28
32
|
"prosemirror-state": "1.3.4",
|
|
29
33
|
"prosemirror-view": "1.23.7"
|
|
30
34
|
},
|
|
@@ -33,8 +37,8 @@
|
|
|
33
37
|
},
|
|
34
38
|
"devDependencies": {
|
|
35
39
|
"@atlaskit/docs": "*",
|
|
36
|
-
"@atlaskit/editor-core": "^
|
|
37
|
-
"@atlaskit/editor-test-helpers": "^18.
|
|
40
|
+
"@atlaskit/editor-core": "^185.1.0",
|
|
41
|
+
"@atlaskit/editor-test-helpers": "^18.5.0",
|
|
38
42
|
"@atlaskit/ssr": "*",
|
|
39
43
|
"@atlaskit/visual-regression": "*",
|
|
40
44
|
"@atlaskit/webdriver-runner": "*",
|
package/report.api.md
CHANGED
|
@@ -20,17 +20,31 @@ import { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
|
20
20
|
import type { widthPlugin } from '@atlaskit/editor-plugin-width';
|
|
21
21
|
|
|
22
22
|
// @public (undocumented)
|
|
23
|
-
type
|
|
23
|
+
type DisplayGrid = (props: Required<GuidelinePluginState>) => boolean;
|
|
24
24
|
|
|
25
25
|
// @public (undocumented)
|
|
26
|
-
type
|
|
27
|
-
|
|
26
|
+
type DisplayGuideline = (view: EditorView) => DisplayGrid;
|
|
27
|
+
|
|
28
|
+
// @public (undocumented)
|
|
29
|
+
export type GuidelineConfig = {
|
|
30
|
+
key: string;
|
|
31
|
+
position: GuidelinePosition;
|
|
28
32
|
active?: boolean;
|
|
29
33
|
show?: boolean;
|
|
30
34
|
style?: 'dashed' | 'solid';
|
|
31
35
|
color?: string;
|
|
32
36
|
};
|
|
33
37
|
|
|
38
|
+
// @public (undocumented)
|
|
39
|
+
enum GuidelineContainerArea {
|
|
40
|
+
// (undocumented)
|
|
41
|
+
EditorContent = 'editorContent',
|
|
42
|
+
// (undocumented)
|
|
43
|
+
EditorLeftMargin = 'editorLeftMargin',
|
|
44
|
+
// (undocumented)
|
|
45
|
+
EditorRightMargin = 'editorRightMargin',
|
|
46
|
+
}
|
|
47
|
+
|
|
34
48
|
// @public (undocumented)
|
|
35
49
|
export const guidelinePlugin: NextEditorPlugin<
|
|
36
50
|
'guideline',
|
|
@@ -45,9 +59,28 @@ export const guidelinePlugin: NextEditorPlugin<
|
|
|
45
59
|
|
|
46
60
|
// @public (undocumented)
|
|
47
61
|
type GuidelinePluginState = {
|
|
48
|
-
guidelines:
|
|
62
|
+
guidelines: GuidelineConfig[];
|
|
49
63
|
};
|
|
50
64
|
|
|
65
|
+
// @public (undocumented)
|
|
66
|
+
type GuidelinePosition = {
|
|
67
|
+
containerArea?: GuidelineContainerArea;
|
|
68
|
+
} & PositionSide;
|
|
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`;
|
|
83
|
+
|
|
51
84
|
// (No @packageDocumentation comment for this package)
|
|
52
85
|
```
|
|
53
86
|
|