@atlaskit/editor-plugin-rule 18.0.0 → 18.1.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.
Files changed (43) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/pm-plugins/commands.js +69 -2
  3. package/dist/cjs/rulePlugin.js +1 -1
  4. package/dist/cjs/ui/DividerOptions.compiled.css +12 -0
  5. package/dist/cjs/ui/DividerOptions.js +165 -0
  6. package/dist/cjs/ui/constants.js +8 -0
  7. package/dist/cjs/ui/icons/DashedStrokeIcon.js +33 -0
  8. package/dist/cjs/ui/icons/DottedStrokeIcon.js +34 -0
  9. package/dist/cjs/ui/icons/FadeStrokeIcon.js +43 -0
  10. package/dist/cjs/ui/icons/SketchStrokeIcon.js +24 -0
  11. package/dist/cjs/ui/icons/SolidStrokeIcon.js +32 -0
  12. package/dist/cjs/ui/toolbar.js +39 -8
  13. package/dist/es2019/pm-plugins/commands.js +66 -1
  14. package/dist/es2019/rulePlugin.js +2 -2
  15. package/dist/es2019/ui/DividerOptions.compiled.css +12 -0
  16. package/dist/es2019/ui/DividerOptions.js +147 -0
  17. package/dist/es2019/ui/constants.js +2 -0
  18. package/dist/es2019/ui/icons/DashedStrokeIcon.js +24 -0
  19. package/dist/es2019/ui/icons/DottedStrokeIcon.js +25 -0
  20. package/dist/es2019/ui/icons/FadeStrokeIcon.js +34 -0
  21. package/dist/es2019/ui/icons/SketchStrokeIcon.js +15 -0
  22. package/dist/es2019/ui/icons/SolidStrokeIcon.js +23 -0
  23. package/dist/es2019/ui/toolbar.js +39 -9
  24. package/dist/esm/pm-plugins/commands.js +67 -1
  25. package/dist/esm/rulePlugin.js +2 -2
  26. package/dist/esm/ui/DividerOptions.compiled.css +12 -0
  27. package/dist/esm/ui/DividerOptions.js +156 -0
  28. package/dist/esm/ui/constants.js +2 -0
  29. package/dist/esm/ui/icons/DashedStrokeIcon.js +26 -0
  30. package/dist/esm/ui/icons/DottedStrokeIcon.js +27 -0
  31. package/dist/esm/ui/icons/FadeStrokeIcon.js +36 -0
  32. package/dist/esm/ui/icons/SketchStrokeIcon.js +17 -0
  33. package/dist/esm/ui/icons/SolidStrokeIcon.js +25 -0
  34. package/dist/esm/ui/toolbar.js +40 -9
  35. package/dist/types/pm-plugins/commands.d.ts +3 -0
  36. package/dist/types/ui/DividerOptions.d.ts +14 -0
  37. package/dist/types/ui/constants.d.ts +5 -0
  38. package/dist/types/ui/icons/DashedStrokeIcon.d.ts +2 -0
  39. package/dist/types/ui/icons/DottedStrokeIcon.d.ts +2 -0
  40. package/dist/types/ui/icons/FadeStrokeIcon.d.ts +2 -0
  41. package/dist/types/ui/icons/SketchStrokeIcon.d.ts +2 -0
  42. package/dist/types/ui/icons/SolidStrokeIcon.d.ts +2 -0
  43. package/package.json +9 -4
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ var CustomGlyph = function CustomGlyph() {
3
+ return /*#__PURE__*/React.createElement("svg", {
4
+ width: "44",
5
+ height: "8",
6
+ viewBox: "0 0 44 8",
7
+ fill: "none",
8
+ xmlns: "http://www.w3.org/2000/svg"
9
+ }, /*#__PURE__*/React.createElement("g", {
10
+ clipPath: "url(#clip0_238_17349)"
11
+ }, /*#__PURE__*/React.createElement("path", {
12
+ d: "M-78 4H122",
13
+ stroke: "var(--ds-icon-subtle, #505258)",
14
+ strokeWidth: "2",
15
+ strokeDasharray: "4 6"
16
+ })), /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("clipPath", {
17
+ id: "clip0_238_17349"
18
+ }, /*#__PURE__*/React.createElement("rect", {
19
+ width: "44",
20
+ height: "8",
21
+ fill: "white"
22
+ }))));
23
+ };
24
+ export var DashedStrokeIcon = function DashedStrokeIcon() {
25
+ return /*#__PURE__*/React.createElement(CustomGlyph, null);
26
+ };
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ var CustomGlyph = function CustomGlyph() {
3
+ return /*#__PURE__*/React.createElement("svg", {
4
+ width: "44",
5
+ height: "8",
6
+ viewBox: "0 0 44 8",
7
+ fill: "none",
8
+ xmlns: "http://www.w3.org/2000/svg"
9
+ }, /*#__PURE__*/React.createElement("g", {
10
+ clipPath: "url(#clip0_238_2909)"
11
+ }, /*#__PURE__*/React.createElement("path", {
12
+ d: "M-78 4H122",
13
+ stroke: "var(--ds-icon, #292A2E)",
14
+ strokeWidth: "2",
15
+ strokeLinecap: "round",
16
+ strokeDasharray: "0.01 6"
17
+ })), /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("clipPath", {
18
+ id: "clip0_238_2909"
19
+ }, /*#__PURE__*/React.createElement("rect", {
20
+ width: "44",
21
+ height: "8",
22
+ fill: "white"
23
+ }))));
24
+ };
25
+ export var DottedStrokeIcon = function DottedStrokeIcon() {
26
+ return /*#__PURE__*/React.createElement(CustomGlyph, null);
27
+ };
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+ var CustomGlyph = function CustomGlyph() {
3
+ return /*#__PURE__*/React.createElement("svg", {
4
+ width: "79",
5
+ height: "2",
6
+ viewBox: "0 0 79 2",
7
+ fill: "none",
8
+ xmlns: "http://www.w3.org/2000/svg"
9
+ }, /*#__PURE__*/React.createElement("path", {
10
+ d: "M0 1C1.31667 1.06667 2.63333 1.13 3.95 1.19C15.8 1.73 27.65 2 39.5 2C51.35 2 63.2 1.73 75.05 1.19C76.3667 1.13 77.6833 1.06667 79 1C77.6833 0.933333 76.3667 0.87 75.05 0.81C63.2 0.27 51.35 0 39.5 0C27.65 0 15.8 0.27 3.95 0.81C2.63333 0.87 1.31667 0.933333 0 1Z",
11
+ fill: "url(#paint0_linear_238_2941)"
12
+ }), /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("linearGradient", {
13
+ id: "paint0_linear_238_2941",
14
+ x1: "0",
15
+ y1: "1.5",
16
+ x2: "79",
17
+ y2: "1.5",
18
+ gradientUnits: "userSpaceOnUse"
19
+ }, /*#__PURE__*/React.createElement("stop", {
20
+ stopColor: "var(--ds-icon, #292A2E)",
21
+ stopOpacity: 0
22
+ }), /*#__PURE__*/React.createElement("stop", {
23
+ offset: "0.274038",
24
+ stopColor: "var(--ds-icon, #292A2E)"
25
+ }), /*#__PURE__*/React.createElement("stop", {
26
+ offset: "0.740385",
27
+ stopColor: "var(--ds-icon, #292A2E)"
28
+ }), /*#__PURE__*/React.createElement("stop", {
29
+ offset: "1",
30
+ stopColor: "var(--ds-icon, #292A2E)",
31
+ stopOpacity: 0
32
+ }))));
33
+ };
34
+ export var FadeStrokeIcon = function FadeStrokeIcon() {
35
+ return /*#__PURE__*/React.createElement(CustomGlyph, null);
36
+ };
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ var CustomGlyph = function CustomGlyph() {
3
+ return /*#__PURE__*/React.createElement("svg", {
4
+ width: "83",
5
+ height: "6",
6
+ viewBox: "0 0 83 6",
7
+ fill: "none",
8
+ xmlns: "http://www.w3.org/2000/svg"
9
+ }, /*#__PURE__*/React.createElement("path", {
10
+ d: "M0.428223 4.0112C0.428223 4.0112 6.35543 1.20063 10.4282 1.0112C15.2535 0.786762 17.5977 4.0112 22.4282 4.0112C27.2587 4.0112 29.5977 1.01007 34.4282 1.0112C38.8335 1.01222 41.0265 3.33342 45.4282 3.5112C50.7856 3.72757 53.5691 0.845277 58.9282 1.0112C63.5219 1.15342 65.8325 3.47137 70.4282 3.5112C75.215 3.55267 77.6415 1.04949 82.4282 1.0112",
11
+ stroke: "var(--ds-icon, #292A2E)",
12
+ strokeWidth: "2"
13
+ }));
14
+ };
15
+ export var SketchStrokeIcon = function SketchStrokeIcon() {
16
+ return /*#__PURE__*/React.createElement(CustomGlyph, null);
17
+ };
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ var CustomGlyph = function CustomGlyph() {
3
+ return /*#__PURE__*/React.createElement("svg", {
4
+ width: "44",
5
+ height: "8",
6
+ viewBox: "0 0 44 8",
7
+ fill: "none",
8
+ xmlns: "http://www.w3.org/2000/svg"
9
+ }, /*#__PURE__*/React.createElement("g", {
10
+ clipPath: "url(#clip0_238_17340)"
11
+ }, /*#__PURE__*/React.createElement("path", {
12
+ d: "M-78 4H122",
13
+ stroke: "var(--ds-icon, #292A2E)",
14
+ strokeWidth: "2"
15
+ })), /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("clipPath", {
16
+ id: "clip0_238_17340"
17
+ }, /*#__PURE__*/React.createElement("rect", {
18
+ width: "44",
19
+ height: "8",
20
+ fill: "white"
21
+ }))));
22
+ };
23
+ export var SolidStrokeIcon = function SolidStrokeIcon() {
24
+ return /*#__PURE__*/React.createElement(CustomGlyph, null);
25
+ };
@@ -5,12 +5,15 @@ import React from 'react';
5
5
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
6
6
  import { findDomRefAtPos, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
7
7
  import commonMessages from '@atlaskit/editor-common/messages';
8
+ import { ruleMessages } from '@atlaskit/editor-common/messages/rule';
8
9
  import { akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
9
10
  import CopyIcon from '@atlaskit/icon/core/copy';
11
+ import CustomizeIcon from '@atlaskit/icon/core/customize';
10
12
  import DeleteIcon from '@atlaskit/icon/core/delete';
11
- import { removeHorizontalRule } from '../pm-plugins/commands';
12
- var getToolbarItems = function getToolbarItems(formatMessage, ruleNodeType, api) {
13
- var _api$decorations, _api$analytics;
13
+ import { removeHorizontalRule, updateHorizontalRuleStyle, updateHorizontalRuleWeight } from '../pm-plugins/commands';
14
+ import { DividerOptions } from './DividerOptions';
15
+ var getToolbarItems = function getToolbarItems(formatMessage, ruleNodeType, ruleAttrs, api) {
16
+ var _api$decorations, _api$analytics3;
14
17
  var hoverDecoration = api === null || api === void 0 || (_api$decorations = api.decorations) === null || _api$decorations === void 0 ? void 0 : _api$decorations.actions.hoverDecoration;
15
18
  var hoverDecorationProps = function hoverDecorationProps(className) {
16
19
  return {
@@ -20,7 +23,35 @@ var getToolbarItems = function getToolbarItems(formatMessage, ruleNodeType, api)
20
23
  onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(ruleNodeType, false, className)
21
24
  };
22
25
  };
23
- var items = [];
26
+ var items = [{
27
+ id: 'divider-options',
28
+ type: 'dropdown',
29
+ testId: 'divider-options',
30
+ title: formatMessage(ruleMessages.dividerOptions),
31
+ iconBefore: CustomizeIcon,
32
+ options: {
33
+ width: 272,
34
+ height: 184,
35
+ render: function render(_ref) {
36
+ var dispatchCommand = _ref.dispatchCommand;
37
+ return /*#__PURE__*/React.createElement(DividerOptions, {
38
+ style: ruleAttrs.style,
39
+ weight: ruleAttrs.weight,
40
+ onStyleChange: function onStyleChange(style) {
41
+ var _api$analytics;
42
+ return dispatchCommand(updateHorizontalRuleStyle(style, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions));
43
+ },
44
+ onWeightChange: function onWeightChange(weight) {
45
+ var _api$analytics2;
46
+ return dispatchCommand(updateHorizontalRuleWeight(weight, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions));
47
+ }
48
+ });
49
+ }
50
+ }
51
+ }, {
52
+ type: 'separator',
53
+ fullHeight: true
54
+ }];
24
55
  var overflowMenuItems = [{
25
56
  type: 'overflow-dropdown',
26
57
  options: [_objectSpread({
@@ -38,7 +69,7 @@ var getToolbarItems = function getToolbarItems(formatMessage, ruleNodeType, api)
38
69
  icon: /*#__PURE__*/React.createElement(DeleteIcon, {
39
70
  label: ""
40
71
  }),
41
- onClick: removeHorizontalRule(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)
72
+ onClick: removeHorizontalRule(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions)
42
73
  }, hoverDecorationProps())]
43
74
  }];
44
75
  items.push.apply(items, overflowMenuItems);
@@ -48,8 +79,8 @@ export var getToolbarConfig = function getToolbarConfig(state, intl, api) {
48
79
  var formatMessage = intl.formatMessage;
49
80
  var selection = state.selection;
50
81
  var rule = state.schema.nodes.rule;
51
- var isRuleSelection = findSelectedNodeOfType(state.schema.nodes.rule)(state.selection);
52
- if (!isRuleSelection) {
82
+ var ruleNode = findSelectedNodeOfType(state.schema.nodes.rule)(state.selection);
83
+ if (!ruleNode) {
53
84
  return undefined;
54
85
  }
55
86
  var getDomRef = function getDomRef(editorView) {
@@ -58,10 +89,10 @@ export var getToolbarConfig = function getToolbarConfig(state, intl, api) {
58
89
  return element;
59
90
  };
60
91
  return {
61
- title: 'Divider floating controls',
92
+ title: formatMessage(ruleMessages.dividerFloatingControls),
62
93
  getDomRef: getDomRef,
63
94
  nodeType: [rule],
64
- items: getToolbarItems(formatMessage, rule, api),
95
+ items: getToolbarItems(formatMessage, rule, ruleNode.node.attrs, api),
65
96
  scrollable: true
66
97
  };
67
98
  };
@@ -1,5 +1,8 @@
1
1
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
2
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
3
  import type { Command } from '@atlaskit/editor-common/types';
4
+ import { type DividerStyle, type DividerWeight } from '../ui/constants';
4
5
  export declare const insertHorizontalRule: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (inputMethod: INPUT_METHOD.ELEMENT_BROWSER | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.TOOLBAR | INPUT_METHOD.INSERT_MENU | INPUT_METHOD.FORMATTING | INPUT_METHOD.SHORTCUT) => Command;
5
6
  export declare const removeHorizontalRule: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
7
+ export declare const updateHorizontalRuleWeight: (weight: DividerWeight, editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
8
+ export declare const updateHorizontalRuleStyle: (style: DividerStyle, editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
5
+ import React from 'react';
6
+ import { type DividerStyle, type DividerWeight } from './constants';
7
+ type DividerOptionsProps = {
8
+ onStyleChange?: (style: DividerStyle) => void;
9
+ onWeightChange?: (weight: DividerWeight) => void;
10
+ style?: DividerStyle | null;
11
+ weight?: DividerWeight | null;
12
+ };
13
+ export declare const DividerOptions: ({ onStyleChange, onWeightChange, style, weight, }: DividerOptionsProps) => React.JSX.Element;
14
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { RuleStyle } from '@atlaskit/adf-schema/rule';
2
+ export declare const DEFAULT_DIVIDER_STYLE = "solid";
3
+ export declare const DEFAULT_DIVIDER_WEIGHT = 2;
4
+ export type DividerStyle = RuleStyle;
5
+ export type DividerWeight = 1 | 2 | 3;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const DashedStrokeIcon: () => React.JSX.Element;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const DottedStrokeIcon: () => React.JSX.Element;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const FadeStrokeIcon: () => React.JSX.Element;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const SketchStrokeIcon: () => React.JSX.Element;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const SolidStrokeIcon: () => React.JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-rule",
3
- "version": "18.0.0",
3
+ "version": "18.1.1",
4
4
  "description": "Rule plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -20,20 +20,25 @@
20
20
  "atlaskit:src": "src/index.ts",
21
21
  "dependencies": {
22
22
  "@atlaskit/adf-schema": "^57.4.0",
23
+ "@atlaskit/button": "^25.3.0",
24
+ "@atlaskit/css": "^1.1.0",
23
25
  "@atlaskit/editor-plugin-analytics": "^18.0.0",
24
26
  "@atlaskit/editor-plugin-floating-toolbar": "^20.0.0",
25
27
  "@atlaskit/editor-plugin-ui-control-registry": "^12.0.0",
26
28
  "@atlaskit/editor-prosemirror": "^8.0.0",
27
- "@atlaskit/editor-shared-styles": "^4.2.0",
28
- "@atlaskit/icon": "^37.6.0",
29
+ "@atlaskit/editor-shared-styles": "^4.3.0",
30
+ "@atlaskit/icon": "^37.7.0",
29
31
  "@atlaskit/platform-feature-experiments": "^0.3.0",
30
32
  "@atlaskit/platform-feature-flags": "^2.2.0",
33
+ "@atlaskit/primitives": "^22.5.0",
31
34
  "@atlaskit/prosemirror-input-rules": "^4.1.0",
35
+ "@atlaskit/tokens": "^17.0.0",
32
36
  "@babel/runtime": "^7.0.0",
37
+ "@compiled/react": "^1.0.2",
33
38
  "react-intl": "^7.0.0"
34
39
  },
35
40
  "peerDependencies": {
36
- "@atlaskit/editor-common": "^122.0.0",
41
+ "@atlaskit/editor-common": "^122.6.0",
37
42
  "react": "^18.2.0 || ^19.2.0",
38
43
  "react-dom": "^18.2.0 || ^19.2.0"
39
44
  },