@atlaskit/editor-plugin-text-formatting 0.3.1 → 0.4.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 CHANGED
@@ -1,5 +1,45 @@
1
1
  # @atlaskit/editor-plugin-text-formatting
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`ad3c5c21079`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ad3c5c21079) - Updating all plugins with minor version to correct issue with semver.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+
13
+ ## 0.3.2
14
+
15
+ ### Patch Changes
16
+
17
+ - [`8467bdcdf4f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8467bdcdf4f) - Removing `dependencies` prop from PluginInjectionAPI and changing
18
+ signature of `NextEditorPlugin`.
19
+
20
+ Previously a `NextEditorPlugin` would be consumed as so:
21
+
22
+ ```ts
23
+ const plugin: NextEditorPlugin< ... > = (config, api) => {
24
+ // Can use api like so:
25
+ api.dependencies.core.actions.execute( ... )
26
+ return { ... }
27
+ }
28
+ ```
29
+
30
+ Now these have become named parameters like so and the `pluginInjectionAPI` is used
31
+ without the `dependencies` prop:
32
+
33
+ ```ts
34
+ const plugin: NextEditorPlugin< ... > = ({ config, api }) => {
35
+ // Can use api like so:
36
+ api.core.actions.execute( ... )
37
+ return { ... }
38
+ }
39
+ ```
40
+
41
+ - Updated dependencies
42
+
3
43
  ## 0.3.1
4
44
 
5
45
  ### Patch Changes
package/README.md CHANGED
@@ -1,9 +1,30 @@
1
- # EditorPluginTextFormatting
1
+ # Editor plugin text formatting
2
2
 
3
- Text-formatting plugin for @atlaskit/editor-core
3
+ Text formatting plugin for @atlaskit/editor-core
4
+
5
+ **Note:** This component is designed for internal Atlassian development.
6
+ External contributors will be able to use this component but will not be able to submit issues.
7
+
8
+ ## Install
9
+ ---
10
+ - **Install** - *yarn add @atlaskit/editor-plugin-text-formatting*
11
+ - **npm** - [@atlaskit/editor-plugin-text-formatting](https://www.npmjs.com/package/@atlaskit/editor-plugin-text-formatting)
12
+ - **Source** - [Bitbucket](https://bitbucket.org/atlassian/atlassian-frontend/src/master/packages/editor/editor-plugin-text-formatting)
13
+ - **Bundle** - [unpkg.com](https://unpkg.com/@atlaskit/editor-plugin-text-formatting/dist/)
4
14
 
5
15
  ## Usage
16
+ ---
17
+ **Internal use only**
18
+
19
+ @atlaskit/editor-plugin-text-formatting is intended for internal use by the @atlaskit/editor-core and as a plugin dependency of the Editor within your product.
20
+
21
+ Direct use of this component is not supported.
6
22
 
7
- `import EditorPluginTextFormatting from '@atlaskit/editor-plugin-text-formatting';`
23
+ Please see [Atlaskit - Editor plugin text formatting](https://atlaskit.atlassian.com/packages/editor/editor-plugin-text-formatting) for documentation and examples for this package.
8
24
 
9
- Detailed docs and example usage can be found [here](https://atlaskit.atlassian.com/packages/editor/editor-plugin-text-formatting).
25
+ ## Support
26
+ ---
27
+ For internal Atlassian, visit the slack channel [#help-editor](https://atlassian.slack.com/archives/CFG3PSQ9E) for support or visit [go/editor-help](https://go/editor-help) to submit a bug.
28
+ ## License
29
+ ---
30
+ Please see [Atlassian Frontend - License](https://developer.atlassian.com/cloud/framework/atlassian-frontend/#license) for more licensing information.
@@ -17,10 +17,14 @@ var _keymap = _interopRequireDefault(require("./pm-plugins/keymap"));
17
17
  var _main = require("./pm-plugins/main");
18
18
  var _smartInputRule = _interopRequireDefault(require("./pm-plugins/smart-input-rule"));
19
19
  var _Toolbar = _interopRequireDefault(require("./ui/Toolbar"));
20
- var textFormattingPlugin = function textFormattingPlugin() {
21
- var _api$dependencies$ana7, _api$dependencies$ana8, _api$dependencies$ana9, _api$dependencies$ana10, _api$dependencies$ana11, _api$dependencies$ana12, _api$dependencies$ana13;
22
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
23
- var api = arguments.length > 1 ? arguments[1] : undefined;
20
+ /**
21
+ * Text formatting plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
22
+ * from `@atlaskit/editor-core`.
23
+ */
24
+ var textFormattingPlugin = function textFormattingPlugin(_ref) {
25
+ var _api$analytics7, _api$analytics8, _api$analytics9, _api$analytics10, _api$analytics11, _api$analytics12, _api$analytics13;
26
+ var options = _ref.config,
27
+ api = _ref.api;
24
28
  return {
25
29
  name: 'textFormatting',
26
30
  marks: function marks() {
@@ -33,13 +37,13 @@ var textFormattingPlugin = function textFormattingPlugin() {
33
37
  }, {
34
38
  name: 'strike',
35
39
  mark: _adfSchema.strike
36
- }].concat(options.disableCode ? [] : {
40
+ }].concat(options !== null && options !== void 0 && options.disableCode ? [] : {
37
41
  name: 'code',
38
42
  mark: _adfSchema.code
39
- }).concat(options.disableSuperscriptAndSubscript ? [] : {
43
+ }).concat(options !== null && options !== void 0 && options.disableSuperscriptAndSubscript ? [] : {
40
44
  name: 'subsup',
41
45
  mark: _adfSchema.subsup
42
- }).concat(options.disableUnderline ? [] : {
46
+ }).concat(options !== null && options !== void 0 && options.disableUnderline ? [] : {
43
47
  name: 'underline',
44
48
  mark: _adfSchema.underline
45
49
  });
@@ -47,10 +51,10 @@ var textFormattingPlugin = function textFormattingPlugin() {
47
51
  pmPlugins: function pmPlugins() {
48
52
  return [{
49
53
  name: 'textFormatting',
50
- plugin: function plugin(_ref) {
51
- var _api$dependencies$ana;
52
- var dispatch = _ref.dispatch;
53
- return (0, _main.plugin)(dispatch, api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions);
54
+ plugin: function plugin(_ref2) {
55
+ var _api$analytics;
56
+ var dispatch = _ref2.dispatch;
57
+ return (0, _main.plugin)(dispatch, api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
54
58
  }
55
59
  }, {
56
60
  name: 'textFormattingCursor',
@@ -59,35 +63,35 @@ var textFormattingPlugin = function textFormattingPlugin() {
59
63
  }
60
64
  }, {
61
65
  name: 'textFormattingInputRule',
62
- plugin: function plugin(_ref2) {
63
- var _api$dependencies$ana2;
64
- var schema = _ref2.schema;
65
- return (0, _inputRule.default)(schema, api === null || api === void 0 ? void 0 : (_api$dependencies$ana2 = api.dependencies.analytics) === null || _api$dependencies$ana2 === void 0 ? void 0 : _api$dependencies$ana2.actions);
66
+ plugin: function plugin(_ref3) {
67
+ var _api$analytics2;
68
+ var schema = _ref3.schema;
69
+ return (0, _inputRule.default)(schema, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions);
66
70
  }
67
71
  }, {
68
72
  name: 'textFormattingSmartRule',
69
73
  plugin: function plugin() {
70
- var _api$dependencies$ana3;
71
- return !options.disableSmartTextCompletion ? (0, _smartInputRule.default)(api === null || api === void 0 ? void 0 : (_api$dependencies$ana3 = api.dependencies.analytics) === null || _api$dependencies$ana3 === void 0 ? void 0 : _api$dependencies$ana3.actions) : undefined;
74
+ var _api$analytics3;
75
+ return !(options !== null && options !== void 0 && options.disableSmartTextCompletion) ? (0, _smartInputRule.default)(api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions) : undefined;
72
76
  }
73
77
  }, {
74
78
  name: 'textFormattingClear',
75
- plugin: function plugin(_ref3) {
76
- var dispatch = _ref3.dispatch;
79
+ plugin: function plugin(_ref4) {
80
+ var dispatch = _ref4.dispatch;
77
81
  return (0, _clearFormatting.plugin)(dispatch);
78
82
  }
79
83
  }, {
80
84
  name: 'textFormattingClearKeymap',
81
85
  plugin: function plugin() {
82
- var _api$dependencies$ana4;
83
- return (0, _clearFormattingKeymap.default)(api === null || api === void 0 ? void 0 : (_api$dependencies$ana4 = api.dependencies.analytics) === null || _api$dependencies$ana4 === void 0 ? void 0 : _api$dependencies$ana4.actions);
86
+ var _api$analytics4;
87
+ return (0, _clearFormattingKeymap.default)(api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions);
84
88
  }
85
89
  }, {
86
90
  name: 'textFormattingKeymap',
87
- plugin: function plugin(_ref4) {
88
- var _api$dependencies$ana5;
89
- var schema = _ref4.schema;
90
- return (0, _keymap.default)(schema, api === null || api === void 0 ? void 0 : (_api$dependencies$ana5 = api.dependencies.analytics) === null || _api$dependencies$ana5 === void 0 ? void 0 : _api$dependencies$ana5.actions);
91
+ plugin: function plugin(_ref5) {
92
+ var _api$analytics5;
93
+ var schema = _ref5.schema;
94
+ return (0, _keymap.default)(schema, api === null || api === void 0 ? void 0 : (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions);
91
95
  }
92
96
  }];
93
97
  },
@@ -97,20 +101,20 @@ var textFormattingPlugin = function textFormattingPlugin() {
97
101
  }
98
102
  return _main.pluginKey.getState(editorState);
99
103
  },
100
- primaryToolbarComponent: function primaryToolbarComponent(_ref5) {
101
- var editorView = _ref5.editorView,
102
- popupsMountPoint = _ref5.popupsMountPoint,
103
- popupsScrollableElement = _ref5.popupsScrollableElement,
104
- isToolbarReducedSpacing = _ref5.isToolbarReducedSpacing,
105
- toolbarSize = _ref5.toolbarSize,
106
- disabled = _ref5.disabled;
104
+ primaryToolbarComponent: function primaryToolbarComponent(_ref6) {
105
+ var editorView = _ref6.editorView,
106
+ popupsMountPoint = _ref6.popupsMountPoint,
107
+ popupsScrollableElement = _ref6.popupsScrollableElement,
108
+ isToolbarReducedSpacing = _ref6.isToolbarReducedSpacing,
109
+ toolbarSize = _ref6.toolbarSize,
110
+ disabled = _ref6.disabled;
107
111
  return /*#__PURE__*/_react.default.createElement(_withPluginState.WithPluginState, {
108
112
  plugins: {
109
113
  textFormattingState: _main.pluginKey,
110
114
  clearFormattingPluginState: _clearFormatting.pluginKey
111
115
  },
112
116
  render: function render() {
113
- var _api$dependencies$ana6;
117
+ var _api$analytics6;
114
118
  return /*#__PURE__*/_react.default.createElement(_Toolbar.default, {
115
119
  editorState: editorView.state,
116
120
  popupsMountPoint: popupsMountPoint,
@@ -119,20 +123,20 @@ var textFormattingPlugin = function textFormattingPlugin() {
119
123
  isReducedSpacing: isToolbarReducedSpacing,
120
124
  editorView: editorView,
121
125
  isToolbarDisabled: disabled,
122
- shouldUseResponsiveToolbar: Boolean(options.responsiveToolbarMenu),
123
- editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$dependencies$ana6 = api.dependencies.analytics) === null || _api$dependencies$ana6 === void 0 ? void 0 : _api$dependencies$ana6.actions
126
+ shouldUseResponsiveToolbar: Boolean(options === null || options === void 0 ? void 0 : options.responsiveToolbarMenu),
127
+ editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions
124
128
  });
125
129
  }
126
130
  });
127
131
  },
128
132
  commands: {
129
- toggleSuperscript: (0, _commands.toggleSuperscriptWithAnalytics)(api === null || api === void 0 ? void 0 : (_api$dependencies$ana7 = api.dependencies.analytics) === null || _api$dependencies$ana7 === void 0 ? void 0 : _api$dependencies$ana7.actions),
130
- toggleSubscript: (0, _commands.toggleSubscriptWithAnalytics)(api === null || api === void 0 ? void 0 : (_api$dependencies$ana8 = api.dependencies.analytics) === null || _api$dependencies$ana8 === void 0 ? void 0 : _api$dependencies$ana8.actions),
131
- toggleStrike: (0, _commands.toggleStrikeWithAnalytics)(api === null || api === void 0 ? void 0 : (_api$dependencies$ana9 = api.dependencies.analytics) === null || _api$dependencies$ana9 === void 0 ? void 0 : _api$dependencies$ana9.actions),
132
- toggleCode: (0, _commands.toggleCodeWithAnalytics)(api === null || api === void 0 ? void 0 : (_api$dependencies$ana10 = api.dependencies.analytics) === null || _api$dependencies$ana10 === void 0 ? void 0 : _api$dependencies$ana10.actions),
133
- toggleUnderline: (0, _commands.toggleUnderlineWithAnalytics)(api === null || api === void 0 ? void 0 : (_api$dependencies$ana11 = api.dependencies.analytics) === null || _api$dependencies$ana11 === void 0 ? void 0 : _api$dependencies$ana11.actions),
134
- toggleEm: (0, _commands.toggleEmWithAnalytics)(api === null || api === void 0 ? void 0 : (_api$dependencies$ana12 = api.dependencies.analytics) === null || _api$dependencies$ana12 === void 0 ? void 0 : _api$dependencies$ana12.actions),
135
- toggleStrong: (0, _commands.toggleStrongWithAnalytics)(api === null || api === void 0 ? void 0 : (_api$dependencies$ana13 = api.dependencies.analytics) === null || _api$dependencies$ana13 === void 0 ? void 0 : _api$dependencies$ana13.actions)
133
+ toggleSuperscript: (0, _commands.toggleSuperscriptWithAnalytics)(api === null || api === void 0 ? void 0 : (_api$analytics7 = api.analytics) === null || _api$analytics7 === void 0 ? void 0 : _api$analytics7.actions),
134
+ toggleSubscript: (0, _commands.toggleSubscriptWithAnalytics)(api === null || api === void 0 ? void 0 : (_api$analytics8 = api.analytics) === null || _api$analytics8 === void 0 ? void 0 : _api$analytics8.actions),
135
+ toggleStrike: (0, _commands.toggleStrikeWithAnalytics)(api === null || api === void 0 ? void 0 : (_api$analytics9 = api.analytics) === null || _api$analytics9 === void 0 ? void 0 : _api$analytics9.actions),
136
+ toggleCode: (0, _commands.toggleCodeWithAnalytics)(api === null || api === void 0 ? void 0 : (_api$analytics10 = api.analytics) === null || _api$analytics10 === void 0 ? void 0 : _api$analytics10.actions),
137
+ toggleUnderline: (0, _commands.toggleUnderlineWithAnalytics)(api === null || api === void 0 ? void 0 : (_api$analytics11 = api.analytics) === null || _api$analytics11 === void 0 ? void 0 : _api$analytics11.actions),
138
+ toggleEm: (0, _commands.toggleEmWithAnalytics)(api === null || api === void 0 ? void 0 : (_api$analytics12 = api.analytics) === null || _api$analytics12 === void 0 ? void 0 : _api$analytics12.actions),
139
+ toggleStrong: (0, _commands.toggleStrongWithAnalytics)(api === null || api === void 0 ? void 0 : (_api$analytics13 = api.analytics) === null || _api$analytics13 === void 0 ? void 0 : _api$analytics13.actions)
136
140
  }
137
141
  };
138
142
  };
@@ -10,8 +10,15 @@ import keymapPlugin from './pm-plugins/keymap';
10
10
  import { plugin as pmPlugin, pluginKey as textFormattingPluginKey } from './pm-plugins/main';
11
11
  import textFormattingSmartInputRulePlugin from './pm-plugins/smart-input-rule';
12
12
  import Toolbar from './ui/Toolbar';
13
- export const textFormattingPlugin = (options = {}, api) => {
14
- var _api$dependencies$ana7, _api$dependencies$ana8, _api$dependencies$ana9, _api$dependencies$ana10, _api$dependencies$ana11, _api$dependencies$ana12, _api$dependencies$ana13;
13
+ /**
14
+ * Text formatting plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
15
+ * from `@atlaskit/editor-core`.
16
+ */
17
+ export const textFormattingPlugin = ({
18
+ config: options,
19
+ api
20
+ }) => {
21
+ var _api$analytics7, _api$analytics8, _api$analytics9, _api$analytics10, _api$analytics11, _api$analytics12, _api$analytics13;
15
22
  return {
16
23
  name: 'textFormatting',
17
24
  marks() {
@@ -24,13 +31,13 @@ export const textFormattingPlugin = (options = {}, api) => {
24
31
  }, {
25
32
  name: 'strike',
26
33
  mark: strike
27
- }].concat(options.disableCode ? [] : {
34
+ }].concat(options !== null && options !== void 0 && options.disableCode ? [] : {
28
35
  name: 'code',
29
36
  mark: code
30
- }).concat(options.disableSuperscriptAndSubscript ? [] : {
37
+ }).concat(options !== null && options !== void 0 && options.disableSuperscriptAndSubscript ? [] : {
31
38
  name: 'subsup',
32
39
  mark: subsup
33
- }).concat(options.disableUnderline ? [] : {
40
+ }).concat(options !== null && options !== void 0 && options.disableUnderline ? [] : {
34
41
  name: 'underline',
35
42
  mark: underline
36
43
  });
@@ -41,8 +48,8 @@ export const textFormattingPlugin = (options = {}, api) => {
41
48
  plugin: ({
42
49
  dispatch
43
50
  }) => {
44
- var _api$dependencies$ana;
45
- return pmPlugin(dispatch, api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions);
51
+ var _api$analytics;
52
+ return pmPlugin(dispatch, api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
46
53
  }
47
54
  }, {
48
55
  name: 'textFormattingCursor',
@@ -52,14 +59,14 @@ export const textFormattingPlugin = (options = {}, api) => {
52
59
  plugin: ({
53
60
  schema
54
61
  }) => {
55
- var _api$dependencies$ana2;
56
- return textFormattingInputRulePlugin(schema, api === null || api === void 0 ? void 0 : (_api$dependencies$ana2 = api.dependencies.analytics) === null || _api$dependencies$ana2 === void 0 ? void 0 : _api$dependencies$ana2.actions);
62
+ var _api$analytics2;
63
+ return textFormattingInputRulePlugin(schema, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions);
57
64
  }
58
65
  }, {
59
66
  name: 'textFormattingSmartRule',
60
67
  plugin: () => {
61
- var _api$dependencies$ana3;
62
- return !options.disableSmartTextCompletion ? textFormattingSmartInputRulePlugin(api === null || api === void 0 ? void 0 : (_api$dependencies$ana3 = api.dependencies.analytics) === null || _api$dependencies$ana3 === void 0 ? void 0 : _api$dependencies$ana3.actions) : undefined;
68
+ var _api$analytics3;
69
+ return !(options !== null && options !== void 0 && options.disableSmartTextCompletion) ? textFormattingSmartInputRulePlugin(api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions) : undefined;
63
70
  }
64
71
  }, {
65
72
  name: 'textFormattingClear',
@@ -69,16 +76,16 @@ export const textFormattingPlugin = (options = {}, api) => {
69
76
  }, {
70
77
  name: 'textFormattingClearKeymap',
71
78
  plugin: () => {
72
- var _api$dependencies$ana4;
73
- return clearFormattingKeymapPlugin(api === null || api === void 0 ? void 0 : (_api$dependencies$ana4 = api.dependencies.analytics) === null || _api$dependencies$ana4 === void 0 ? void 0 : _api$dependencies$ana4.actions);
79
+ var _api$analytics4;
80
+ return clearFormattingKeymapPlugin(api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions);
74
81
  }
75
82
  }, {
76
83
  name: 'textFormattingKeymap',
77
84
  plugin: ({
78
85
  schema
79
86
  }) => {
80
- var _api$dependencies$ana5;
81
- return keymapPlugin(schema, api === null || api === void 0 ? void 0 : (_api$dependencies$ana5 = api.dependencies.analytics) === null || _api$dependencies$ana5 === void 0 ? void 0 : _api$dependencies$ana5.actions);
87
+ var _api$analytics5;
88
+ return keymapPlugin(schema, api === null || api === void 0 ? void 0 : (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions);
82
89
  }
83
90
  }];
84
91
  },
@@ -102,7 +109,7 @@ export const textFormattingPlugin = (options = {}, api) => {
102
109
  clearFormattingPluginState: clearFormattingPluginKey
103
110
  },
104
111
  render: () => {
105
- var _api$dependencies$ana6;
112
+ var _api$analytics6;
106
113
  return /*#__PURE__*/React.createElement(Toolbar, {
107
114
  editorState: editorView.state,
108
115
  popupsMountPoint: popupsMountPoint,
@@ -111,20 +118,20 @@ export const textFormattingPlugin = (options = {}, api) => {
111
118
  isReducedSpacing: isToolbarReducedSpacing,
112
119
  editorView: editorView,
113
120
  isToolbarDisabled: disabled,
114
- shouldUseResponsiveToolbar: Boolean(options.responsiveToolbarMenu),
115
- editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$dependencies$ana6 = api.dependencies.analytics) === null || _api$dependencies$ana6 === void 0 ? void 0 : _api$dependencies$ana6.actions
121
+ shouldUseResponsiveToolbar: Boolean(options === null || options === void 0 ? void 0 : options.responsiveToolbarMenu),
122
+ editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions
116
123
  });
117
124
  }
118
125
  });
119
126
  },
120
127
  commands: {
121
- toggleSuperscript: toggleSuperscriptWithAnalytics(api === null || api === void 0 ? void 0 : (_api$dependencies$ana7 = api.dependencies.analytics) === null || _api$dependencies$ana7 === void 0 ? void 0 : _api$dependencies$ana7.actions),
122
- toggleSubscript: toggleSubscriptWithAnalytics(api === null || api === void 0 ? void 0 : (_api$dependencies$ana8 = api.dependencies.analytics) === null || _api$dependencies$ana8 === void 0 ? void 0 : _api$dependencies$ana8.actions),
123
- toggleStrike: toggleStrikeWithAnalytics(api === null || api === void 0 ? void 0 : (_api$dependencies$ana9 = api.dependencies.analytics) === null || _api$dependencies$ana9 === void 0 ? void 0 : _api$dependencies$ana9.actions),
124
- toggleCode: toggleCodeWithAnalytics(api === null || api === void 0 ? void 0 : (_api$dependencies$ana10 = api.dependencies.analytics) === null || _api$dependencies$ana10 === void 0 ? void 0 : _api$dependencies$ana10.actions),
125
- toggleUnderline: toggleUnderlineWithAnalytics(api === null || api === void 0 ? void 0 : (_api$dependencies$ana11 = api.dependencies.analytics) === null || _api$dependencies$ana11 === void 0 ? void 0 : _api$dependencies$ana11.actions),
126
- toggleEm: toggleEmWithAnalytics(api === null || api === void 0 ? void 0 : (_api$dependencies$ana12 = api.dependencies.analytics) === null || _api$dependencies$ana12 === void 0 ? void 0 : _api$dependencies$ana12.actions),
127
- toggleStrong: toggleStrongWithAnalytics(api === null || api === void 0 ? void 0 : (_api$dependencies$ana13 = api.dependencies.analytics) === null || _api$dependencies$ana13 === void 0 ? void 0 : _api$dependencies$ana13.actions)
128
+ toggleSuperscript: toggleSuperscriptWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics7 = api.analytics) === null || _api$analytics7 === void 0 ? void 0 : _api$analytics7.actions),
129
+ toggleSubscript: toggleSubscriptWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics8 = api.analytics) === null || _api$analytics8 === void 0 ? void 0 : _api$analytics8.actions),
130
+ toggleStrike: toggleStrikeWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics9 = api.analytics) === null || _api$analytics9 === void 0 ? void 0 : _api$analytics9.actions),
131
+ toggleCode: toggleCodeWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics10 = api.analytics) === null || _api$analytics10 === void 0 ? void 0 : _api$analytics10.actions),
132
+ toggleUnderline: toggleUnderlineWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics11 = api.analytics) === null || _api$analytics11 === void 0 ? void 0 : _api$analytics11.actions),
133
+ toggleEm: toggleEmWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics12 = api.analytics) === null || _api$analytics12 === void 0 ? void 0 : _api$analytics12.actions),
134
+ toggleStrong: toggleStrongWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics13 = api.analytics) === null || _api$analytics13 === void 0 ? void 0 : _api$analytics13.actions)
128
135
  }
129
136
  };
130
137
  };
@@ -10,10 +10,14 @@ import keymapPlugin from './pm-plugins/keymap';
10
10
  import { plugin as pmPlugin, pluginKey as textFormattingPluginKey } from './pm-plugins/main';
11
11
  import textFormattingSmartInputRulePlugin from './pm-plugins/smart-input-rule';
12
12
  import Toolbar from './ui/Toolbar';
13
- export var textFormattingPlugin = function textFormattingPlugin() {
14
- var _api$dependencies$ana7, _api$dependencies$ana8, _api$dependencies$ana9, _api$dependencies$ana10, _api$dependencies$ana11, _api$dependencies$ana12, _api$dependencies$ana13;
15
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
16
- var api = arguments.length > 1 ? arguments[1] : undefined;
13
+ /**
14
+ * Text formatting plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
15
+ * from `@atlaskit/editor-core`.
16
+ */
17
+ export var textFormattingPlugin = function textFormattingPlugin(_ref) {
18
+ var _api$analytics7, _api$analytics8, _api$analytics9, _api$analytics10, _api$analytics11, _api$analytics12, _api$analytics13;
19
+ var options = _ref.config,
20
+ api = _ref.api;
17
21
  return {
18
22
  name: 'textFormatting',
19
23
  marks: function marks() {
@@ -26,13 +30,13 @@ export var textFormattingPlugin = function textFormattingPlugin() {
26
30
  }, {
27
31
  name: 'strike',
28
32
  mark: strike
29
- }].concat(options.disableCode ? [] : {
33
+ }].concat(options !== null && options !== void 0 && options.disableCode ? [] : {
30
34
  name: 'code',
31
35
  mark: code
32
- }).concat(options.disableSuperscriptAndSubscript ? [] : {
36
+ }).concat(options !== null && options !== void 0 && options.disableSuperscriptAndSubscript ? [] : {
33
37
  name: 'subsup',
34
38
  mark: subsup
35
- }).concat(options.disableUnderline ? [] : {
39
+ }).concat(options !== null && options !== void 0 && options.disableUnderline ? [] : {
36
40
  name: 'underline',
37
41
  mark: underline
38
42
  });
@@ -40,10 +44,10 @@ export var textFormattingPlugin = function textFormattingPlugin() {
40
44
  pmPlugins: function pmPlugins() {
41
45
  return [{
42
46
  name: 'textFormatting',
43
- plugin: function plugin(_ref) {
44
- var _api$dependencies$ana;
45
- var dispatch = _ref.dispatch;
46
- return pmPlugin(dispatch, api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions);
47
+ plugin: function plugin(_ref2) {
48
+ var _api$analytics;
49
+ var dispatch = _ref2.dispatch;
50
+ return pmPlugin(dispatch, api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
47
51
  }
48
52
  }, {
49
53
  name: 'textFormattingCursor',
@@ -52,35 +56,35 @@ export var textFormattingPlugin = function textFormattingPlugin() {
52
56
  }
53
57
  }, {
54
58
  name: 'textFormattingInputRule',
55
- plugin: function plugin(_ref2) {
56
- var _api$dependencies$ana2;
57
- var schema = _ref2.schema;
58
- return textFormattingInputRulePlugin(schema, api === null || api === void 0 ? void 0 : (_api$dependencies$ana2 = api.dependencies.analytics) === null || _api$dependencies$ana2 === void 0 ? void 0 : _api$dependencies$ana2.actions);
59
+ plugin: function plugin(_ref3) {
60
+ var _api$analytics2;
61
+ var schema = _ref3.schema;
62
+ return textFormattingInputRulePlugin(schema, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions);
59
63
  }
60
64
  }, {
61
65
  name: 'textFormattingSmartRule',
62
66
  plugin: function plugin() {
63
- var _api$dependencies$ana3;
64
- return !options.disableSmartTextCompletion ? textFormattingSmartInputRulePlugin(api === null || api === void 0 ? void 0 : (_api$dependencies$ana3 = api.dependencies.analytics) === null || _api$dependencies$ana3 === void 0 ? void 0 : _api$dependencies$ana3.actions) : undefined;
67
+ var _api$analytics3;
68
+ return !(options !== null && options !== void 0 && options.disableSmartTextCompletion) ? textFormattingSmartInputRulePlugin(api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions) : undefined;
65
69
  }
66
70
  }, {
67
71
  name: 'textFormattingClear',
68
- plugin: function plugin(_ref3) {
69
- var dispatch = _ref3.dispatch;
72
+ plugin: function plugin(_ref4) {
73
+ var dispatch = _ref4.dispatch;
70
74
  return clearFormattingPlugin(dispatch);
71
75
  }
72
76
  }, {
73
77
  name: 'textFormattingClearKeymap',
74
78
  plugin: function plugin() {
75
- var _api$dependencies$ana4;
76
- return clearFormattingKeymapPlugin(api === null || api === void 0 ? void 0 : (_api$dependencies$ana4 = api.dependencies.analytics) === null || _api$dependencies$ana4 === void 0 ? void 0 : _api$dependencies$ana4.actions);
79
+ var _api$analytics4;
80
+ return clearFormattingKeymapPlugin(api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions);
77
81
  }
78
82
  }, {
79
83
  name: 'textFormattingKeymap',
80
- plugin: function plugin(_ref4) {
81
- var _api$dependencies$ana5;
82
- var schema = _ref4.schema;
83
- return keymapPlugin(schema, api === null || api === void 0 ? void 0 : (_api$dependencies$ana5 = api.dependencies.analytics) === null || _api$dependencies$ana5 === void 0 ? void 0 : _api$dependencies$ana5.actions);
84
+ plugin: function plugin(_ref5) {
85
+ var _api$analytics5;
86
+ var schema = _ref5.schema;
87
+ return keymapPlugin(schema, api === null || api === void 0 ? void 0 : (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions);
84
88
  }
85
89
  }];
86
90
  },
@@ -90,20 +94,20 @@ export var textFormattingPlugin = function textFormattingPlugin() {
90
94
  }
91
95
  return textFormattingPluginKey.getState(editorState);
92
96
  },
93
- primaryToolbarComponent: function primaryToolbarComponent(_ref5) {
94
- var editorView = _ref5.editorView,
95
- popupsMountPoint = _ref5.popupsMountPoint,
96
- popupsScrollableElement = _ref5.popupsScrollableElement,
97
- isToolbarReducedSpacing = _ref5.isToolbarReducedSpacing,
98
- toolbarSize = _ref5.toolbarSize,
99
- disabled = _ref5.disabled;
97
+ primaryToolbarComponent: function primaryToolbarComponent(_ref6) {
98
+ var editorView = _ref6.editorView,
99
+ popupsMountPoint = _ref6.popupsMountPoint,
100
+ popupsScrollableElement = _ref6.popupsScrollableElement,
101
+ isToolbarReducedSpacing = _ref6.isToolbarReducedSpacing,
102
+ toolbarSize = _ref6.toolbarSize,
103
+ disabled = _ref6.disabled;
100
104
  return /*#__PURE__*/React.createElement(WithPluginState, {
101
105
  plugins: {
102
106
  textFormattingState: textFormattingPluginKey,
103
107
  clearFormattingPluginState: clearFormattingPluginKey
104
108
  },
105
109
  render: function render() {
106
- var _api$dependencies$ana6;
110
+ var _api$analytics6;
107
111
  return /*#__PURE__*/React.createElement(Toolbar, {
108
112
  editorState: editorView.state,
109
113
  popupsMountPoint: popupsMountPoint,
@@ -112,20 +116,20 @@ export var textFormattingPlugin = function textFormattingPlugin() {
112
116
  isReducedSpacing: isToolbarReducedSpacing,
113
117
  editorView: editorView,
114
118
  isToolbarDisabled: disabled,
115
- shouldUseResponsiveToolbar: Boolean(options.responsiveToolbarMenu),
116
- editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$dependencies$ana6 = api.dependencies.analytics) === null || _api$dependencies$ana6 === void 0 ? void 0 : _api$dependencies$ana6.actions
119
+ shouldUseResponsiveToolbar: Boolean(options === null || options === void 0 ? void 0 : options.responsiveToolbarMenu),
120
+ editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions
117
121
  });
118
122
  }
119
123
  });
120
124
  },
121
125
  commands: {
122
- toggleSuperscript: toggleSuperscriptWithAnalytics(api === null || api === void 0 ? void 0 : (_api$dependencies$ana7 = api.dependencies.analytics) === null || _api$dependencies$ana7 === void 0 ? void 0 : _api$dependencies$ana7.actions),
123
- toggleSubscript: toggleSubscriptWithAnalytics(api === null || api === void 0 ? void 0 : (_api$dependencies$ana8 = api.dependencies.analytics) === null || _api$dependencies$ana8 === void 0 ? void 0 : _api$dependencies$ana8.actions),
124
- toggleStrike: toggleStrikeWithAnalytics(api === null || api === void 0 ? void 0 : (_api$dependencies$ana9 = api.dependencies.analytics) === null || _api$dependencies$ana9 === void 0 ? void 0 : _api$dependencies$ana9.actions),
125
- toggleCode: toggleCodeWithAnalytics(api === null || api === void 0 ? void 0 : (_api$dependencies$ana10 = api.dependencies.analytics) === null || _api$dependencies$ana10 === void 0 ? void 0 : _api$dependencies$ana10.actions),
126
- toggleUnderline: toggleUnderlineWithAnalytics(api === null || api === void 0 ? void 0 : (_api$dependencies$ana11 = api.dependencies.analytics) === null || _api$dependencies$ana11 === void 0 ? void 0 : _api$dependencies$ana11.actions),
127
- toggleEm: toggleEmWithAnalytics(api === null || api === void 0 ? void 0 : (_api$dependencies$ana12 = api.dependencies.analytics) === null || _api$dependencies$ana12 === void 0 ? void 0 : _api$dependencies$ana12.actions),
128
- toggleStrong: toggleStrongWithAnalytics(api === null || api === void 0 ? void 0 : (_api$dependencies$ana13 = api.dependencies.analytics) === null || _api$dependencies$ana13 === void 0 ? void 0 : _api$dependencies$ana13.actions)
126
+ toggleSuperscript: toggleSuperscriptWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics7 = api.analytics) === null || _api$analytics7 === void 0 ? void 0 : _api$analytics7.actions),
127
+ toggleSubscript: toggleSubscriptWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics8 = api.analytics) === null || _api$analytics8 === void 0 ? void 0 : _api$analytics8.actions),
128
+ toggleStrike: toggleStrikeWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics9 = api.analytics) === null || _api$analytics9 === void 0 ? void 0 : _api$analytics9.actions),
129
+ toggleCode: toggleCodeWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics10 = api.analytics) === null || _api$analytics10 === void 0 ? void 0 : _api$analytics10.actions),
130
+ toggleUnderline: toggleUnderlineWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics11 = api.analytics) === null || _api$analytics11 === void 0 ? void 0 : _api$analytics11.actions),
131
+ toggleEm: toggleEmWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics12 = api.analytics) === null || _api$analytics12 === void 0 ? void 0 : _api$analytics12.actions),
132
+ toggleStrong: toggleStrongWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics13 = api.analytics) === null || _api$analytics13 === void 0 ? void 0 : _api$analytics13.actions)
129
133
  }
130
134
  };
131
135
  };
@@ -15,4 +15,8 @@ export type TextFormattingPlugin = NextEditorPlugin<'textFormatting', {
15
15
  };
16
16
  sharedState: TextFormattingState | undefined;
17
17
  }>;
18
+ /**
19
+ * Text formatting plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
20
+ * from `@atlaskit/editor-core`.
21
+ */
18
22
  export declare const textFormattingPlugin: TextFormattingPlugin;
@@ -17,4 +17,8 @@ export type TextFormattingPlugin = NextEditorPlugin<'textFormatting', {
17
17
  };
18
18
  sharedState: TextFormattingState | undefined;
19
19
  }>;
20
+ /**
21
+ * Text formatting plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
22
+ * from `@atlaskit/editor-core`.
23
+ */
20
24
  export declare const textFormattingPlugin: TextFormattingPlugin;
@@ -0,0 +1,55 @@
1
+ import React from 'react';
2
+
3
+ import { AtlassianInternalWarning, code, md } from '@atlaskit/docs';
4
+ import { createEditorUseOnlyNotice } from '@atlaskit/editor-core/docs/editor-use-only';
5
+ import { token } from '@atlaskit/tokens';
6
+
7
+ export default md`
8
+
9
+ ${createEditorUseOnlyNotice('Editor Plugin Text Formatting', [
10
+ { name: 'Editor Core', link: '/packages/editor/editor-core' },
11
+ ])}
12
+
13
+
14
+ ${(
15
+ <div style={{ marginTop: token('space.100', '8px') }}>
16
+ <AtlassianInternalWarning />
17
+ </div>
18
+ )}
19
+
20
+ This package includes the text formatting plugin used by \`@atlaskit/editor-core\`.
21
+
22
+ ## Usage
23
+ ---
24
+
25
+ The \`dependencies\`, \`configuration\`, \`state\`, \`actions\`, and \`commands\` of the plugin are defined
26
+ below:
27
+
28
+ ${code`
29
+ type TextFormattingPlugin = NextEditorPlugin<
30
+ 'textFormatting',
31
+ {
32
+ pluginConfiguration: TextFormattingOptions | undefined;
33
+ dependencies: [OptionalPlugin<typeof analyticsPlugin>];
34
+ commands: {
35
+ toggleSuperscript: ToggleMarkEditorCommand;
36
+ toggleSubscript: ToggleMarkEditorCommand;
37
+ toggleStrike: ToggleMarkEditorCommand;
38
+ toggleCode: ToggleMarkEditorCommand;
39
+ toggleUnderline: ToggleMarkEditorCommand;
40
+ toggleEm: ToggleMarkEditorCommand;
41
+ toggleStrong: ToggleMarkEditorCommand;
42
+ };
43
+ sharedState: TextFormattingState | undefined;
44
+ }
45
+ >;
46
+ `}
47
+
48
+
49
+ ## Support
50
+ ---
51
+ For internal Atlassian, visit the slack channel [#help-editor](https://atlassian.slack.com/archives/CFG3PSQ9E) for support or visit [go/editor-help](https://go/editor-help) to submit a bug.
52
+ ## License
53
+ ---
54
+ Please see [Atlassian Frontend - License](https://developer.atlassian.com/cloud/framework/atlassian-frontend/#license) for more licensing information.
55
+ `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-text-formatting",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "Text-formatting plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -8,7 +8,7 @@
8
8
  "registry": "https://registry.npmjs.org/"
9
9
  },
10
10
  "atlassian": {
11
- "team": "Editor",
11
+ "team": "Editor: Scarlet",
12
12
  "singleton": true,
13
13
  "releaseModel": "continuous"
14
14
  },
@@ -32,8 +32,8 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@atlaskit/adf-schema": "28.1.2",
35
- "@atlaskit/editor-common": "^74.52.0",
36
- "@atlaskit/editor-plugin-analytics": "^0.1.0",
35
+ "@atlaskit/editor-common": "^74.55.0",
36
+ "@atlaskit/editor-plugin-analytics": "^0.2.0",
37
37
  "@atlaskit/editor-prosemirror": "1.1.0",
38
38
  "@atlaskit/editor-shared-styles": "^2.5.0",
39
39
  "@atlaskit/editor-tables": "^2.3.0",
@@ -47,9 +47,9 @@
47
47
  "react": "^16.8.0"
48
48
  },
49
49
  "devDependencies": {
50
- "@atlaskit/editor-plugin-composition": "^0.0.2",
51
- "@atlaskit/editor-plugin-decorations": "^0.1.0",
52
- "@atlaskit/editor-plugin-feature-flags": "^0.1.0",
50
+ "@atlaskit/editor-plugin-composition": "^0.1.0",
51
+ "@atlaskit/editor-plugin-decorations": "^0.2.0",
52
+ "@atlaskit/editor-plugin-feature-flags": "^0.2.0",
53
53
  "@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
54
54
  "@testing-library/react": "^12.1.5",
55
55
  "typescript": "~4.9.5"
package/report.api.md CHANGED
@@ -42,7 +42,7 @@ export type TextFormattingPlugin = NextEditorPlugin<
42
42
  }
43
43
  >;
44
44
 
45
- // @public (undocumented)
45
+ // @public
46
46
  export const textFormattingPlugin: TextFormattingPlugin;
47
47
 
48
48
  // @public (undocumented)
@@ -0,0 +1,39 @@
1
+ ## API Report File for "@atlaskit/editor-plugin-text-formatting"
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 type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
8
+ import type { EditorCommand } from '@atlaskit/editor-common/types';
9
+ import type { InputMethodBasic } from '@atlaskit/editor-common/types';
10
+ import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
11
+ import type { OptionalPlugin } from '@atlaskit/editor-common/types';
12
+ import type { TextFormattingOptions } from '@atlaskit/editor-common/types';
13
+ import type { TextFormattingState } from '@atlaskit/editor-common/types';
14
+
15
+ // @public (undocumented)
16
+ export type TextFormattingPlugin = NextEditorPlugin<'textFormatting', {
17
+ pluginConfiguration: TextFormattingOptions | undefined;
18
+ dependencies: [OptionalPlugin<typeof analyticsPlugin>];
19
+ commands: {
20
+ toggleSuperscript: ToggleMarkEditorCommand;
21
+ toggleSubscript: ToggleMarkEditorCommand;
22
+ toggleStrike: ToggleMarkEditorCommand;
23
+ toggleCode: ToggleMarkEditorCommand;
24
+ toggleUnderline: ToggleMarkEditorCommand;
25
+ toggleEm: ToggleMarkEditorCommand;
26
+ toggleStrong: ToggleMarkEditorCommand;
27
+ };
28
+ sharedState: TextFormattingState | undefined;
29
+ }>;
30
+
31
+ // @public
32
+ export const textFormattingPlugin: TextFormattingPlugin;
33
+
34
+ // @public (undocumented)
35
+ export type ToggleMarkEditorCommand = (inputMethod: InputMethodBasic) => EditorCommand;
36
+
37
+ // (No @packageDocumentation comment for this package)
38
+
39
+ ```