@atlaskit/editor-plugin-guideline 0.2.0 → 0.3.1
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 +18 -0
- package/dist/cjs/guideline.js +21 -12
- package/dist/cjs/guildelineContainer.js +32 -46
- package/dist/cjs/plugin.js +4 -2
- package/dist/cjs/types.js +1 -9
- package/dist/cjs/utils.js +59 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/guideline.js +26 -16
- package/dist/es2019/guildelineContainer.js +23 -39
- package/dist/es2019/plugin.js +4 -2
- package/dist/es2019/types.js +1 -6
- package/dist/es2019/utils.js +46 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/guideline.js +22 -13
- package/dist/esm/guildelineContainer.js +27 -43
- package/dist/esm/plugin.js +4 -2
- package/dist/esm/types.js +1 -6
- package/dist/esm/utils.js +50 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/guideline.d.ts +4 -2
- package/dist/types/guildelineContainer.d.ts +3 -3
- package/dist/types/types.d.ts +4 -17
- package/dist/types/utils.d.ts +10 -0
- package/dist/types-ts4.5/guideline.d.ts +4 -2
- package/dist/types-ts4.5/guildelineContainer.d.ts +3 -3
- package/dist/types-ts4.5/types.d.ts +4 -17
- package/dist/types-ts4.5/utils.d.ts +10 -0
- package/package.json +5 -5
- package/report.api.md +4 -28
- package/tmp/api-report-tmp.d.ts +48 -0
- package/dist/cjs/constants.js +0 -17
- package/dist/es2019/constants.js +0 -6
- package/dist/esm/constants.js +0 -9
- package/dist/types/constants.d.ts +0 -2
- package/dist/types-ts4.5/constants.d.ts +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-guideline
|
|
2
2
|
|
|
3
|
+
## 0.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`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).
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
10
|
+
## 0.3.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- [`d7aa08972c6`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d7aa08972c6) - add style handler for the editor guideline plugin
|
|
15
|
+
- [`1dadcae5b09`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1dadcae5b09) - COLLAB-2623 Updated API to newest interface and added utils to create default gridlines
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 0.2.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
package/dist/cjs/guideline.js
CHANGED
|
@@ -14,21 +14,30 @@ var BasicGuidelineStyles = (0, _react.css)({
|
|
|
14
14
|
width: '1px',
|
|
15
15
|
height: '100%',
|
|
16
16
|
zIndex: 0,
|
|
17
|
-
|
|
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'
|
|
18
28
|
});
|
|
19
|
-
var positionToStyle = function positionToStyle(position) {
|
|
20
|
-
var left = position.left,
|
|
21
|
-
right = position.right;
|
|
22
|
-
return left ? {
|
|
23
|
-
left: left
|
|
24
|
-
} : {
|
|
25
|
-
right: right
|
|
26
|
-
};
|
|
27
|
-
};
|
|
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;
|
|
29
35
|
return (0, _react.jsx)("div", {
|
|
30
|
-
css: BasicGuidelineStyles,
|
|
31
|
-
|
|
36
|
+
css: [BasicGuidelineStyles, active && ActiveGuidelineStyles, !show && HiddenGuidelineStyles, style === 'dashed' && DashedGuidelineStyles],
|
|
37
|
+
className: "guideline",
|
|
38
|
+
style: {
|
|
39
|
+
left: "".concat(position, "px")
|
|
40
|
+
}
|
|
32
41
|
});
|
|
33
42
|
};
|
|
34
43
|
exports.Guideline = Guideline;
|
|
@@ -5,15 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.GuidelineContainer = void 0;
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var _react = require("react");
|
|
10
|
+
var _react2 = require("@emotion/react");
|
|
11
11
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
12
12
|
var _guideline = require("./guideline");
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var guidelineContainerStyles = (0, _react.css)({
|
|
13
|
+
/** @jsx jsx */
|
|
14
|
+
|
|
15
|
+
var guidelineContainerStyles = (0, _react2.css)({
|
|
17
16
|
position: 'fixed',
|
|
18
17
|
height: '100vh',
|
|
19
18
|
width: '100%',
|
|
@@ -22,52 +21,39 @@ var guidelineContainerStyles = (0, _react.css)({
|
|
|
22
21
|
border: 'none',
|
|
23
22
|
maxWidth: "".concat(_editorSharedStyles.akEditorFullWidthLayoutWidth, "px")
|
|
24
23
|
});
|
|
25
|
-
var guidelineSubContainerStyles = (0, _react.css)({
|
|
26
|
-
position: 'relative'
|
|
27
|
-
});
|
|
28
|
-
var groupGuidelines = function groupGuidelines(guidelines) {
|
|
29
|
-
var _guidelines$reduce;
|
|
30
|
-
return guidelines.reduce(function (acc, curr) {
|
|
31
|
-
var areaKey = curr.position.containerArea || _types.GuidelineContainerArea.EditorContent;
|
|
32
|
-
var currentList = acc[areaKey];
|
|
33
|
-
return _objectSpread(_objectSpread({}, acc), {}, (0, _defineProperty2.default)({}, areaKey, [].concat((0, _toConsumableArray2.default)(currentList), [curr])));
|
|
34
|
-
}, (_guidelines$reduce = {}, (0, _defineProperty2.default)(_guidelines$reduce, _types.GuidelineContainerArea.EditorLeftMargin, []), (0, _defineProperty2.default)(_guidelines$reduce, _types.GuidelineContainerArea.EditorContent, []), (0, _defineProperty2.default)(_guidelines$reduce, _types.GuidelineContainerArea.EditorRightMargin, []), _guidelines$reduce));
|
|
35
|
-
};
|
|
36
|
-
var GuidelineSubContainer = function GuidelineSubContainer(props) {
|
|
37
|
-
return (0, _react.jsx)("div", {
|
|
38
|
-
css: guidelineSubContainerStyles,
|
|
39
|
-
"data-container-id": props.containerId
|
|
40
|
-
}, props.guidelines.map(function (guideline) {
|
|
41
|
-
return (0, _react.jsx)(_guideline.Guideline, {
|
|
42
|
-
key: guideline.key,
|
|
43
|
-
position: guideline.position
|
|
44
|
-
});
|
|
45
|
-
}));
|
|
46
|
-
};
|
|
47
24
|
var GuidelineContainer = function GuidelineContainer(props) {
|
|
48
25
|
var guidelines = props.guidelines,
|
|
49
26
|
height = props.height,
|
|
50
|
-
editorWidth = props.editorWidth
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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,
|
|
56
44
|
css: guidelineContainerStyles,
|
|
57
45
|
style: {
|
|
58
|
-
height: height
|
|
59
|
-
gridTemplateColumns: "[left] auto [editor] ".concat(editorWidth, "px [right] auto")
|
|
46
|
+
height: height
|
|
60
47
|
},
|
|
61
48
|
"data-testid": "guidelineContainer"
|
|
62
|
-
}, (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
guidelines: guidelineGroups[_types.GuidelineContainerArea.EditorRightMargin]
|
|
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
|
+
});
|
|
71
57
|
}));
|
|
72
58
|
};
|
|
73
59
|
exports.GuidelineContainer = GuidelineContainer;
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -10,6 +10,7 @@ var _hooks = require("@atlaskit/editor-common/hooks");
|
|
|
10
10
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
11
11
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
12
12
|
var _guildelineContainer = require("./guildelineContainer");
|
|
13
|
+
var _utils = require("./utils");
|
|
13
14
|
/** @jsx jsx */
|
|
14
15
|
|
|
15
16
|
var guidelineStyles = (0, _react.css)({
|
|
@@ -58,7 +59,7 @@ var ContentComponent = function ContentComponent(_ref) {
|
|
|
58
59
|
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['width', 'guideline']),
|
|
59
60
|
widthState = _useSharedPluginState.widthState,
|
|
60
61
|
guidelineState = _useSharedPluginState.guidelineState;
|
|
61
|
-
if (!widthState || !widthState.
|
|
62
|
+
if (!widthState || !widthState.width || !widthState.lineLength || !guidelineState || !guidelineState.guidelines || guidelineState.guidelines.length === 0) {
|
|
62
63
|
return null;
|
|
63
64
|
}
|
|
64
65
|
return (0, _react.jsx)("div", {
|
|
@@ -66,7 +67,8 @@ var ContentComponent = function ContentComponent(_ref) {
|
|
|
66
67
|
}, (0, _react.jsx)(_guildelineContainer.GuidelineContainer, {
|
|
67
68
|
guidelines: guidelineState.guidelines,
|
|
68
69
|
height: editorView.dom.scrollHeight,
|
|
69
|
-
|
|
70
|
+
centerOffset: (0, _utils.getEditorCenterX)(editorView),
|
|
71
|
+
width: widthState.width,
|
|
70
72
|
editorWidth: widthState.lineLength
|
|
71
73
|
}));
|
|
72
74
|
};
|
package/dist/cjs/types.js
CHANGED
|
@@ -2,12 +2,4 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.GuidelineContainerArea = void 0;
|
|
7
|
-
var GuidelineContainerArea = /*#__PURE__*/function (GuidelineContainerArea) {
|
|
8
|
-
GuidelineContainerArea["EditorLeftMargin"] = "editorLeftMargin";
|
|
9
|
-
GuidelineContainerArea["EditorContent"] = "editorContent";
|
|
10
|
-
GuidelineContainerArea["EditorRightMargin"] = "editorRightMargin";
|
|
11
|
-
return GuidelineContainerArea;
|
|
12
|
-
}({});
|
|
13
|
-
exports.GuidelineContainerArea = GuidelineContainerArea;
|
|
5
|
+
});
|
|
@@ -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
package/dist/es2019/guideline.js
CHANGED
|
@@ -1,26 +1,36 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { css, jsx } from '@emotion/react';
|
|
3
|
-
import { N30A } from '@atlaskit/theme/colors';
|
|
3
|
+
import { B200, N30A } from '@atlaskit/theme/colors';
|
|
4
4
|
const BasicGuidelineStyles = css({
|
|
5
5
|
borderLeft: `1px solid ${`var(--ds-border, ${N30A})`}`,
|
|
6
6
|
position: 'absolute',
|
|
7
7
|
width: '1px',
|
|
8
8
|
height: '100%',
|
|
9
9
|
zIndex: 0,
|
|
10
|
-
|
|
10
|
+
opacity: 1,
|
|
11
|
+
transition: 'border-color 0.15s linear, opacity 0.15s linear'
|
|
11
12
|
});
|
|
12
|
-
const
|
|
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 => {
|
|
13
23
|
const {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
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
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
+
import { useLayoutEffect, useRef, useState } from 'react';
|
|
2
3
|
import { css, jsx } from '@emotion/react';
|
|
3
4
|
import { akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
4
5
|
import { Guideline } from './guideline';
|
|
5
|
-
import { GuidelineContainerArea as Areas } from './types';
|
|
6
6
|
const guidelineContainerStyles = css({
|
|
7
7
|
position: 'fixed',
|
|
8
8
|
height: '100vh',
|
|
@@ -12,53 +12,37 @@ const guidelineContainerStyles = css({
|
|
|
12
12
|
border: 'none',
|
|
13
13
|
maxWidth: `${akEditorFullWidthLayoutWidth}px`
|
|
14
14
|
});
|
|
15
|
-
const guidelineSubContainerStyles = css({
|
|
16
|
-
position: 'relative'
|
|
17
|
-
});
|
|
18
|
-
const groupGuidelines = guidelines => guidelines.reduce((acc, curr) => {
|
|
19
|
-
const areaKey = curr.position.containerArea || Areas.EditorContent;
|
|
20
|
-
const currentList = acc[areaKey];
|
|
21
|
-
return {
|
|
22
|
-
...acc,
|
|
23
|
-
[areaKey]: [...currentList, curr]
|
|
24
|
-
};
|
|
25
|
-
}, {
|
|
26
|
-
[Areas.EditorLeftMargin]: [],
|
|
27
|
-
[Areas.EditorContent]: [],
|
|
28
|
-
[Areas.EditorRightMargin]: []
|
|
29
|
-
});
|
|
30
|
-
const GuidelineSubContainer = props => jsx("div", {
|
|
31
|
-
css: guidelineSubContainerStyles,
|
|
32
|
-
"data-container-id": props.containerId
|
|
33
|
-
}, props.guidelines.map(guideline => jsx(Guideline, {
|
|
34
|
-
key: guideline.key,
|
|
35
|
-
position: guideline.position
|
|
36
|
-
})));
|
|
37
15
|
export const GuidelineContainer = props => {
|
|
38
16
|
const {
|
|
39
17
|
guidelines,
|
|
40
18
|
height,
|
|
41
|
-
editorWidth
|
|
19
|
+
editorWidth,
|
|
20
|
+
centerOffset
|
|
42
21
|
} = props;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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]);
|
|
47
32
|
return jsx("div", {
|
|
33
|
+
ref: ref,
|
|
48
34
|
css: guidelineContainerStyles,
|
|
49
35
|
style: {
|
|
50
|
-
height
|
|
51
|
-
gridTemplateColumns: `[left] auto [editor] ${editorWidth}px [right] auto`
|
|
36
|
+
height
|
|
52
37
|
},
|
|
53
38
|
"data-testid": "guidelineContainer"
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
guidelines: guidelineGroups[Areas.EditorRightMargin]
|
|
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
|
+
});
|
|
63
47
|
}));
|
|
64
48
|
};
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -5,6 +5,7 @@ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
|
5
5
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
6
6
|
import { akEditorGridLineZIndex } from '@atlaskit/editor-shared-styles';
|
|
7
7
|
import { GuidelineContainer } from './guildelineContainer';
|
|
8
|
+
import { getEditorCenterX } from './utils';
|
|
8
9
|
const guidelineStyles = css({
|
|
9
10
|
position: 'absolute',
|
|
10
11
|
width: '100%',
|
|
@@ -52,7 +53,7 @@ const ContentComponent = ({
|
|
|
52
53
|
widthState,
|
|
53
54
|
guidelineState
|
|
54
55
|
} = useSharedPluginState(api, ['width', 'guideline']);
|
|
55
|
-
if (!widthState || !widthState.
|
|
56
|
+
if (!widthState || !widthState.width || !widthState.lineLength || !guidelineState || !guidelineState.guidelines || guidelineState.guidelines.length === 0) {
|
|
56
57
|
return null;
|
|
57
58
|
}
|
|
58
59
|
return jsx("div", {
|
|
@@ -60,7 +61,8 @@ const ContentComponent = ({
|
|
|
60
61
|
}, jsx(GuidelineContainer, {
|
|
61
62
|
guidelines: guidelineState.guidelines,
|
|
62
63
|
height: editorView.dom.scrollHeight,
|
|
63
|
-
|
|
64
|
+
centerOffset: getEditorCenterX(editorView),
|
|
65
|
+
width: widthState.width,
|
|
64
66
|
editorWidth: widthState.lineLength
|
|
65
67
|
}));
|
|
66
68
|
};
|
package/dist/es2019/types.js
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
GuidelineContainerArea["EditorLeftMargin"] = "editorLeftMargin";
|
|
3
|
-
GuidelineContainerArea["EditorContent"] = "editorContent";
|
|
4
|
-
GuidelineContainerArea["EditorRightMargin"] = "editorRightMargin";
|
|
5
|
-
return GuidelineContainerArea;
|
|
6
|
-
}({});
|
|
1
|
+
export {};
|
|
@@ -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
package/dist/esm/guideline.js
CHANGED
|
@@ -1,26 +1,35 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { css, jsx } from '@emotion/react';
|
|
3
|
-
import { N30A } from '@atlaskit/theme/colors';
|
|
3
|
+
import { B200, N30A } from '@atlaskit/theme/colors';
|
|
4
4
|
var BasicGuidelineStyles = css({
|
|
5
5
|
borderLeft: "1px solid ".concat("var(--ds-border, ".concat(N30A, ")")),
|
|
6
6
|
position: 'absolute',
|
|
7
7
|
width: '1px',
|
|
8
8
|
height: '100%',
|
|
9
9
|
zIndex: 0,
|
|
10
|
-
|
|
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'
|
|
11
21
|
});
|
|
12
|
-
var positionToStyle = function positionToStyle(position) {
|
|
13
|
-
var left = position.left,
|
|
14
|
-
right = position.right;
|
|
15
|
-
return left ? {
|
|
16
|
-
left: left
|
|
17
|
-
} : {
|
|
18
|
-
right: right
|
|
19
|
-
};
|
|
20
|
-
};
|
|
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;
|
|
22
28
|
return jsx("div", {
|
|
23
|
-
css: BasicGuidelineStyles,
|
|
24
|
-
|
|
29
|
+
css: [BasicGuidelineStyles, active && ActiveGuidelineStyles, !show && HiddenGuidelineStyles, style === 'dashed' && DashedGuidelineStyles],
|
|
30
|
+
className: "guideline",
|
|
31
|
+
style: {
|
|
32
|
+
left: "".concat(position, "px")
|
|
33
|
+
}
|
|
25
34
|
});
|
|
26
35
|
};
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
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; }
|
|
4
|
-
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
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
5
2
|
/** @jsx jsx */
|
|
3
|
+
import { useLayoutEffect, useRef, useState } from 'react';
|
|
6
4
|
import { css, jsx } from '@emotion/react';
|
|
7
5
|
import { akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
8
6
|
import { Guideline } from './guideline';
|
|
9
|
-
import { GuidelineContainerArea as Areas } from './types';
|
|
10
7
|
var guidelineContainerStyles = css({
|
|
11
8
|
position: 'fixed',
|
|
12
9
|
height: '100vh',
|
|
@@ -16,51 +13,38 @@ var guidelineContainerStyles = css({
|
|
|
16
13
|
border: 'none',
|
|
17
14
|
maxWidth: "".concat(akEditorFullWidthLayoutWidth, "px")
|
|
18
15
|
});
|
|
19
|
-
var guidelineSubContainerStyles = css({
|
|
20
|
-
position: 'relative'
|
|
21
|
-
});
|
|
22
|
-
var groupGuidelines = function groupGuidelines(guidelines) {
|
|
23
|
-
var _guidelines$reduce;
|
|
24
|
-
return guidelines.reduce(function (acc, curr) {
|
|
25
|
-
var areaKey = curr.position.containerArea || Areas.EditorContent;
|
|
26
|
-
var currentList = acc[areaKey];
|
|
27
|
-
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, areaKey, [].concat(_toConsumableArray(currentList), [curr])));
|
|
28
|
-
}, (_guidelines$reduce = {}, _defineProperty(_guidelines$reduce, Areas.EditorLeftMargin, []), _defineProperty(_guidelines$reduce, Areas.EditorContent, []), _defineProperty(_guidelines$reduce, Areas.EditorRightMargin, []), _guidelines$reduce));
|
|
29
|
-
};
|
|
30
|
-
var GuidelineSubContainer = function GuidelineSubContainer(props) {
|
|
31
|
-
return jsx("div", {
|
|
32
|
-
css: guidelineSubContainerStyles,
|
|
33
|
-
"data-container-id": props.containerId
|
|
34
|
-
}, props.guidelines.map(function (guideline) {
|
|
35
|
-
return jsx(Guideline, {
|
|
36
|
-
key: guideline.key,
|
|
37
|
-
position: guideline.position
|
|
38
|
-
});
|
|
39
|
-
}));
|
|
40
|
-
};
|
|
41
16
|
export var GuidelineContainer = function GuidelineContainer(props) {
|
|
42
17
|
var guidelines = props.guidelines,
|
|
43
18
|
height = props.height,
|
|
44
|
-
editorWidth = props.editorWidth
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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]);
|
|
49
34
|
return jsx("div", {
|
|
35
|
+
ref: ref,
|
|
50
36
|
css: guidelineContainerStyles,
|
|
51
37
|
style: {
|
|
52
|
-
height: height
|
|
53
|
-
gridTemplateColumns: "[left] auto [editor] ".concat(editorWidth, "px [right] auto")
|
|
38
|
+
height: height
|
|
54
39
|
},
|
|
55
40
|
"data-testid": "guidelineContainer"
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
guidelines: guidelineGroups[Areas.EditorRightMargin]
|
|
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
|
+
});
|
|
65
49
|
}));
|
|
66
50
|
};
|
package/dist/esm/plugin.js
CHANGED
|
@@ -5,6 +5,7 @@ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
|
5
5
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
6
6
|
import { akEditorGridLineZIndex } from '@atlaskit/editor-shared-styles';
|
|
7
7
|
import { GuidelineContainer } from './guildelineContainer';
|
|
8
|
+
import { getEditorCenterX } from './utils';
|
|
8
9
|
var guidelineStyles = css({
|
|
9
10
|
position: 'absolute',
|
|
10
11
|
width: '100%',
|
|
@@ -50,7 +51,7 @@ var ContentComponent = function ContentComponent(_ref) {
|
|
|
50
51
|
var _useSharedPluginState = useSharedPluginState(api, ['width', 'guideline']),
|
|
51
52
|
widthState = _useSharedPluginState.widthState,
|
|
52
53
|
guidelineState = _useSharedPluginState.guidelineState;
|
|
53
|
-
if (!widthState || !widthState.
|
|
54
|
+
if (!widthState || !widthState.width || !widthState.lineLength || !guidelineState || !guidelineState.guidelines || guidelineState.guidelines.length === 0) {
|
|
54
55
|
return null;
|
|
55
56
|
}
|
|
56
57
|
return jsx("div", {
|
|
@@ -58,7 +59,8 @@ var ContentComponent = function ContentComponent(_ref) {
|
|
|
58
59
|
}, jsx(GuidelineContainer, {
|
|
59
60
|
guidelines: guidelineState.guidelines,
|
|
60
61
|
height: editorView.dom.scrollHeight,
|
|
61
|
-
|
|
62
|
+
centerOffset: getEditorCenterX(editorView),
|
|
63
|
+
width: widthState.width,
|
|
62
64
|
editorWidth: widthState.lineLength
|
|
63
65
|
}));
|
|
64
66
|
};
|
package/dist/esm/types.js
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
GuidelineContainerArea["EditorLeftMargin"] = "editorLeftMargin";
|
|
3
|
-
GuidelineContainerArea["EditorContent"] = "editorContent";
|
|
4
|
-
GuidelineContainerArea["EditorRightMargin"] = "editorRightMargin";
|
|
5
|
-
return GuidelineContainerArea;
|
|
6
|
-
}({});
|
|
1
|
+
export {};
|
|
@@ -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
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { jsx } from '@emotion/react';
|
|
3
|
-
import { GuidelinePosition } from './types';
|
|
4
3
|
type Props = {
|
|
5
|
-
position:
|
|
4
|
+
position: number;
|
|
5
|
+
active?: boolean;
|
|
6
|
+
show?: boolean;
|
|
7
|
+
style?: 'dashed' | 'solid';
|
|
6
8
|
};
|
|
7
9
|
export declare const Guideline: (props: Props) => jsx.JSX.Element;
|
|
8
10
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
1
|
import { jsx } from '@emotion/react';
|
|
3
2
|
import { GuidelineConfig } from './types';
|
|
4
3
|
type ContainerProps = {
|
|
5
4
|
guidelines: GuidelineConfig[];
|
|
6
5
|
height: number;
|
|
7
|
-
|
|
6
|
+
centerOffset: number;
|
|
7
|
+
width: number;
|
|
8
8
|
editorWidth: number;
|
|
9
9
|
};
|
|
10
|
-
export declare const GuidelineContainer: (props: ContainerProps) => jsx.JSX.Element
|
|
10
|
+
export declare const GuidelineContainer: (props: ContainerProps) => jsx.JSX.Element;
|
|
11
11
|
export {};
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,23 +1,10 @@
|
|
|
1
1
|
import { EditorView } from 'prosemirror-view';
|
|
2
|
-
type
|
|
3
|
-
|
|
4
|
-
left: PositionValue;
|
|
5
|
-
right?: never;
|
|
6
|
-
} | {
|
|
7
|
-
right: PositionValue;
|
|
8
|
-
left?: never;
|
|
2
|
+
export type Position = {
|
|
3
|
+
x: number;
|
|
9
4
|
};
|
|
10
|
-
export declare enum GuidelineContainerArea {
|
|
11
|
-
EditorLeftMargin = "editorLeftMargin",
|
|
12
|
-
EditorContent = "editorContent",
|
|
13
|
-
EditorRightMargin = "editorRightMargin"
|
|
14
|
-
}
|
|
15
|
-
type GuidelinePosition = {
|
|
16
|
-
containerArea?: GuidelineContainerArea;
|
|
17
|
-
} & PositionSide;
|
|
18
5
|
type GuidelineConfig = {
|
|
19
6
|
key: string;
|
|
20
|
-
position:
|
|
7
|
+
position: Position;
|
|
21
8
|
active?: boolean;
|
|
22
9
|
show?: boolean;
|
|
23
10
|
style?: 'dashed' | 'solid';
|
|
@@ -30,4 +17,4 @@ interface GuidelinePluginOptions {
|
|
|
30
17
|
}
|
|
31
18
|
type DisplayGrid = (props: Required<GuidelinePluginState>) => boolean;
|
|
32
19
|
type DisplayGuideline = (view: EditorView) => DisplayGrid;
|
|
33
|
-
export type { GuidelinePluginState, GuidelinePluginOptions, GuidelineConfig,
|
|
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[];
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { jsx } from '@emotion/react';
|
|
3
|
-
import { GuidelinePosition } from './types';
|
|
4
3
|
type Props = {
|
|
5
|
-
position:
|
|
4
|
+
position: number;
|
|
5
|
+
active?: boolean;
|
|
6
|
+
show?: boolean;
|
|
7
|
+
style?: 'dashed' | 'solid';
|
|
6
8
|
};
|
|
7
9
|
export declare const Guideline: (props: Props) => jsx.JSX.Element;
|
|
8
10
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
1
|
import { jsx } from '@emotion/react';
|
|
3
2
|
import { GuidelineConfig } from './types';
|
|
4
3
|
type ContainerProps = {
|
|
5
4
|
guidelines: GuidelineConfig[];
|
|
6
5
|
height: number;
|
|
7
|
-
|
|
6
|
+
centerOffset: number;
|
|
7
|
+
width: number;
|
|
8
8
|
editorWidth: number;
|
|
9
9
|
};
|
|
10
|
-
export declare const GuidelineContainer: (props: ContainerProps) => jsx.JSX.Element
|
|
10
|
+
export declare const GuidelineContainer: (props: ContainerProps) => jsx.JSX.Element;
|
|
11
11
|
export {};
|
|
@@ -1,23 +1,10 @@
|
|
|
1
1
|
import { EditorView } from 'prosemirror-view';
|
|
2
|
-
type
|
|
3
|
-
|
|
4
|
-
left: PositionValue;
|
|
5
|
-
right?: never;
|
|
6
|
-
} | {
|
|
7
|
-
right: PositionValue;
|
|
8
|
-
left?: never;
|
|
2
|
+
export type Position = {
|
|
3
|
+
x: number;
|
|
9
4
|
};
|
|
10
|
-
export declare enum GuidelineContainerArea {
|
|
11
|
-
EditorLeftMargin = "editorLeftMargin",
|
|
12
|
-
EditorContent = "editorContent",
|
|
13
|
-
EditorRightMargin = "editorRightMargin"
|
|
14
|
-
}
|
|
15
|
-
type GuidelinePosition = {
|
|
16
|
-
containerArea?: GuidelineContainerArea;
|
|
17
|
-
} & PositionSide;
|
|
18
5
|
type GuidelineConfig = {
|
|
19
6
|
key: string;
|
|
20
|
-
position:
|
|
7
|
+
position: Position;
|
|
21
8
|
active?: boolean;
|
|
22
9
|
show?: boolean;
|
|
23
10
|
style?: 'dashed' | 'solid';
|
|
@@ -30,4 +17,4 @@ interface GuidelinePluginOptions {
|
|
|
30
17
|
}
|
|
31
18
|
type DisplayGrid = (props: Required<GuidelinePluginState>) => boolean;
|
|
32
19
|
type DisplayGuideline = (view: EditorView) => DisplayGrid;
|
|
33
|
-
export type { GuidelinePluginState, GuidelinePluginOptions, GuidelineConfig,
|
|
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.1",
|
|
4
4
|
"description": "guideline plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"atlassian": {
|
|
11
11
|
"team": "Editor",
|
|
12
|
-
"releaseModel": "
|
|
12
|
+
"releaseModel": "continuous"
|
|
13
13
|
},
|
|
14
14
|
"repository": "https://bitbucket.org/atlassian/atlassian-frontend",
|
|
15
15
|
"main": "dist/cjs/index.js",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
".": "./src/index.ts"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@atlaskit/editor-common": "^74.
|
|
26
|
-
"@atlaskit/editor-plugin-width": "^0.0
|
|
25
|
+
"@atlaskit/editor-common": "^74.5.0",
|
|
26
|
+
"@atlaskit/editor-plugin-width": "^0.1.0",
|
|
27
27
|
"@atlaskit/editor-shared-styles": "^2.4.0",
|
|
28
28
|
"@atlaskit/theme": "^12.5.0",
|
|
29
29
|
"@atlaskit/tokens": "^1.4.2",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@atlaskit/docs": "*",
|
|
40
|
-
"@atlaskit/editor-core": "^185.
|
|
40
|
+
"@atlaskit/editor-core": "^185.1.0",
|
|
41
41
|
"@atlaskit/editor-test-helpers": "^18.5.0",
|
|
42
42
|
"@atlaskit/ssr": "*",
|
|
43
43
|
"@atlaskit/visual-regression": "*",
|
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
|
+
```
|
package/dist/cjs/constants.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.DEFAULT_GRIDS = void 0;
|
|
8
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
-
var DEFAULT_GRIDS = (0, _toConsumableArray2.default)(Array(13).keys()).map(function (index) {
|
|
10
|
-
return {
|
|
11
|
-
key: "grid_".concat(index),
|
|
12
|
-
position: {
|
|
13
|
-
left: "".concat(index * 100 / 12, "%")
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
});
|
|
17
|
-
exports.DEFAULT_GRIDS = DEFAULT_GRIDS;
|
package/dist/es2019/constants.js
DELETED
package/dist/esm/constants.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
-
export var DEFAULT_GRIDS = _toConsumableArray(Array(13).keys()).map(function (index) {
|
|
3
|
-
return {
|
|
4
|
-
key: "grid_".concat(index),
|
|
5
|
-
position: {
|
|
6
|
-
left: "".concat(index * 100 / 12, "%")
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
});
|