@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.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/plugins/index.js +0 -14
- package/dist/cjs/plugins/insert-block/index.js +6 -10
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +40 -38
- package/dist/cjs/presets/universal.js +4 -2
- package/dist/cjs/ui/ContentStyles/index.js +1 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/plugins/index.js +0 -2
- package/dist/es2019/plugins/insert-block/index.js +5 -9
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +4 -3
- package/dist/es2019/presets/universal.js +3 -1
- package/dist/es2019/ui/ContentStyles/index.js +1 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/plugins/index.js +0 -2
- package/dist/esm/plugins/insert-block/index.js +5 -9
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +40 -38
- package/dist/esm/presets/universal.js +3 -1
- package/dist/esm/ui/ContentStyles/index.js +1 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/index.d.ts +0 -2
- package/dist/types/plugins/insert-block/types.d.ts +4 -2
- package/dist/types/types/editor-props.d.ts +2 -2
- package/dist/types/ui/ConfigPanel/ConfigPanel.d.ts +1 -1
- package/dist/types-ts4.5/plugins/index.d.ts +0 -2
- package/dist/types-ts4.5/plugins/insert-block/types.d.ts +4 -2
- package/dist/types-ts4.5/types/editor-props.d.ts +2 -2
- package/dist/types-ts4.5/ui/ConfigPanel/ConfigPanel.d.ts +1 -1
- package/package.json +4 -2
- package/report.api.md +2 -16
- package/tmp/api-report-tmp.d.ts +2 -16
- package/dist/cjs/plugins/layout/actions.js +0 -345
- package/dist/cjs/plugins/layout/index.js +0 -91
- package/dist/cjs/plugins/layout/pm-plugins/main.js +0 -148
- package/dist/cjs/plugins/layout/pm-plugins/plugin-key.js +0 -8
- package/dist/cjs/plugins/layout/pm-plugins/types.js +0 -5
- package/dist/cjs/plugins/layout/toolbar-messages.js +0 -39
- package/dist/cjs/plugins/layout/toolbar.js +0 -116
- package/dist/cjs/plugins/layout/types.js +0 -5
- package/dist/cjs/plugins/placeholder-text/actions.js +0 -35
- package/dist/cjs/plugins/placeholder-text/fake-text-cursor/cursor.js +0 -107
- package/dist/cjs/plugins/placeholder-text/index.js +0 -20
- package/dist/cjs/plugins/placeholder-text/placeholder-text-nodeview.js +0 -89
- package/dist/cjs/plugins/placeholder-text/plugin-key.js +0 -8
- package/dist/cjs/plugins/placeholder-text/plugin.js +0 -267
- package/dist/cjs/plugins/placeholder-text/selection-utils.js +0 -14
- package/dist/cjs/plugins/placeholder-text/styles.js +0 -13
- package/dist/cjs/plugins/placeholder-text/types.js +0 -5
- package/dist/cjs/plugins/placeholder-text/ui/FloatingToolbar/index.js +0 -86
- package/dist/cjs/plugins/placeholder-text/ui/FloatingToolbar/styles.js +0 -15
- package/dist/cjs/plugins/placeholder-text/ui/FloatingToolbar/utils.js +0 -54
- package/dist/cjs/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.js +0 -89
- package/dist/es2019/plugins/layout/actions.js +0 -328
- package/dist/es2019/plugins/layout/index.js +0 -75
- package/dist/es2019/plugins/layout/pm-plugins/main.js +0 -142
- package/dist/es2019/plugins/layout/pm-plugins/plugin-key.js +0 -2
- package/dist/es2019/plugins/layout/pm-plugins/types.js +0 -1
- package/dist/es2019/plugins/layout/toolbar-messages.js +0 -33
- package/dist/es2019/plugins/layout/toolbar.js +0 -101
- package/dist/es2019/plugins/layout/types.js +0 -1
- package/dist/es2019/plugins/placeholder-text/actions.js +0 -27
- package/dist/es2019/plugins/placeholder-text/fake-text-cursor/cursor.js +0 -77
- package/dist/es2019/plugins/placeholder-text/index.js +0 -2
- package/dist/es2019/plugins/placeholder-text/placeholder-text-nodeview.js +0 -77
- package/dist/es2019/plugins/placeholder-text/plugin-key.js +0 -2
- package/dist/es2019/plugins/placeholder-text/plugin.js +0 -247
- package/dist/es2019/plugins/placeholder-text/selection-utils.js +0 -8
- package/dist/es2019/plugins/placeholder-text/styles.js +0 -52
- package/dist/es2019/plugins/placeholder-text/types.js +0 -1
- package/dist/es2019/plugins/placeholder-text/ui/FloatingToolbar/index.js +0 -45
- package/dist/es2019/plugins/placeholder-text/ui/FloatingToolbar/styles.js +0 -15
- package/dist/es2019/plugins/placeholder-text/ui/FloatingToolbar/utils.js +0 -41
- package/dist/es2019/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.js +0 -60
- package/dist/esm/plugins/layout/actions.js +0 -336
- package/dist/esm/plugins/layout/index.js +0 -79
- package/dist/esm/plugins/layout/pm-plugins/main.js +0 -141
- package/dist/esm/plugins/layout/pm-plugins/plugin-key.js +0 -2
- package/dist/esm/plugins/layout/pm-plugins/types.js +0 -1
- package/dist/esm/plugins/layout/toolbar-messages.js +0 -33
- package/dist/esm/plugins/layout/toolbar.js +0 -109
- package/dist/esm/plugins/layout/types.js +0 -1
- package/dist/esm/plugins/placeholder-text/actions.js +0 -29
- package/dist/esm/plugins/placeholder-text/fake-text-cursor/cursor.js +0 -100
- package/dist/esm/plugins/placeholder-text/index.js +0 -2
- package/dist/esm/plugins/placeholder-text/placeholder-text-nodeview.js +0 -82
- package/dist/esm/plugins/placeholder-text/plugin-key.js +0 -2
- package/dist/esm/plugins/placeholder-text/plugin.js +0 -259
- package/dist/esm/plugins/placeholder-text/selection-utils.js +0 -8
- package/dist/esm/plugins/placeholder-text/styles.js +0 -6
- package/dist/esm/plugins/placeholder-text/types.js +0 -1
- package/dist/esm/plugins/placeholder-text/ui/FloatingToolbar/index.js +0 -63
- package/dist/esm/plugins/placeholder-text/ui/FloatingToolbar/styles.js +0 -8
- package/dist/esm/plugins/placeholder-text/ui/FloatingToolbar/utils.js +0 -48
- package/dist/esm/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.js +0 -79
- package/dist/types/plugins/layout/actions.d.ts +0 -22
- package/dist/types/plugins/layout/index.d.ts +0 -15
- package/dist/types/plugins/layout/pm-plugins/main.d.ts +0 -6
- package/dist/types/plugins/layout/pm-plugins/plugin-key.d.ts +0 -3
- package/dist/types/plugins/layout/pm-plugins/types.d.ts +0 -14
- package/dist/types/plugins/layout/toolbar-messages.d.ts +0 -32
- package/dist/types/plugins/layout/toolbar.d.ts +0 -6
- package/dist/types/plugins/layout/types.d.ts +0 -13
- package/dist/types/plugins/placeholder-text/actions.d.ts +0 -4
- package/dist/types/plugins/placeholder-text/fake-text-cursor/cursor.d.ts +0 -30
- package/dist/types/plugins/placeholder-text/index.d.ts +0 -3
- package/dist/types/plugins/placeholder-text/placeholder-text-nodeview.d.ts +0 -17
- package/dist/types/plugins/placeholder-text/plugin-key.d.ts +0 -3
- package/dist/types/plugins/placeholder-text/plugin.d.ts +0 -7
- package/dist/types/plugins/placeholder-text/selection-utils.d.ts +0 -2
- package/dist/types/plugins/placeholder-text/styles.d.ts +0 -1
- package/dist/types/plugins/placeholder-text/types.d.ts +0 -18
- package/dist/types/plugins/placeholder-text/ui/FloatingToolbar/index.d.ts +0 -28
- package/dist/types/plugins/placeholder-text/ui/FloatingToolbar/styles.d.ts +0 -1
- package/dist/types/plugins/placeholder-text/ui/FloatingToolbar/utils.d.ts +0 -13
- package/dist/types/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.d.ts +0 -25
- package/dist/types-ts4.5/plugins/layout/actions.d.ts +0 -22
- package/dist/types-ts4.5/plugins/layout/index.d.ts +0 -18
- package/dist/types-ts4.5/plugins/layout/pm-plugins/main.d.ts +0 -6
- package/dist/types-ts4.5/plugins/layout/pm-plugins/plugin-key.d.ts +0 -3
- package/dist/types-ts4.5/plugins/layout/pm-plugins/types.d.ts +0 -14
- package/dist/types-ts4.5/plugins/layout/toolbar-messages.d.ts +0 -32
- package/dist/types-ts4.5/plugins/layout/toolbar.d.ts +0 -6
- package/dist/types-ts4.5/plugins/layout/types.d.ts +0 -13
- package/dist/types-ts4.5/plugins/placeholder-text/actions.d.ts +0 -4
- package/dist/types-ts4.5/plugins/placeholder-text/fake-text-cursor/cursor.d.ts +0 -30
- package/dist/types-ts4.5/plugins/placeholder-text/index.d.ts +0 -3
- package/dist/types-ts4.5/plugins/placeholder-text/placeholder-text-nodeview.d.ts +0 -17
- package/dist/types-ts4.5/plugins/placeholder-text/plugin-key.d.ts +0 -3
- package/dist/types-ts4.5/plugins/placeholder-text/plugin.d.ts +0 -7
- package/dist/types-ts4.5/plugins/placeholder-text/selection-utils.d.ts +0 -2
- package/dist/types-ts4.5/plugins/placeholder-text/styles.d.ts +0 -1
- package/dist/types-ts4.5/plugins/placeholder-text/types.d.ts +0 -18
- package/dist/types-ts4.5/plugins/placeholder-text/ui/FloatingToolbar/index.d.ts +0 -28
- package/dist/types-ts4.5/plugins/placeholder-text/ui/FloatingToolbar/styles.d.ts +0 -1
- package/dist/types-ts4.5/plugins/placeholder-text/ui/FloatingToolbar/utils.d.ts +0 -13
- 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 +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,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
|
-
}
|