@atlaskit/editor-plugin-quick-insert 10.1.3 → 10.2.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,65 @@
1
1
  # @atlaskit/editor-plugin-quick-insert
2
2
 
3
+ ## 10.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`ef22af532ebfd`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ef22af532ebfd) -
8
+ EDITOR-6558: Introduce a reusable Markdown Mode editor plugin and two consumer-supplied
9
+ insert-filter hooks.
10
+
11
+ ### `@atlassian/editor-plugin-markdown-mode` (new package — major)
12
+
13
+ A reusable editor plugin that owns the full Markdown Mode lifecycle: ProseMirror plugin state for
14
+ the active view, a 3-button view toggle (`MarkdownModeViewToggleBase`), a CodeMirror 6 source view
15
+ (`MarkdownSourceView`), ADF↔markdown conversion (`adfToMarkdown` / `markdownToAdf`), and the
16
+ snapshot/writeback orchestration (`MarkdownModeContentComponent`). The plugin is product-agnostic
17
+ — Confluence wraps it for the `cc-markdown-mode` experiment, but any consumer can adopt it.
18
+
19
+ The package also exports two allowlists used by the new insert-filter hooks below:
20
+ - `MARKDOWN_COMPATIBLE_QUICK_INSERT_ITEM_IDS` + `isMarkdownCompatibleQuickInsertItem` — items
21
+ whose underlying node has a clean GFM round-trip via `@atlassian/mdast-util-from-pm`.
22
+ - `MARKDOWN_COMPATIBLE_TOOLBAR_ITEM_NAMES` + `isMarkdownCompatibleToolbarItem` — same idea for the
23
+ main toolbar's `+` insert block.
24
+
25
+ ### `@atlaskit/editor-plugin-quick-insert` (minor)
26
+
27
+ Added an optional `itemFilter?: (item: QuickInsertItem) => boolean` to `QuickInsertOptions`. When
28
+ set, the filter is applied in both `getQuickInsertSuggestions` (the typeahead path) and the
29
+ `getSuggestions` action path before items are categorised or returned. Composes additively with
30
+ any caller-supplied filter via `&&`. No behavioural change for callers that don't set it.
31
+
32
+ ### `@atlaskit/editor-plugin-insert-block` (minor)
33
+
34
+ Added an optional `itemFilter?: (item: { value: { name: string } }) => boolean` to
35
+ `InsertBlockPluginOptions`. The filter is applied to the items list inside `createItems` before
36
+ it's split into toolbar buttons / overflow dropdown entries, so item counts stay correct
37
+ downstream. Wired through both legacy (`ToolbarInsertBlock`) and new (`useInsertButtonState`)
38
+ toolbar code paths. No behavioural change for callers that don't set it.
39
+
40
+ ### `@atlaskit/editor-common` (patch)
41
+
42
+ `UseSharedPluginStateWithSelector`-friendly types are unchanged; the only public change is a new
43
+ optional field on `QuickInsertOptions` and a corresponding plumbing field on the internal
44
+ `QuickInsertSearchOptions`.
45
+
46
+ ### `@atlassian/mdast-util-from-pm` (patch)
47
+
48
+ Added `undoEdgeWhitespaceEncoding()` post-processor that replaces the leading/trailing-edge entity
49
+ escapes ` ` and `	` produced by the upstream encoder with literal space and tab
50
+ characters. This is a readability + round-trip identity fix that benefits all consumers, not just
51
+ Markdown Mode.
52
+
53
+ ### Patch Changes
54
+
55
+ - Updated dependencies
56
+
57
+ ## 10.1.4
58
+
59
+ ### Patch Changes
60
+
61
+ - Updated dependencies
62
+
3
63
  ## 10.1.3
4
64
 
5
65
  ### Patch Changes
@@ -45,7 +45,9 @@ var quickInsertPlugin = exports.quickInsertPlugin = function quickInsertPlugin(_
45
45
  return Promise.resolve((0, _search.getQuickInsertSuggestions)({
46
46
  query: query,
47
47
  disableDefaultItems: options === null || options === void 0 ? void 0 : options.disableDefaultItems,
48
- prioritySortingFn: options === null || options === void 0 ? void 0 : options.prioritySortingFn
48
+ prioritySortingFn: options === null || options === void 0 ? void 0 : options.prioritySortingFn,
49
+ // EDITOR-6558: pass through consumer-supplied filter (e.g. Markdown Mode allowlist)
50
+ itemFilter: options === null || options === void 0 ? void 0 : options.itemFilter
49
51
  }, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems));
50
52
  },
51
53
  selectItem: function selectItem(state, item, insert) {
@@ -151,6 +153,18 @@ var quickInsertPlugin = exports.quickInsertPlugin = function quickInsertPlugin(_
151
153
  prioritySortingFn: options.prioritySortingFn
152
154
  });
153
155
  }
156
+
157
+ // EDITOR-6558: layer the consumer-supplied filter (e.g. Markdown Mode allowlist)
158
+ // over any caller-supplied filter so both apply.
159
+ if (options !== null && options !== void 0 && options.itemFilter) {
160
+ var consumerFilter = options.itemFilter;
161
+ var callerFilter = searchOptions.itemFilter;
162
+ searchOptions = _objectSpread(_objectSpread({}, searchOptions), {}, {
163
+ itemFilter: callerFilter ? function (item) {
164
+ return consumerFilter(item) && callerFilter(item);
165
+ } : consumerFilter
166
+ });
167
+ }
154
168
  return (0, _search.getQuickInsertSuggestions)(searchOptions, lazyDefaultItems, providedItems);
155
169
  }
156
170
  },
@@ -19,6 +19,7 @@ var getQuickInsertSuggestions = exports.getQuickInsertSuggestions = function get
19
19
  category = searchOptions.category,
20
20
  disableDefaultItems = searchOptions.disableDefaultItems,
21
21
  featuredItems = searchOptions.featuredItems,
22
+ itemFilter = searchOptions.itemFilter,
22
23
  prioritySortingFn = searchOptions.prioritySortingFn;
23
24
  var defaultItems = disableDefaultItems ? [] : lazyDefaultItems();
24
25
  var dedupeFn = function dedupeFn(item) {
@@ -26,6 +27,11 @@ var getQuickInsertSuggestions = exports.getQuickInsertSuggestions = function get
26
27
  return "".concat(item.title, "-").concat((_item$description = item.description) !== null && _item$description !== void 0 ? _item$description : '');
27
28
  };
28
29
  var items = providedItems ? (0, _utils.dedupe)([].concat((0, _toConsumableArray2.default)(defaultItems), (0, _toConsumableArray2.default)(providedItems)), dedupeFn) : defaultItems;
30
+
31
+ // EDITOR-6558: apply consumer-supplied filter (e.g. Markdown Mode allowlist).
32
+ if (itemFilter) {
33
+ items = items.filter(itemFilter);
34
+ }
29
35
  if (featuredItems) {
30
36
  return items.filter(function (item) {
31
37
  return item.featured;
@@ -34,7 +34,9 @@ export const quickInsertPlugin = ({
34
34
  return Promise.resolve(getQuickInsertSuggestions({
35
35
  query: query,
36
36
  disableDefaultItems: options === null || options === void 0 ? void 0 : options.disableDefaultItems,
37
- prioritySortingFn: options === null || options === void 0 ? void 0 : options.prioritySortingFn
37
+ prioritySortingFn: options === null || options === void 0 ? void 0 : options.prioritySortingFn,
38
+ // EDITOR-6558: pass through consumer-supplied filter (e.g. Markdown Mode allowlist)
39
+ itemFilter: options === null || options === void 0 ? void 0 : options.itemFilter
38
40
  }, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems));
39
41
  },
40
42
  selectItem: (state, item, insert) => {
@@ -141,6 +143,17 @@ export const quickInsertPlugin = ({
141
143
  prioritySortingFn: options.prioritySortingFn
142
144
  };
143
145
  }
146
+
147
+ // EDITOR-6558: layer the consumer-supplied filter (e.g. Markdown Mode allowlist)
148
+ // over any caller-supplied filter so both apply.
149
+ if (options !== null && options !== void 0 && options.itemFilter) {
150
+ const consumerFilter = options.itemFilter;
151
+ const callerFilter = searchOptions.itemFilter;
152
+ searchOptions = {
153
+ ...searchOptions,
154
+ itemFilter: callerFilter ? item => consumerFilter(item) && callerFilter(item) : consumerFilter
155
+ };
156
+ }
144
157
  return getQuickInsertSuggestions(searchOptions, lazyDefaultItems, providedItems);
145
158
  }
146
159
  },
@@ -8,6 +8,7 @@ export const getQuickInsertSuggestions = (searchOptions, lazyDefaultItems = () =
8
8
  category,
9
9
  disableDefaultItems,
10
10
  featuredItems,
11
+ itemFilter,
11
12
  prioritySortingFn
12
13
  } = searchOptions;
13
14
  const defaultItems = disableDefaultItems ? [] : lazyDefaultItems();
@@ -15,7 +16,12 @@ export const getQuickInsertSuggestions = (searchOptions, lazyDefaultItems = () =
15
16
  var _item$description;
16
17
  return `${item.title}-${(_item$description = item.description) !== null && _item$description !== void 0 ? _item$description : ''}`;
17
18
  };
18
- const items = providedItems ? dedupe([...defaultItems, ...providedItems], dedupeFn) : defaultItems;
19
+ let items = providedItems ? dedupe([...defaultItems, ...providedItems], dedupeFn) : defaultItems;
20
+
21
+ // EDITOR-6558: apply consumer-supplied filter (e.g. Markdown Mode allowlist).
22
+ if (itemFilter) {
23
+ items = items.filter(itemFilter);
24
+ }
19
25
  if (featuredItems) {
20
26
  return items.filter(item => item.featured);
21
27
  }
@@ -38,7 +38,9 @@ export var quickInsertPlugin = function quickInsertPlugin(_ref) {
38
38
  return Promise.resolve(getQuickInsertSuggestions({
39
39
  query: query,
40
40
  disableDefaultItems: options === null || options === void 0 ? void 0 : options.disableDefaultItems,
41
- prioritySortingFn: options === null || options === void 0 ? void 0 : options.prioritySortingFn
41
+ prioritySortingFn: options === null || options === void 0 ? void 0 : options.prioritySortingFn,
42
+ // EDITOR-6558: pass through consumer-supplied filter (e.g. Markdown Mode allowlist)
43
+ itemFilter: options === null || options === void 0 ? void 0 : options.itemFilter
42
44
  }, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems));
43
45
  },
44
46
  selectItem: function selectItem(state, item, insert) {
@@ -144,6 +146,18 @@ export var quickInsertPlugin = function quickInsertPlugin(_ref) {
144
146
  prioritySortingFn: options.prioritySortingFn
145
147
  });
146
148
  }
149
+
150
+ // EDITOR-6558: layer the consumer-supplied filter (e.g. Markdown Mode allowlist)
151
+ // over any caller-supplied filter so both apply.
152
+ if (options !== null && options !== void 0 && options.itemFilter) {
153
+ var consumerFilter = options.itemFilter;
154
+ var callerFilter = searchOptions.itemFilter;
155
+ searchOptions = _objectSpread(_objectSpread({}, searchOptions), {}, {
156
+ itemFilter: callerFilter ? function (item) {
157
+ return consumerFilter(item) && callerFilter(item);
158
+ } : consumerFilter
159
+ });
160
+ }
147
161
  return getQuickInsertSuggestions(searchOptions, lazyDefaultItems, providedItems);
148
162
  }
149
163
  },
@@ -12,6 +12,7 @@ export var getQuickInsertSuggestions = function getQuickInsertSuggestions(search
12
12
  category = searchOptions.category,
13
13
  disableDefaultItems = searchOptions.disableDefaultItems,
14
14
  featuredItems = searchOptions.featuredItems,
15
+ itemFilter = searchOptions.itemFilter,
15
16
  prioritySortingFn = searchOptions.prioritySortingFn;
16
17
  var defaultItems = disableDefaultItems ? [] : lazyDefaultItems();
17
18
  var dedupeFn = function dedupeFn(item) {
@@ -19,6 +20,11 @@ export var getQuickInsertSuggestions = function getQuickInsertSuggestions(search
19
20
  return "".concat(item.title, "-").concat((_item$description = item.description) !== null && _item$description !== void 0 ? _item$description : '');
20
21
  };
21
22
  var items = providedItems ? dedupe([].concat(_toConsumableArray(defaultItems), _toConsumableArray(providedItems)), dedupeFn) : defaultItems;
23
+
24
+ // EDITOR-6558: apply consumer-supplied filter (e.g. Markdown Mode allowlist).
25
+ if (itemFilter) {
26
+ items = items.filter(itemFilter);
27
+ }
22
28
  if (featuredItems) {
23
29
  return items.filter(function (item) {
24
30
  return item.featured;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-quick-insert",
3
- "version": "10.1.3",
3
+ "version": "10.2.0",
4
4
  "description": "Quick insert plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -38,13 +38,13 @@
38
38
  "@atlaskit/icon": "^34.3.0",
39
39
  "@atlaskit/modal-dialog": "^14.18.0",
40
40
  "@atlaskit/platform-feature-flags": "^1.1.0",
41
- "@atlaskit/tmp-editor-statsig": "^68.0.0",
41
+ "@atlaskit/tmp-editor-statsig": "^70.2.0",
42
42
  "@atlaskit/tokens": "^13.0.0",
43
43
  "@babel/runtime": "^7.0.0",
44
44
  "@emotion/react": "^11.7.1"
45
45
  },
46
46
  "peerDependencies": {
47
- "@atlaskit/editor-common": "^114.9.0",
47
+ "@atlaskit/editor-common": "^114.11.0",
48
48
  "react": "^18.2.0",
49
49
  "react-dom": "^18.2.0",
50
50
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"