@atlaskit/editor-core 189.1.11 → 189.1.13

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 (135) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/plugins/index.js +0 -14
  3. package/dist/cjs/plugins/insert-block/index.js +6 -10
  4. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +40 -38
  5. package/dist/cjs/presets/universal.js +4 -2
  6. package/dist/cjs/ui/ContentStyles/index.js +1 -1
  7. package/dist/cjs/version-wrapper.js +1 -1
  8. package/dist/es2019/plugins/index.js +0 -2
  9. package/dist/es2019/plugins/insert-block/index.js +5 -9
  10. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +4 -3
  11. package/dist/es2019/presets/universal.js +3 -1
  12. package/dist/es2019/ui/ContentStyles/index.js +1 -1
  13. package/dist/es2019/version-wrapper.js +1 -1
  14. package/dist/esm/plugins/index.js +0 -2
  15. package/dist/esm/plugins/insert-block/index.js +5 -9
  16. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +40 -38
  17. package/dist/esm/presets/universal.js +3 -1
  18. package/dist/esm/ui/ContentStyles/index.js +1 -1
  19. package/dist/esm/version-wrapper.js +1 -1
  20. package/dist/types/plugins/index.d.ts +0 -2
  21. package/dist/types/plugins/insert-block/types.d.ts +4 -2
  22. package/dist/types/types/editor-props.d.ts +2 -2
  23. package/dist/types/ui/ConfigPanel/ConfigPanel.d.ts +1 -1
  24. package/dist/types-ts4.5/plugins/index.d.ts +0 -2
  25. package/dist/types-ts4.5/plugins/insert-block/types.d.ts +4 -2
  26. package/dist/types-ts4.5/types/editor-props.d.ts +2 -2
  27. package/dist/types-ts4.5/ui/ConfigPanel/ConfigPanel.d.ts +1 -1
  28. package/package.json +4 -2
  29. package/report.api.md +2 -16
  30. package/tmp/api-report-tmp.d.ts +2 -16
  31. package/dist/cjs/plugins/layout/actions.js +0 -345
  32. package/dist/cjs/plugins/layout/index.js +0 -91
  33. package/dist/cjs/plugins/layout/pm-plugins/main.js +0 -148
  34. package/dist/cjs/plugins/layout/pm-plugins/plugin-key.js +0 -8
  35. package/dist/cjs/plugins/layout/pm-plugins/types.js +0 -5
  36. package/dist/cjs/plugins/layout/toolbar-messages.js +0 -39
  37. package/dist/cjs/plugins/layout/toolbar.js +0 -116
  38. package/dist/cjs/plugins/layout/types.js +0 -5
  39. package/dist/cjs/plugins/placeholder-text/actions.js +0 -35
  40. package/dist/cjs/plugins/placeholder-text/fake-text-cursor/cursor.js +0 -107
  41. package/dist/cjs/plugins/placeholder-text/index.js +0 -20
  42. package/dist/cjs/plugins/placeholder-text/placeholder-text-nodeview.js +0 -89
  43. package/dist/cjs/plugins/placeholder-text/plugin-key.js +0 -8
  44. package/dist/cjs/plugins/placeholder-text/plugin.js +0 -267
  45. package/dist/cjs/plugins/placeholder-text/selection-utils.js +0 -14
  46. package/dist/cjs/plugins/placeholder-text/styles.js +0 -13
  47. package/dist/cjs/plugins/placeholder-text/types.js +0 -5
  48. package/dist/cjs/plugins/placeholder-text/ui/FloatingToolbar/index.js +0 -86
  49. package/dist/cjs/plugins/placeholder-text/ui/FloatingToolbar/styles.js +0 -15
  50. package/dist/cjs/plugins/placeholder-text/ui/FloatingToolbar/utils.js +0 -54
  51. package/dist/cjs/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.js +0 -89
  52. package/dist/es2019/plugins/layout/actions.js +0 -328
  53. package/dist/es2019/plugins/layout/index.js +0 -75
  54. package/dist/es2019/plugins/layout/pm-plugins/main.js +0 -142
  55. package/dist/es2019/plugins/layout/pm-plugins/plugin-key.js +0 -2
  56. package/dist/es2019/plugins/layout/pm-plugins/types.js +0 -1
  57. package/dist/es2019/plugins/layout/toolbar-messages.js +0 -33
  58. package/dist/es2019/plugins/layout/toolbar.js +0 -101
  59. package/dist/es2019/plugins/layout/types.js +0 -1
  60. package/dist/es2019/plugins/placeholder-text/actions.js +0 -27
  61. package/dist/es2019/plugins/placeholder-text/fake-text-cursor/cursor.js +0 -77
  62. package/dist/es2019/plugins/placeholder-text/index.js +0 -2
  63. package/dist/es2019/plugins/placeholder-text/placeholder-text-nodeview.js +0 -77
  64. package/dist/es2019/plugins/placeholder-text/plugin-key.js +0 -2
  65. package/dist/es2019/plugins/placeholder-text/plugin.js +0 -247
  66. package/dist/es2019/plugins/placeholder-text/selection-utils.js +0 -8
  67. package/dist/es2019/plugins/placeholder-text/styles.js +0 -52
  68. package/dist/es2019/plugins/placeholder-text/types.js +0 -1
  69. package/dist/es2019/plugins/placeholder-text/ui/FloatingToolbar/index.js +0 -45
  70. package/dist/es2019/plugins/placeholder-text/ui/FloatingToolbar/styles.js +0 -15
  71. package/dist/es2019/plugins/placeholder-text/ui/FloatingToolbar/utils.js +0 -41
  72. package/dist/es2019/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.js +0 -60
  73. package/dist/esm/plugins/layout/actions.js +0 -336
  74. package/dist/esm/plugins/layout/index.js +0 -79
  75. package/dist/esm/plugins/layout/pm-plugins/main.js +0 -141
  76. package/dist/esm/plugins/layout/pm-plugins/plugin-key.js +0 -2
  77. package/dist/esm/plugins/layout/pm-plugins/types.js +0 -1
  78. package/dist/esm/plugins/layout/toolbar-messages.js +0 -33
  79. package/dist/esm/plugins/layout/toolbar.js +0 -109
  80. package/dist/esm/plugins/layout/types.js +0 -1
  81. package/dist/esm/plugins/placeholder-text/actions.js +0 -29
  82. package/dist/esm/plugins/placeholder-text/fake-text-cursor/cursor.js +0 -100
  83. package/dist/esm/plugins/placeholder-text/index.js +0 -2
  84. package/dist/esm/plugins/placeholder-text/placeholder-text-nodeview.js +0 -82
  85. package/dist/esm/plugins/placeholder-text/plugin-key.js +0 -2
  86. package/dist/esm/plugins/placeholder-text/plugin.js +0 -259
  87. package/dist/esm/plugins/placeholder-text/selection-utils.js +0 -8
  88. package/dist/esm/plugins/placeholder-text/styles.js +0 -6
  89. package/dist/esm/plugins/placeholder-text/types.js +0 -1
  90. package/dist/esm/plugins/placeholder-text/ui/FloatingToolbar/index.js +0 -63
  91. package/dist/esm/plugins/placeholder-text/ui/FloatingToolbar/styles.js +0 -8
  92. package/dist/esm/plugins/placeholder-text/ui/FloatingToolbar/utils.js +0 -48
  93. package/dist/esm/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.js +0 -79
  94. package/dist/types/plugins/layout/actions.d.ts +0 -22
  95. package/dist/types/plugins/layout/index.d.ts +0 -15
  96. package/dist/types/plugins/layout/pm-plugins/main.d.ts +0 -6
  97. package/dist/types/plugins/layout/pm-plugins/plugin-key.d.ts +0 -3
  98. package/dist/types/plugins/layout/pm-plugins/types.d.ts +0 -14
  99. package/dist/types/plugins/layout/toolbar-messages.d.ts +0 -32
  100. package/dist/types/plugins/layout/toolbar.d.ts +0 -6
  101. package/dist/types/plugins/layout/types.d.ts +0 -13
  102. package/dist/types/plugins/placeholder-text/actions.d.ts +0 -4
  103. package/dist/types/plugins/placeholder-text/fake-text-cursor/cursor.d.ts +0 -30
  104. package/dist/types/plugins/placeholder-text/index.d.ts +0 -3
  105. package/dist/types/plugins/placeholder-text/placeholder-text-nodeview.d.ts +0 -17
  106. package/dist/types/plugins/placeholder-text/plugin-key.d.ts +0 -3
  107. package/dist/types/plugins/placeholder-text/plugin.d.ts +0 -7
  108. package/dist/types/plugins/placeholder-text/selection-utils.d.ts +0 -2
  109. package/dist/types/plugins/placeholder-text/styles.d.ts +0 -1
  110. package/dist/types/plugins/placeholder-text/types.d.ts +0 -18
  111. package/dist/types/plugins/placeholder-text/ui/FloatingToolbar/index.d.ts +0 -28
  112. package/dist/types/plugins/placeholder-text/ui/FloatingToolbar/styles.d.ts +0 -1
  113. package/dist/types/plugins/placeholder-text/ui/FloatingToolbar/utils.d.ts +0 -13
  114. package/dist/types/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.d.ts +0 -25
  115. package/dist/types-ts4.5/plugins/layout/actions.d.ts +0 -22
  116. package/dist/types-ts4.5/plugins/layout/index.d.ts +0 -18
  117. package/dist/types-ts4.5/plugins/layout/pm-plugins/main.d.ts +0 -6
  118. package/dist/types-ts4.5/plugins/layout/pm-plugins/plugin-key.d.ts +0 -3
  119. package/dist/types-ts4.5/plugins/layout/pm-plugins/types.d.ts +0 -14
  120. package/dist/types-ts4.5/plugins/layout/toolbar-messages.d.ts +0 -32
  121. package/dist/types-ts4.5/plugins/layout/toolbar.d.ts +0 -6
  122. package/dist/types-ts4.5/plugins/layout/types.d.ts +0 -13
  123. package/dist/types-ts4.5/plugins/placeholder-text/actions.d.ts +0 -4
  124. package/dist/types-ts4.5/plugins/placeholder-text/fake-text-cursor/cursor.d.ts +0 -30
  125. package/dist/types-ts4.5/plugins/placeholder-text/index.d.ts +0 -3
  126. package/dist/types-ts4.5/plugins/placeholder-text/placeholder-text-nodeview.d.ts +0 -17
  127. package/dist/types-ts4.5/plugins/placeholder-text/plugin-key.d.ts +0 -3
  128. package/dist/types-ts4.5/plugins/placeholder-text/plugin.d.ts +0 -7
  129. package/dist/types-ts4.5/plugins/placeholder-text/selection-utils.d.ts +0 -2
  130. package/dist/types-ts4.5/plugins/placeholder-text/styles.d.ts +0 -1
  131. package/dist/types-ts4.5/plugins/placeholder-text/types.d.ts +0 -18
  132. package/dist/types-ts4.5/plugins/placeholder-text/ui/FloatingToolbar/index.d.ts +0 -28
  133. package/dist/types-ts4.5/plugins/placeholder-text/ui/FloatingToolbar/styles.d.ts +0 -1
  134. package/dist/types-ts4.5/plugins/placeholder-text/ui/FloatingToolbar/utils.d.ts +0 -13
  135. package/dist/types-ts4.5/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.d.ts +0 -25
@@ -1,116 +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.layoutToolbarTitle = exports.buildToolbar = void 0;
8
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
- var _utils = require("@atlaskit/editor-prosemirror/utils");
10
- var _layoutSingle = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/layout-single"));
11
- var _layoutTwoEqual = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/layout-two-equal"));
12
- var _layoutThreeEqual = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/layout-three-equal"));
13
- var _layoutTwoLeftSidebar = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/layout-two-left-sidebar"));
14
- var _layoutTwoRightSidebar = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/layout-two-right-sidebar"));
15
- var _layoutThreeWithSidebars = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/layout-three-with-sidebars"));
16
- var _remove = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/remove"));
17
- var _toolbarMessages = require("./toolbar-messages");
18
- var _messages = _interopRequireDefault(require("@atlaskit/editor-common/messages"));
19
- var _actions = require("./actions");
20
- var LAYOUT_TYPES = [{
21
- id: 'editor.layout.twoEquals',
22
- type: 'two_equal',
23
- title: _toolbarMessages.toolbarMessages.twoColumns,
24
- icon: _layoutTwoEqual.default
25
- }, {
26
- id: 'editor.layout.threeEquals',
27
- type: 'three_equal',
28
- title: _toolbarMessages.toolbarMessages.threeColumns,
29
- icon: _layoutThreeEqual.default
30
- }];
31
- var LAYOUT_TYPES_WITH_SINGLE_COL = [{
32
- id: 'editor.layout.singeLayout',
33
- type: 'single',
34
- title: _toolbarMessages.toolbarMessages.singleColumn,
35
- icon: _layoutSingle.default
36
- }].concat(LAYOUT_TYPES);
37
- var SIDEBAR_LAYOUT_TYPES = [{
38
- id: 'editor.layout.twoRightSidebar',
39
- type: 'two_right_sidebar',
40
- title: _toolbarMessages.toolbarMessages.rightSidebar,
41
- icon: _layoutTwoRightSidebar.default
42
- }, {
43
- id: 'editor.layout.twoLeftSidebar',
44
- type: 'two_left_sidebar',
45
- title: _toolbarMessages.toolbarMessages.leftSidebar,
46
- icon: _layoutTwoLeftSidebar.default
47
- }, {
48
- id: 'editor.layout.threeWithSidebars',
49
- type: 'three_with_sidebars',
50
- title: _toolbarMessages.toolbarMessages.threeColumnsWithSidebars,
51
- icon: _layoutThreeWithSidebars.default
52
- }];
53
- var buildLayoutButton = function buildLayoutButton(intl, item, currentLayout, editorAnalyticsAPI) {
54
- return {
55
- id: item.id,
56
- type: 'button',
57
- icon: item.icon,
58
- testId: item.title.id ? "".concat(item.title.id) : undefined,
59
- title: intl.formatMessage(item.title),
60
- onClick: (0, _actions.setPresetLayout)(editorAnalyticsAPI)(item.type),
61
- selected: !!currentLayout && currentLayout === item.type,
62
- tabIndex: null
63
- };
64
- };
65
- var layoutToolbarTitle = exports.layoutToolbarTitle = 'Layout floating controls';
66
- var buildToolbar = exports.buildToolbar = function buildToolbar(state, intl, pos, _allowBreakout, addSidebarLayouts, allowSingleColumnLayout, api) {
67
- var _api$decorations$acti, _api$decorations, _api$analytics;
68
- var _ref = (_api$decorations$acti = api === null || api === void 0 || (_api$decorations = api.decorations) === null || _api$decorations === void 0 ? void 0 : _api$decorations.actions) !== null && _api$decorations$acti !== void 0 ? _api$decorations$acti : {},
69
- hoverDecoration = _ref.hoverDecoration;
70
- var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
71
- var node = state.doc.nodeAt(pos);
72
- if (node) {
73
- var currentLayout = (0, _actions.getPresetLayout)(node);
74
- var separator = {
75
- type: 'separator'
76
- };
77
- var nodeType = state.schema.nodes.layoutSection;
78
- var deleteButton = {
79
- id: 'editor.layout.delete',
80
- type: 'button',
81
- appearance: 'danger',
82
- focusEditoronEnter: true,
83
- icon: _remove.default,
84
- testId: _messages.default.remove.id,
85
- title: intl.formatMessage(_messages.default.remove),
86
- onClick: (0, _actions.deleteActiveLayoutNode)(editorAnalyticsAPI),
87
- onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true),
88
- onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false),
89
- onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true),
90
- onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false),
91
- tabIndex: null
92
- };
93
- var layoutTypes = allowSingleColumnLayout ? LAYOUT_TYPES_WITH_SINGLE_COL : LAYOUT_TYPES;
94
- return {
95
- title: layoutToolbarTitle,
96
- getDomRef: function getDomRef(view) {
97
- return (0, _utils.findDomRefAtPos)(pos, view.domAtPos.bind(view));
98
- },
99
- nodeType: nodeType,
100
- items: [].concat((0, _toConsumableArray2.default)(layoutTypes.map(function (i) {
101
- return buildLayoutButton(intl, i, currentLayout, editorAnalyticsAPI);
102
- })), (0, _toConsumableArray2.default)(addSidebarLayouts ? SIDEBAR_LAYOUT_TYPES.map(function (i) {
103
- return buildLayoutButton(intl, i, currentLayout, editorAnalyticsAPI);
104
- }) : []), [{
105
- type: 'copy-button',
106
- items: [separator, {
107
- state: state,
108
- formatMessage: intl.formatMessage,
109
- nodeType: nodeType
110
- }]
111
- }, separator, deleteButton]),
112
- scrollable: true
113
- };
114
- }
115
- return;
116
- };
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
@@ -1,35 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.showPlaceholderFloatingToolbar = exports.insertPlaceholderTextAtSelection = exports.hidePlaceholderFloatingToolbar = void 0;
7
- var _pluginKey = require("./plugin-key");
8
- var showPlaceholderFloatingToolbar = exports.showPlaceholderFloatingToolbar = function showPlaceholderFloatingToolbar(state, dispatch) {
9
- var tr = state.tr;
10
- if (!state.selection.empty) {
11
- tr.deleteSelection();
12
- }
13
- tr.setMeta(_pluginKey.pluginKey, {
14
- showInsertPanelAt: tr.selection.anchor
15
- });
16
- tr.scrollIntoView();
17
- dispatch(tr);
18
- return true;
19
- };
20
- var insertPlaceholderTextAtSelection = exports.insertPlaceholderTextAtSelection = function insertPlaceholderTextAtSelection(value) {
21
- return function (state, dispatch) {
22
- dispatch(state.tr.replaceSelectionWith(state.schema.nodes.placeholder.createChecked({
23
- text: value
24
- })).setMeta(_pluginKey.pluginKey, {
25
- showInsertPanelAt: null
26
- }).scrollIntoView());
27
- return true;
28
- };
29
- };
30
- var hidePlaceholderFloatingToolbar = exports.hidePlaceholderFloatingToolbar = function hidePlaceholderFloatingToolbar(state, dispatch) {
31
- dispatch(state.tr.setMeta(_pluginKey.pluginKey, {
32
- showInsertPanelAt: null
33
- }));
34
- return true;
35
- };
@@ -1,107 +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.removeFakeTextCursor = exports.drawFakeTextCursor = exports.addFakeTextCursor = exports.FakeTextCursorSelection = exports.FakeTextCursorBookmark = void 0;
8
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
9
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
10
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
11
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
12
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
- var _state = require("@atlaskit/editor-prosemirror/state");
15
- var _view = require("@atlaskit/editor-prosemirror/view");
16
- var _model = require("@atlaskit/editor-prosemirror/model");
17
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
18
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
19
- var FakeTextCursorBookmark = exports.FakeTextCursorBookmark = /*#__PURE__*/function () {
20
- function FakeTextCursorBookmark(pos) {
21
- (0, _classCallCheck2.default)(this, FakeTextCursorBookmark);
22
- (0, _defineProperty2.default)(this, "pos", undefined);
23
- (0, _defineProperty2.default)(this, "visible", false);
24
- this.pos = pos;
25
- }
26
- (0, _createClass2.default)(FakeTextCursorBookmark, [{
27
- key: "map",
28
- value: function map(mapping) {
29
- return new FakeTextCursorBookmark(mapping.map(this.pos));
30
- }
31
- }, {
32
- key: "resolve",
33
- value: function resolve(doc) {
34
- var $pos = doc.resolve(this.pos);
35
- return _state.Selection.near($pos);
36
- }
37
- }]);
38
- return FakeTextCursorBookmark;
39
- }();
40
- var FakeTextCursorSelection = exports.FakeTextCursorSelection = /*#__PURE__*/function (_Selection) {
41
- (0, _inherits2.default)(FakeTextCursorSelection, _Selection);
42
- var _super = _createSuper(FakeTextCursorSelection);
43
- function FakeTextCursorSelection($pos) {
44
- (0, _classCallCheck2.default)(this, FakeTextCursorSelection);
45
- return _super.call(this, $pos, $pos);
46
- }
47
- (0, _createClass2.default)(FakeTextCursorSelection, [{
48
- key: "map",
49
- value: function map(doc, mapping) {
50
- var $pos = doc.resolve(mapping.map(this.$head.pos));
51
- return new FakeTextCursorSelection($pos);
52
- }
53
- }, {
54
- key: "eq",
55
- value: function eq(other) {
56
- return other instanceof FakeTextCursorSelection && other.head === this.head;
57
- }
58
- }, {
59
- key: "toJSON",
60
- value: function toJSON() {
61
- return {
62
- type: 'Cursor',
63
- pos: this.head
64
- };
65
- }
66
- }, {
67
- key: "getBookmark",
68
- value: function getBookmark() {
69
- return new FakeTextCursorBookmark(this.anchor);
70
- }
71
- }], [{
72
- key: "content",
73
- value: function content() {
74
- return _model.Slice.empty;
75
- }
76
- }, {
77
- key: "fromJSON",
78
- value: function fromJSON(doc, json) {
79
- return new FakeTextCursorSelection(doc.resolve(json.pos));
80
- }
81
- }]);
82
- return FakeTextCursorSelection;
83
- }(_state.Selection);
84
- _state.Selection.jsonID('fake-text-cursor', FakeTextCursorSelection);
85
- var addFakeTextCursor = exports.addFakeTextCursor = function addFakeTextCursor(state, dispatch) {
86
- var selection = state.selection;
87
- if (selection.empty) {
88
- var $from = state.selection.$from;
89
- dispatch(state.tr.setSelection(new FakeTextCursorSelection($from)));
90
- }
91
- };
92
- var removeFakeTextCursor = exports.removeFakeTextCursor = function removeFakeTextCursor(state, dispatch) {
93
- if (state.selection instanceof FakeTextCursorSelection) {
94
- var $from = state.selection.$from;
95
- dispatch(state.tr.setSelection(new _state.TextSelection($from)));
96
- }
97
- };
98
- var drawFakeTextCursor = exports.drawFakeTextCursor = function drawFakeTextCursor(state) {
99
- if (!(state.selection instanceof FakeTextCursorSelection)) {
100
- return null;
101
- }
102
- var node = document.createElement('div');
103
- node.className = 'ProseMirror-fake-text-cursor';
104
- return _view.DecorationSet.create(state.doc, [_view.Decoration.widget(state.selection.head, node, {
105
- key: 'Cursor'
106
- })]);
107
- };
@@ -1,20 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- Object.defineProperty(exports, "FakeTextCursorSelection", {
8
- enumerable: true,
9
- get: function get() {
10
- return _cursor.FakeTextCursorSelection;
11
- }
12
- });
13
- Object.defineProperty(exports, "placeholderTextPlugin", {
14
- enumerable: true,
15
- get: function get() {
16
- return _plugin.default;
17
- }
18
- });
19
- var _plugin = _interopRequireDefault(require("./plugin"));
20
- var _cursor = require("./fake-text-cursor/cursor");
@@ -1,89 +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.PlaceholderTextNodeView = void 0;
8
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
- var _state = require("@atlaskit/editor-prosemirror/state");
11
- var _utils = require("@atlaskit/editor-common/utils");
12
- var serializePlaceholderNode = function serializePlaceholderNode(node) {
13
- var element = document.createElement('span');
14
- element.classList.add('pm-placeholder');
15
-
16
- // the inline node api test suite requires the following class name
17
- element.classList.add('placeholderView-content-wrap');
18
- element.innerText = _utils.ZERO_WIDTH_SPACE;
19
- var elementChildren = document.createElement('span');
20
- elementChildren.classList.add('pm-placeholder__text');
21
- elementChildren.dataset.placeholder = node.attrs.text;
22
- elementChildren.setAttribute('contenteditable', 'false');
23
- element.appendChild(elementChildren);
24
- if (_utils.browser.safari) {
25
- element.appendChild(document.createTextNode(_utils.ZERO_WIDTH_SPACE));
26
- } else {
27
- element.appendChild(document.createElement('wbr'));
28
- }
29
- return element;
30
- };
31
- var PlaceholderTextNodeView = exports.PlaceholderTextNodeView = /*#__PURE__*/function () {
32
- function PlaceholderTextNodeView(node, view, getPos) {
33
- (0, _classCallCheck2.default)(this, PlaceholderTextNodeView);
34
- this.node = node;
35
- this.view = view;
36
- this.getPos = getPos;
37
- this.dom = serializePlaceholderNode(this.node);
38
- this.getPos = getPos;
39
- }
40
- (0, _createClass2.default)(PlaceholderTextNodeView, [{
41
- key: "stopEvent",
42
- value: function stopEvent(e) {
43
- if (e.type === 'mousedown' && typeof this.getPos === 'function') {
44
- e.preventDefault();
45
- var _view = this.view;
46
- var startNodePosition = this.getPos();
47
- if (typeof startNodePosition !== 'number') {
48
- return false;
49
- }
50
- var tr = _view.state.tr;
51
- tr.setSelection(_state.Selection.near(tr.doc.resolve(startNodePosition)));
52
- _view.dispatch(tr);
53
- return true;
54
- }
55
- return false;
56
- }
57
- }, {
58
- key: "ignoreMutation",
59
- value: function ignoreMutation(record) {
60
- if (typeof this.getPos !== 'function' || record.type !== 'selection') {
61
- return true;
62
- }
63
- var view = this.view,
64
- node = this.node;
65
- var placeholderStartPosition = this.getPos();
66
- if (typeof placeholderStartPosition !== 'number') {
67
- return false;
68
- }
69
- var placeholderEndPosition = placeholderStartPosition + node.nodeSize;
70
- var selection = view.state.selection;
71
-
72
- // when the selection is set right after the placeholder.
73
- // we should let ProseMirror deal with this edge-case
74
- if (selection.from === placeholderEndPosition) {
75
- return false;
76
- }
77
- var isSelectionAtPlaceholder = selection.from === placeholderStartPosition;
78
- var isSelectionAfterlaceholder = selection.from > placeholderEndPosition;
79
- if (isSelectionAtPlaceholder || isSelectionAfterlaceholder) {
80
- var tr = view.state.tr;
81
- tr.setSelection(_state.Selection.near(tr.doc.resolve(placeholderEndPosition)));
82
- view.dispatch(tr);
83
- return true;
84
- }
85
- return true;
86
- }
87
- }]);
88
- return PlaceholderTextNodeView;
89
- }();
@@ -1,8 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.pluginKey = void 0;
7
- var _state = require("@atlaskit/editor-prosemirror/state");
8
- var pluginKey = exports.pluginKey = new _state.PluginKey('placeholderTextPlugin');
@@ -1,267 +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.createPlugin = createPlugin;
8
- exports.default = void 0;
9
- var _react = _interopRequireDefault(require("react"));
10
- var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
11
- var _state = require("@atlaskit/editor-prosemirror/state");
12
- var _adfSchema = require("@atlaskit/adf-schema");
13
- var _text = _interopRequireDefault(require("@atlaskit/icon/glyph/media-services/text"));
14
- var _hooks = require("@atlaskit/editor-common/hooks");
15
- var _utils = require("@atlaskit/editor-common/utils");
16
- var _cursor = require("./fake-text-cursor/cursor");
17
- var _PlaceholderFloatingToolbar = _interopRequireDefault(require("./ui/PlaceholderFloatingToolbar"));
18
- var _actions = require("./actions");
19
- var _placeholderTextNodeview = require("./placeholder-text-nodeview");
20
- var _pluginKey = require("./plugin-key");
21
- var _analytics = require("@atlaskit/editor-common/analytics");
22
- var _messages = require("@atlaskit/editor-common/messages");
23
- var _selectionUtils = require("./selection-utils");
24
- var getOpenTypeAhead = function getOpenTypeAhead(trigger, api) {
25
- var _api$typeAhead, _api$typeAhead2;
26
- var typeAheadHandler = api === null || api === void 0 || (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 || (_api$typeAhead = _api$typeAhead.actions) === null || _api$typeAhead === void 0 ? void 0 : _api$typeAhead.findHandlerByTrigger(trigger);
27
- if (!typeAheadHandler || !typeAheadHandler.id) {
28
- return null;
29
- }
30
- return api === null || api === void 0 || (_api$typeAhead2 = api.typeAhead) === null || _api$typeAhead2 === void 0 || (_api$typeAhead2 = _api$typeAhead2.actions) === null || _api$typeAhead2 === void 0 ? void 0 : _api$typeAhead2.openAtTransaction({
31
- triggerHandler: typeAheadHandler,
32
- inputMethod: _analytics.INPUT_METHOD.KEYBOARD
33
- });
34
- };
35
- function createPlugin(dispatch, options, api) {
36
- var allowInserting = !!options.allowInserting;
37
- return new _safePlugin.SafePlugin({
38
- key: _pluginKey.pluginKey,
39
- state: {
40
- init: function init() {
41
- return {
42
- showInsertPanelAt: null,
43
- allowInserting: allowInserting
44
- };
45
- },
46
- apply: function apply(tr, state) {
47
- var meta = tr.getMeta(_pluginKey.pluginKey);
48
- if (meta && meta.showInsertPanelAt !== undefined) {
49
- var newState = {
50
- showInsertPanelAt: meta.showInsertPanelAt,
51
- allowInserting: allowInserting
52
- };
53
- dispatch(_pluginKey.pluginKey, newState);
54
- return newState;
55
- } else if (state.showInsertPanelAt) {
56
- var _newState = {
57
- showInsertPanelAt: tr.mapping.map(state.showInsertPanelAt),
58
- allowInserting: allowInserting
59
- };
60
- dispatch(_pluginKey.pluginKey, _newState);
61
- return _newState;
62
- }
63
- return state;
64
- }
65
- },
66
- appendTransaction: function appendTransaction(transactions, oldState, newState) {
67
- if (transactions.some(function (txn) {
68
- return txn.docChanged;
69
- })) {
70
- var didPlaceholderExistBeforeTxn = oldState.selection.$head.nodeAfter === newState.selection.$head.nodeAfter;
71
- var adjacentNode = newState.selection.$head.nodeAfter;
72
- var adjacentNodePos = newState.selection.$head.pos;
73
- var placeholderNodeType = newState.schema.nodes.placeholder;
74
- if (adjacentNode && adjacentNode.type === placeholderNodeType && didPlaceholderExistBeforeTxn) {
75
- var _$newHead$nodeBefore;
76
- var $newHead = newState.selection.$head;
77
- var $oldHead = oldState.selection.$head;
78
- // Check that cursor has moved forward in the document **and** that there is content before the cursor
79
- var cursorMoved = $oldHead.pos < $newHead.pos;
80
- var nodeBeforeHasContent = !(0, _utils.isNodeEmpty)($newHead.nodeBefore);
81
- var nodeBeforeIsInline = (_$newHead$nodeBefore = $newHead.nodeBefore) === null || _$newHead$nodeBefore === void 0 ? void 0 : _$newHead$nodeBefore.type.isInline;
82
- if (cursorMoved && (nodeBeforeHasContent || nodeBeforeIsInline)) {
83
- var _NodeSelection$create = _state.NodeSelection.create(newState.doc, adjacentNodePos),
84
- $from = _NodeSelection$create.$from,
85
- $to = _NodeSelection$create.$to;
86
- return newState.tr.deleteRange($from.pos, $to.pos);
87
- }
88
- }
89
- }
90
-
91
- // Handle Fake Text Cursor for Floating Toolbar
92
- if (!_pluginKey.pluginKey.getState(oldState).showInsertPanelAt && _pluginKey.pluginKey.getState(newState).showInsertPanelAt) {
93
- return newState.tr.setSelection(new _cursor.FakeTextCursorSelection(newState.selection.$from));
94
- }
95
- if (_pluginKey.pluginKey.getState(oldState).showInsertPanelAt && !_pluginKey.pluginKey.getState(newState).showInsertPanelAt) {
96
- if (newState.selection instanceof _cursor.FakeTextCursorSelection) {
97
- return newState.tr.setSelection(new _state.TextSelection(newState.selection.$from));
98
- }
99
- }
100
- return;
101
- },
102
- props: {
103
- decorations: _cursor.drawFakeTextCursor,
104
- handleDOMEvents: {
105
- beforeinput: function beforeinput(view, event) {
106
- var state = view.state;
107
- if (event instanceof InputEvent && !event.isComposing && event.inputType === 'insertText' && (0, _selectionUtils.isSelectionAtPlaceholder)(view.state.selection)) {
108
- event.stopPropagation();
109
- event.preventDefault();
110
- var startNodePosition = state.selection.from;
111
- var content = event.data || '';
112
- var tr = view.state.tr;
113
- tr.delete(startNodePosition, startNodePosition + 1);
114
- var openTypeAhead = getOpenTypeAhead(content, api);
115
- if (openTypeAhead) {
116
- openTypeAhead(tr);
117
- } else {
118
- tr.insertText(content);
119
- }
120
- view.dispatch(tr);
121
- return true;
122
- }
123
- return false;
124
- }
125
- },
126
- nodeViews: {
127
- placeholder: function placeholder(node, view, getPos) {
128
- return new _placeholderTextNodeview.PlaceholderTextNodeView(node, view, getPos);
129
- }
130
- }
131
- }
132
- });
133
- }
134
- function ContentComponent(_ref) {
135
- var editorView = _ref.editorView,
136
- dependencyApi = _ref.dependencyApi,
137
- popupsMountPoint = _ref.popupsMountPoint,
138
- popupsBoundariesElement = _ref.popupsBoundariesElement;
139
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(dependencyApi, ['placeholderText']),
140
- placeholderTextState = _useSharedPluginState.placeholderTextState;
141
- var insertPlaceholderText = function insertPlaceholderText(value) {
142
- return (0, _actions.insertPlaceholderTextAtSelection)(value)(editorView.state, editorView.dispatch);
143
- };
144
- var hidePlaceholderToolbar = function hidePlaceholderToolbar() {
145
- return (0, _actions.hidePlaceholderFloatingToolbar)(editorView.state, editorView.dispatch);
146
- };
147
- var getNodeFromPos = function getNodeFromPos(pos) {
148
- return editorView.domAtPos(pos).node;
149
- };
150
- var getFixedCoordinatesFromPos = function getFixedCoordinatesFromPos(pos) {
151
- return editorView.coordsAtPos(pos);
152
- };
153
- var setFocusInEditor = function setFocusInEditor() {
154
- return editorView.focus();
155
- };
156
- if (placeholderTextState !== null && placeholderTextState !== void 0 && placeholderTextState.showInsertPanelAt) {
157
- return /*#__PURE__*/_react.default.createElement(_PlaceholderFloatingToolbar.default, {
158
- editorViewDOM: editorView.dom,
159
- popupsMountPoint: popupsMountPoint,
160
- popupsBoundariesElement: popupsBoundariesElement,
161
- getFixedCoordinatesFromPos: getFixedCoordinatesFromPos,
162
- getNodeFromPos: getNodeFromPos,
163
- hidePlaceholderFloatingToolbar: hidePlaceholderToolbar,
164
- showInsertPanelAt: placeholderTextState.showInsertPanelAt,
165
- insertPlaceholder: insertPlaceholderText,
166
- setFocusInEditor: setFocusInEditor
167
- });
168
- }
169
- return null;
170
- }
171
- var basePlaceholderTextPlugin = function basePlaceholderTextPlugin(_ref2) {
172
- var api = _ref2.api,
173
- options = _ref2.config;
174
- return {
175
- name: 'placeholderText',
176
- nodes: function nodes() {
177
- return [{
178
- name: 'placeholder',
179
- node: _adfSchema.placeholder
180
- }];
181
- },
182
- pmPlugins: function pmPlugins() {
183
- return [{
184
- name: 'placeholderText',
185
- plugin: function plugin(_ref3) {
186
- var dispatch = _ref3.dispatch;
187
- return createPlugin(dispatch, options, api);
188
- }
189
- }];
190
- },
191
- getSharedState: function getSharedState(editorState) {
192
- if (!editorState) {
193
- return undefined;
194
- }
195
- var _ref4 = _pluginKey.pluginKey.getState(editorState) || {
196
- showInsertPanelAt: null
197
- },
198
- showInsertPanelAt = _ref4.showInsertPanelAt,
199
- allowInserting = _ref4.allowInserting;
200
- return {
201
- showInsertPanelAt: showInsertPanelAt,
202
- allowInserting: !!allowInserting
203
- };
204
- },
205
- contentComponent: function contentComponent(_ref5) {
206
- var editorView = _ref5.editorView,
207
- popupsMountPoint = _ref5.popupsMountPoint,
208
- popupsBoundariesElement = _ref5.popupsBoundariesElement;
209
- return /*#__PURE__*/_react.default.createElement(ContentComponent, {
210
- editorView: editorView,
211
- popupsMountPoint: popupsMountPoint,
212
- popupsBoundariesElement: popupsBoundariesElement,
213
- dependencyApi: api
214
- });
215
- }
216
- };
217
- };
218
- var decorateWithPluginOptions = function decorateWithPluginOptions(plugin, options, api) {
219
- if (!options.allowInserting) {
220
- return plugin;
221
- }
222
- plugin.pluginsOptions = {
223
- quickInsert: function quickInsert(_ref6) {
224
- var formatMessage = _ref6.formatMessage;
225
- return [{
226
- id: 'placeholderText',
227
- title: formatMessage(_messages.toolbarInsertBlockMessages.placeholderText),
228
- description: formatMessage(_messages.toolbarInsertBlockMessages.placeholderTextDescription),
229
- priority: 1400,
230
- keywords: ['placeholder'],
231
- icon: function icon() {
232
- return /*#__PURE__*/_react.default.createElement(_text.default, {
233
- label: ""
234
- });
235
- },
236
- action: function action(insert, state) {
237
- var _api$analytics;
238
- var tr = state.tr;
239
- tr.setMeta(_pluginKey.pluginKey, {
240
- showInsertPanelAt: tr.selection.anchor
241
- });
242
- api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
243
- action: _analytics.ACTION.INSERTED,
244
- actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
245
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.PLACEHOLDER_TEXT,
246
- attributes: {
247
- inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT
248
- },
249
- eventType: _analytics.EVENT_TYPE.TRACK
250
- })(tr);
251
- return tr;
252
- }
253
- }];
254
- }
255
- };
256
- return plugin;
257
- };
258
- var placeholderTextPlugin = function placeholderTextPlugin(_ref7) {
259
- var _ref7$config = _ref7.config,
260
- options = _ref7$config === void 0 ? {} : _ref7$config,
261
- api = _ref7.api;
262
- return decorateWithPluginOptions(basePlaceholderTextPlugin({
263
- config: options,
264
- api: api
265
- }), options, api);
266
- };
267
- var _default = exports.default = placeholderTextPlugin;
@@ -1,14 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isSelectionAtPlaceholder = void 0;
7
- var _state = require("@atlaskit/editor-prosemirror/state");
8
- var isSelectionAtPlaceholder = exports.isSelectionAtPlaceholder = function isSelectionAtPlaceholder(selection) {
9
- if (!(selection instanceof _state.TextSelection) || !selection.$cursor) {
10
- return false;
11
- }
12
- var node = selection.$cursor.doc.nodeAt(selection.$cursor.pos);
13
- return (node === null || node === void 0 ? void 0 : node.type.name) === 'placeholder';
14
- };