@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,142 +0,0 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { TextSelection, Selection } from '@atlaskit/editor-prosemirror/state';
3
- import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
4
- import { keydownHandler } from '@atlaskit/editor-prosemirror/keymap';
5
- import { findParentNodeOfType, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
6
- import { filterCommand as filter } from '@atlaskit/editor-common/utils';
7
- import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
8
- import { fixColumnSizes, fixColumnStructure, getSelectedLayout } from '../actions';
9
- import { pluginKey } from './plugin-key';
10
- export const DEFAULT_LAYOUT = 'two_equal';
11
- const isWholeSelectionInsideLayoutColumn = state => {
12
- // Since findParentNodeOfType doesn't check if selection.to shares the parent, we do this check ourselves
13
- const fromParent = findParentNodeOfType(state.schema.nodes.layoutColumn)(state.selection);
14
- if (fromParent) {
15
- const isToPosInsideSameLayoutColumn = state.selection.from < fromParent.pos + fromParent.node.nodeSize;
16
- return isToPosInsideSameLayoutColumn;
17
- }
18
- return false;
19
- };
20
- const moveCursorToNextColumn = (state, dispatch) => {
21
- const {
22
- selection
23
- } = state;
24
- const {
25
- schema: {
26
- nodes: {
27
- layoutColumn,
28
- layoutSection
29
- }
30
- }
31
- } = state;
32
- const section = findParentNodeOfType(layoutSection)(selection);
33
- const column = findParentNodeOfType(layoutColumn)(selection);
34
- if (column.node !== section.node.lastChild) {
35
- const $nextColumn = state.doc.resolve(column.pos + column.node.nodeSize);
36
- const shiftedSelection = TextSelection.findFrom($nextColumn, 1);
37
- if (dispatch) {
38
- dispatch(state.tr.setSelection(shiftedSelection));
39
- }
40
- }
41
- return true;
42
- };
43
-
44
- // TODO: Look at memoize-one-ing this fn
45
- const getNodeDecoration = (pos, node) => [Decoration.node(pos, pos + node.nodeSize, {
46
- class: 'selected'
47
- })];
48
- const getInitialPluginState = (options, state) => {
49
- const maybeLayoutSection = findParentNodeOfType(state.schema.nodes.layoutSection)(state.selection);
50
- const allowBreakout = options.allowBreakout || false;
51
- const addSidebarLayouts = options.UNSAFE_addSidebarLayouts || false;
52
- const allowSingleColumnLayout = options.UNSAFE_allowSingleColumnLayout || false;
53
- const pos = maybeLayoutSection ? maybeLayoutSection.pos : null;
54
- const selectedLayout = getSelectedLayout(maybeLayoutSection && maybeLayoutSection.node, DEFAULT_LAYOUT);
55
- return {
56
- pos,
57
- allowBreakout,
58
- addSidebarLayouts,
59
- selectedLayout,
60
- allowSingleColumnLayout
61
- };
62
- };
63
- export default (options => new SafePlugin({
64
- key: pluginKey,
65
- state: {
66
- init: (_, state) => getInitialPluginState(options, state),
67
- apply: (tr, pluginState, _oldState, newState) => {
68
- if (tr.docChanged || tr.selectionSet) {
69
- const {
70
- schema: {
71
- nodes: {
72
- layoutSection
73
- }
74
- },
75
- selection
76
- } = newState;
77
- const maybeLayoutSection = findParentNodeOfType(layoutSection)(selection) || findSelectedNodeOfType([layoutSection])(selection);
78
- const newPluginState = {
79
- ...pluginState,
80
- pos: maybeLayoutSection ? maybeLayoutSection.pos : null,
81
- selectedLayout: getSelectedLayout(maybeLayoutSection && maybeLayoutSection.node, pluginState.selectedLayout)
82
- };
83
- return newPluginState;
84
- }
85
- return pluginState;
86
- }
87
- },
88
- props: {
89
- decorations(state) {
90
- const layoutState = pluginKey.getState(state);
91
- if (layoutState.pos !== null) {
92
- return DecorationSet.create(state.doc, getNodeDecoration(layoutState.pos, state.doc.nodeAt(layoutState.pos)));
93
- }
94
- return undefined;
95
- },
96
- handleKeyDown: keydownHandler({
97
- Tab: filter(isWholeSelectionInsideLayoutColumn, moveCursorToNextColumn)
98
- }),
99
- handleClickOn: createSelectionClickHandler(['layoutColumn'], target => target.hasAttribute('data-layout-section') || target.hasAttribute('data-layout-column'), {
100
- useLongPressSelection: options.useLongPressSelection || false,
101
- getNodeSelectionPos: (state, nodePos) => state.doc.resolve(nodePos).before()
102
- })
103
- },
104
- appendTransaction: (transactions, _oldState, newState) => {
105
- let changes = [];
106
- transactions.forEach(prevTr => {
107
- // remap change segments across the transaction set
108
- changes.forEach(change => {
109
- return {
110
- from: prevTr.mapping.map(change.from),
111
- to: prevTr.mapping.map(change.to),
112
- slice: change.slice
113
- };
114
- });
115
-
116
- // don't consider transactions that don't mutate
117
- if (!prevTr.docChanged) {
118
- return;
119
- }
120
- const change = fixColumnSizes(prevTr, newState);
121
- if (change) {
122
- changes.push(change);
123
- }
124
- });
125
- if (changes.length) {
126
- let tr = newState.tr;
127
- const selection = newState.selection.toJSON();
128
- changes.forEach(change => {
129
- tr.replaceRange(change.from, change.to, change.slice);
130
- });
131
-
132
- // selecting and deleting across columns in 3 col layouts can remove
133
- // a layoutColumn so we fix the structure here
134
- tr = fixColumnStructure(newState) || tr;
135
- if (tr.docChanged) {
136
- tr.setSelection(Selection.fromJSON(tr.doc, selection));
137
- return tr;
138
- }
139
- }
140
- return;
141
- }
142
- }));
@@ -1,2 +0,0 @@
1
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
- export const pluginKey = new PluginKey('layout');
@@ -1 +0,0 @@
1
- export {};
@@ -1,33 +0,0 @@
1
- import { defineMessages } from 'react-intl-next';
2
- export const toolbarMessages = defineMessages({
3
- singleColumn: {
4
- id: 'fabric.editor.single',
5
- defaultMessage: 'Single column',
6
- description: 'Layout with one single column'
7
- },
8
- twoColumns: {
9
- id: 'fabric.editor.twoColumns',
10
- defaultMessage: 'Two columns',
11
- description: 'Layout with two columns of equal width'
12
- },
13
- threeColumns: {
14
- id: 'fabric.editor.threeColumns',
15
- defaultMessage: 'Three columns',
16
- description: 'Layout with three columns of equal width'
17
- },
18
- rightSidebar: {
19
- id: 'fabric.editor.rightSidebar',
20
- defaultMessage: 'Right sidebar',
21
- description: 'Layout with two columns, left column is 2/3 and right is 1/3 of page'
22
- },
23
- leftSidebar: {
24
- id: 'fabric.editor.leftSidebar',
25
- defaultMessage: 'Left sidebar',
26
- description: 'Layout with two columns, left column is 1/3 and right is 2/3 of page'
27
- },
28
- threeColumnsWithSidebars: {
29
- id: 'fabric.editor.threeColumnsWithSidebars',
30
- defaultMessage: 'Three columns with sidebars',
31
- description: 'Layout with 3 columns laid out as 25% - 50% - 25%'
32
- }
33
- });
@@ -1,101 +0,0 @@
1
- import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
2
- import EditorLayoutSingleIcon from '@atlaskit/icon/glyph/editor/layout-single';
3
- import LayoutTwoEqualIcon from '@atlaskit/icon/glyph/editor/layout-two-equal';
4
- import LayoutThreeEqualIcon from '@atlaskit/icon/glyph/editor/layout-three-equal';
5
- import LayoutTwoLeftSidebarIcon from '@atlaskit/icon/glyph/editor/layout-two-left-sidebar';
6
- import LayoutTwoRightSidebarIcon from '@atlaskit/icon/glyph/editor/layout-two-right-sidebar';
7
- import LayoutThreeWithSidebarsIcon from '@atlaskit/icon/glyph/editor/layout-three-with-sidebars';
8
- import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
9
- import { toolbarMessages } from './toolbar-messages';
10
- import commonMessages from '@atlaskit/editor-common/messages';
11
- import { setPresetLayout, deleteActiveLayoutNode, getPresetLayout } from './actions';
12
- const LAYOUT_TYPES = [{
13
- id: 'editor.layout.twoEquals',
14
- type: 'two_equal',
15
- title: toolbarMessages.twoColumns,
16
- icon: LayoutTwoEqualIcon
17
- }, {
18
- id: 'editor.layout.threeEquals',
19
- type: 'three_equal',
20
- title: toolbarMessages.threeColumns,
21
- icon: LayoutThreeEqualIcon
22
- }];
23
- const LAYOUT_TYPES_WITH_SINGLE_COL = [{
24
- id: 'editor.layout.singeLayout',
25
- type: 'single',
26
- title: toolbarMessages.singleColumn,
27
- icon: EditorLayoutSingleIcon
28
- }, ...LAYOUT_TYPES];
29
- const SIDEBAR_LAYOUT_TYPES = [{
30
- id: 'editor.layout.twoRightSidebar',
31
- type: 'two_right_sidebar',
32
- title: toolbarMessages.rightSidebar,
33
- icon: LayoutTwoRightSidebarIcon
34
- }, {
35
- id: 'editor.layout.twoLeftSidebar',
36
- type: 'two_left_sidebar',
37
- title: toolbarMessages.leftSidebar,
38
- icon: LayoutTwoLeftSidebarIcon
39
- }, {
40
- id: 'editor.layout.threeWithSidebars',
41
- type: 'three_with_sidebars',
42
- title: toolbarMessages.threeColumnsWithSidebars,
43
- icon: LayoutThreeWithSidebarsIcon
44
- }];
45
- const buildLayoutButton = (intl, item, currentLayout, editorAnalyticsAPI) => ({
46
- id: item.id,
47
- type: 'button',
48
- icon: item.icon,
49
- testId: item.title.id ? `${item.title.id}` : undefined,
50
- title: intl.formatMessage(item.title),
51
- onClick: setPresetLayout(editorAnalyticsAPI)(item.type),
52
- selected: !!currentLayout && currentLayout === item.type,
53
- tabIndex: null
54
- });
55
- export const layoutToolbarTitle = 'Layout floating controls';
56
- export const buildToolbar = (state, intl, pos, _allowBreakout, addSidebarLayouts, allowSingleColumnLayout, api) => {
57
- var _api$decorations$acti, _api$decorations, _api$analytics;
58
- const {
59
- hoverDecoration
60
- } = (_api$decorations$acti = api === null || api === void 0 ? 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 : {};
61
- const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
62
- const node = state.doc.nodeAt(pos);
63
- if (node) {
64
- const currentLayout = getPresetLayout(node);
65
- const separator = {
66
- type: 'separator'
67
- };
68
- const nodeType = state.schema.nodes.layoutSection;
69
- const deleteButton = {
70
- id: 'editor.layout.delete',
71
- type: 'button',
72
- appearance: 'danger',
73
- focusEditoronEnter: true,
74
- icon: RemoveIcon,
75
- testId: commonMessages.remove.id,
76
- title: intl.formatMessage(commonMessages.remove),
77
- onClick: deleteActiveLayoutNode(editorAnalyticsAPI),
78
- onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true),
79
- onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false),
80
- onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true),
81
- onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false),
82
- tabIndex: null
83
- };
84
- const layoutTypes = allowSingleColumnLayout ? LAYOUT_TYPES_WITH_SINGLE_COL : LAYOUT_TYPES;
85
- return {
86
- title: layoutToolbarTitle,
87
- getDomRef: view => findDomRefAtPos(pos, view.domAtPos.bind(view)),
88
- nodeType,
89
- items: [...layoutTypes.map(i => buildLayoutButton(intl, i, currentLayout, editorAnalyticsAPI)), ...(addSidebarLayouts ? SIDEBAR_LAYOUT_TYPES.map(i => buildLayoutButton(intl, i, currentLayout, editorAnalyticsAPI)) : []), {
90
- type: 'copy-button',
91
- items: [separator, {
92
- state,
93
- formatMessage: intl.formatMessage,
94
- nodeType
95
- }]
96
- }, separator, deleteButton],
97
- scrollable: true
98
- };
99
- }
100
- return;
101
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,27 +0,0 @@
1
- import { pluginKey } from './plugin-key';
2
- export const showPlaceholderFloatingToolbar = (state, dispatch) => {
3
- const tr = state.tr;
4
- if (!state.selection.empty) {
5
- tr.deleteSelection();
6
- }
7
- tr.setMeta(pluginKey, {
8
- showInsertPanelAt: tr.selection.anchor
9
- });
10
- tr.scrollIntoView();
11
- dispatch(tr);
12
- return true;
13
- };
14
- export const insertPlaceholderTextAtSelection = value => (state, dispatch) => {
15
- dispatch(state.tr.replaceSelectionWith(state.schema.nodes.placeholder.createChecked({
16
- text: value
17
- })).setMeta(pluginKey, {
18
- showInsertPanelAt: null
19
- }).scrollIntoView());
20
- return true;
21
- };
22
- export const hidePlaceholderFloatingToolbar = (state, dispatch) => {
23
- dispatch(state.tr.setMeta(pluginKey, {
24
- showInsertPanelAt: null
25
- }));
26
- return true;
27
- };
@@ -1,77 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import { TextSelection, Selection } from '@atlaskit/editor-prosemirror/state';
3
- import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
4
- import { Slice } from '@atlaskit/editor-prosemirror/model';
5
- export class FakeTextCursorBookmark {
6
- constructor(pos) {
7
- _defineProperty(this, "pos", undefined);
8
- _defineProperty(this, "visible", false);
9
- this.pos = pos;
10
- }
11
- map(mapping) {
12
- return new FakeTextCursorBookmark(mapping.map(this.pos));
13
- }
14
- resolve(doc) {
15
- const $pos = doc.resolve(this.pos);
16
- return Selection.near($pos);
17
- }
18
- }
19
- export class FakeTextCursorSelection extends Selection {
20
- constructor($pos) {
21
- super($pos, $pos);
22
- }
23
- map(doc, mapping) {
24
- const $pos = doc.resolve(mapping.map(this.$head.pos));
25
- return new FakeTextCursorSelection($pos);
26
- }
27
- static content() {
28
- return Slice.empty;
29
- }
30
- eq(other) {
31
- return other instanceof FakeTextCursorSelection && other.head === this.head;
32
- }
33
- toJSON() {
34
- return {
35
- type: 'Cursor',
36
- pos: this.head
37
- };
38
- }
39
- static fromJSON(doc, json) {
40
- return new FakeTextCursorSelection(doc.resolve(json.pos));
41
- }
42
- getBookmark() {
43
- return new FakeTextCursorBookmark(this.anchor);
44
- }
45
- }
46
- Selection.jsonID('fake-text-cursor', FakeTextCursorSelection);
47
- export const addFakeTextCursor = (state, dispatch) => {
48
- const {
49
- selection
50
- } = state;
51
- if (selection.empty) {
52
- const {
53
- selection: {
54
- $from
55
- }
56
- } = state;
57
- dispatch(state.tr.setSelection(new FakeTextCursorSelection($from)));
58
- }
59
- };
60
- export const removeFakeTextCursor = (state, dispatch) => {
61
- if (state.selection instanceof FakeTextCursorSelection) {
62
- const {
63
- $from
64
- } = state.selection;
65
- dispatch(state.tr.setSelection(new TextSelection($from)));
66
- }
67
- };
68
- export const drawFakeTextCursor = state => {
69
- if (!(state.selection instanceof FakeTextCursorSelection)) {
70
- return null;
71
- }
72
- const node = document.createElement('div');
73
- node.className = 'ProseMirror-fake-text-cursor';
74
- return DecorationSet.create(state.doc, [Decoration.widget(state.selection.head, node, {
75
- key: 'Cursor'
76
- })]);
77
- };
@@ -1,2 +0,0 @@
1
- export { default as placeholderTextPlugin } from './plugin';
2
- export { FakeTextCursorSelection } from './fake-text-cursor/cursor';
@@ -1,77 +0,0 @@
1
- import { Selection } from '@atlaskit/editor-prosemirror/state';
2
- import { browser, ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/utils';
3
- const serializePlaceholderNode = node => {
4
- const element = document.createElement('span');
5
- element.classList.add('pm-placeholder');
6
-
7
- // the inline node api test suite requires the following class name
8
- element.classList.add('placeholderView-content-wrap');
9
- element.innerText = ZERO_WIDTH_SPACE;
10
- const elementChildren = document.createElement('span');
11
- elementChildren.classList.add('pm-placeholder__text');
12
- elementChildren.dataset.placeholder = node.attrs.text;
13
- elementChildren.setAttribute('contenteditable', 'false');
14
- element.appendChild(elementChildren);
15
- if (browser.safari) {
16
- element.appendChild(document.createTextNode(ZERO_WIDTH_SPACE));
17
- } else {
18
- element.appendChild(document.createElement('wbr'));
19
- }
20
- return element;
21
- };
22
- export class PlaceholderTextNodeView {
23
- constructor(node, view, getPos) {
24
- this.node = node;
25
- this.view = view;
26
- this.getPos = getPos;
27
- this.dom = serializePlaceholderNode(this.node);
28
- this.getPos = getPos;
29
- }
30
- stopEvent(e) {
31
- if (e.type === 'mousedown' && typeof this.getPos === 'function') {
32
- e.preventDefault();
33
- const {
34
- view
35
- } = this;
36
- const startNodePosition = this.getPos();
37
- if (typeof startNodePosition !== 'number') {
38
- return false;
39
- }
40
- const tr = view.state.tr;
41
- tr.setSelection(Selection.near(tr.doc.resolve(startNodePosition)));
42
- view.dispatch(tr);
43
- return true;
44
- }
45
- return false;
46
- }
47
- ignoreMutation(record) {
48
- if (typeof this.getPos !== 'function' || record.type !== 'selection') {
49
- return true;
50
- }
51
- const {
52
- view,
53
- node
54
- } = this;
55
- const placeholderStartPosition = this.getPos();
56
- if (typeof placeholderStartPosition !== 'number') {
57
- return false;
58
- }
59
- const placeholderEndPosition = placeholderStartPosition + node.nodeSize;
60
- const selection = view.state.selection;
61
-
62
- // when the selection is set right after the placeholder.
63
- // we should let ProseMirror deal with this edge-case
64
- if (selection.from === placeholderEndPosition) {
65
- return false;
66
- }
67
- const isSelectionAtPlaceholder = selection.from === placeholderStartPosition;
68
- const isSelectionAfterlaceholder = selection.from > placeholderEndPosition;
69
- if (isSelectionAtPlaceholder || isSelectionAfterlaceholder) {
70
- const tr = view.state.tr;
71
- tr.setSelection(Selection.near(tr.doc.resolve(placeholderEndPosition)));
72
- view.dispatch(tr);
73
- return true;
74
- }
75
- return true;
76
- }
77
- }
@@ -1,2 +0,0 @@
1
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
- export const pluginKey = new PluginKey('placeholderTextPlugin');