@atlaskit/editor-core 183.1.1 → 184.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/dist/cjs/i18n/da.js +1 -1
- package/dist/cjs/i18n/en_ZZ.js +8 -34
- package/dist/cjs/i18n/it.js +1 -1
- package/dist/cjs/i18n/nb.js +3 -3
- package/dist/cjs/i18n/nl.js +4 -4
- package/dist/cjs/i18n/pl.js +1 -1
- package/dist/cjs/i18n/pt_BR.js +1 -1
- package/dist/cjs/i18n/ru.js +1 -1
- package/dist/cjs/i18n/th.js +2 -2
- package/dist/cjs/i18n/uk.js +1 -1
- package/dist/cjs/i18n/vi.js +2 -2
- package/dist/cjs/i18n/zh.js +1 -1
- package/dist/cjs/labs/next/full-page.js +2 -6
- package/dist/cjs/labs/next/presets/create-stub-internal-apis.js +4 -2
- package/dist/cjs/labs/next/presets/default.js +2 -2
- package/dist/cjs/labs/next/presets/universal.js +2 -1
- package/dist/cjs/plugins/breakout/index.js +54 -35
- package/dist/cjs/plugins/card/toolbar.js +4 -3
- package/dist/cjs/plugins/collab-edit/plugin-state.js +2 -3
- package/dist/cjs/plugins/copy-button/commands.js +8 -1
- package/dist/cjs/plugins/extension/index.js +1 -1
- package/dist/cjs/plugins/extension/nodeviews/extension.js +5 -3
- package/dist/cjs/plugins/extension/pm-plugins/main.js +6 -6
- package/dist/cjs/plugins/extension/ui/Extension/Extension/index.js +34 -4
- package/dist/cjs/plugins/extension/ui/Extension/ExtensionComponent.js +4 -2
- package/dist/cjs/plugins/extension/ui/Extension/index.js +4 -2
- package/dist/cjs/plugins/help-dialog/index.js +12 -8
- package/dist/cjs/plugins/index.js +0 -14
- package/dist/cjs/plugins/layout/pm-plugins/main.js +0 -1
- package/dist/cjs/plugins/media/index.js +15 -5
- package/dist/cjs/plugins/media/nodeviews/mediaNodeView/index.js +22 -14
- package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +53 -34
- package/dist/cjs/plugins/media/styles.js +1 -1
- package/dist/cjs/plugins/media/toolbar/index.js +4 -3
- package/dist/cjs/plugins/media/ui/ImageBorder/styles.js +4 -1
- package/dist/cjs/plugins/paste/pm-plugins/main.js +7 -1
- package/dist/cjs/test-utils.js +6 -1
- package/dist/cjs/ui/Appearance/Comment/Comment.js +2 -2
- package/dist/cjs/ui/Appearance/FullPage/FullPage.js +2 -2
- package/dist/cjs/ui/Appearance/FullPage/FullPageContentArea.js +1 -2
- package/dist/cjs/ui/Appearance/FullPage/FullPageToolbar.js +2 -2
- package/dist/cjs/ui/ContentStyles/index.js +9 -10
- package/dist/cjs/ui/ContextPanel/index.js +67 -56
- package/dist/cjs/ui/MediaAndEmbedsToolbar/index.js +10 -11
- package/dist/cjs/ui/Resizer/index.js +8 -8
- package/dist/cjs/ui/WidthEmitter/index.js +10 -4
- package/dist/cjs/utils/clipboard.js +18 -11
- package/dist/cjs/utils/performance/instrumented-plugin.js +14 -2
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/i18n/da.js +1 -1
- package/dist/es2019/i18n/en_ZZ.js +8 -34
- package/dist/es2019/i18n/it.js +1 -1
- package/dist/es2019/i18n/nb.js +3 -3
- package/dist/es2019/i18n/nl.js +4 -4
- package/dist/es2019/i18n/pl.js +1 -1
- package/dist/es2019/i18n/pt_BR.js +1 -1
- package/dist/es2019/i18n/ru.js +1 -1
- package/dist/es2019/i18n/th.js +2 -2
- package/dist/es2019/i18n/uk.js +1 -1
- package/dist/es2019/i18n/vi.js +2 -2
- package/dist/es2019/i18n/zh.js +1 -1
- package/dist/es2019/labs/next/full-page.js +2 -5
- package/dist/es2019/labs/next/presets/create-stub-internal-apis.js +4 -2
- package/dist/es2019/labs/next/presets/default.js +1 -1
- package/dist/es2019/labs/next/presets/universal.js +2 -1
- package/dist/es2019/plugins/breakout/index.js +48 -31
- package/dist/es2019/plugins/card/toolbar.js +4 -3
- package/dist/es2019/plugins/collab-edit/plugin-state.js +2 -4
- package/dist/es2019/plugins/copy-button/commands.js +9 -2
- package/dist/es2019/plugins/extension/index.js +1 -1
- package/dist/es2019/plugins/extension/nodeviews/extension.js +5 -3
- package/dist/es2019/plugins/extension/pm-plugins/main.js +4 -4
- package/dist/es2019/plugins/extension/ui/Extension/Extension/index.js +38 -2
- package/dist/es2019/plugins/extension/ui/Extension/ExtensionComponent.js +4 -2
- package/dist/es2019/plugins/extension/ui/Extension/index.js +4 -2
- package/dist/es2019/plugins/help-dialog/index.js +14 -9
- package/dist/es2019/plugins/index.js +0 -2
- package/dist/es2019/plugins/layout/pm-plugins/main.js +0 -1
- package/dist/es2019/plugins/media/index.js +15 -5
- package/dist/es2019/plugins/media/nodeviews/mediaNodeView/index.js +21 -10
- package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +53 -33
- package/dist/es2019/plugins/media/styles.js +1 -7
- package/dist/es2019/plugins/media/toolbar/index.js +4 -4
- package/dist/es2019/plugins/media/ui/ImageBorder/styles.js +9 -9
- package/dist/es2019/plugins/paste/pm-plugins/main.js +7 -1
- package/dist/es2019/test-utils.js +6 -1
- package/dist/es2019/ui/Appearance/Comment/Comment.js +1 -1
- package/dist/es2019/ui/Appearance/FullPage/FullPage.js +1 -1
- package/dist/es2019/ui/Appearance/FullPage/FullPageContentArea.js +1 -1
- package/dist/es2019/ui/Appearance/FullPage/FullPageToolbar.js +1 -1
- package/dist/es2019/ui/ContentStyles/index.js +1 -2
- package/dist/es2019/ui/ContextPanel/index.js +66 -43
- package/dist/es2019/ui/MediaAndEmbedsToolbar/index.js +8 -9
- package/dist/es2019/ui/Resizer/index.js +1 -1
- package/dist/es2019/ui/WidthEmitter/index.js +10 -4
- package/dist/es2019/utils/clipboard.js +12 -7
- package/dist/es2019/utils/performance/instrumented-plugin.js +15 -2
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/i18n/da.js +1 -1
- package/dist/esm/i18n/en_ZZ.js +8 -34
- package/dist/esm/i18n/it.js +1 -1
- package/dist/esm/i18n/nb.js +3 -3
- package/dist/esm/i18n/nl.js +4 -4
- package/dist/esm/i18n/pl.js +1 -1
- package/dist/esm/i18n/pt_BR.js +1 -1
- package/dist/esm/i18n/ru.js +1 -1
- package/dist/esm/i18n/th.js +2 -2
- package/dist/esm/i18n/uk.js +1 -1
- package/dist/esm/i18n/vi.js +2 -2
- package/dist/esm/i18n/zh.js +1 -1
- package/dist/esm/labs/next/full-page.js +2 -5
- package/dist/esm/labs/next/presets/create-stub-internal-apis.js +4 -2
- package/dist/esm/labs/next/presets/default.js +1 -1
- package/dist/esm/labs/next/presets/universal.js +2 -1
- package/dist/esm/plugins/breakout/index.js +54 -35
- package/dist/esm/plugins/card/toolbar.js +4 -3
- package/dist/esm/plugins/collab-edit/plugin-state.js +2 -3
- package/dist/esm/plugins/copy-button/commands.js +9 -2
- package/dist/esm/plugins/extension/index.js +1 -1
- package/dist/esm/plugins/extension/nodeviews/extension.js +5 -3
- package/dist/esm/plugins/extension/pm-plugins/main.js +6 -6
- package/dist/esm/plugins/extension/ui/Extension/Extension/index.js +33 -2
- package/dist/esm/plugins/extension/ui/Extension/ExtensionComponent.js +4 -2
- package/dist/esm/plugins/extension/ui/Extension/index.js +4 -2
- package/dist/esm/plugins/help-dialog/index.js +12 -8
- package/dist/esm/plugins/index.js +0 -2
- package/dist/esm/plugins/layout/pm-plugins/main.js +0 -1
- package/dist/esm/plugins/media/index.js +15 -5
- package/dist/esm/plugins/media/nodeviews/mediaNodeView/index.js +22 -14
- package/dist/esm/plugins/media/nodeviews/mediaSingle.js +54 -35
- package/dist/esm/plugins/media/styles.js +2 -2
- package/dist/esm/plugins/media/toolbar/index.js +4 -3
- package/dist/esm/plugins/media/ui/ImageBorder/styles.js +4 -1
- package/dist/esm/plugins/paste/pm-plugins/main.js +7 -1
- package/dist/esm/test-utils.js +6 -1
- package/dist/esm/ui/Appearance/Comment/Comment.js +1 -1
- package/dist/esm/ui/Appearance/FullPage/FullPage.js +1 -1
- package/dist/esm/ui/Appearance/FullPage/FullPageContentArea.js +1 -1
- package/dist/esm/ui/Appearance/FullPage/FullPageToolbar.js +1 -1
- package/dist/esm/ui/ContentStyles/index.js +1 -2
- package/dist/esm/ui/ContextPanel/index.js +64 -53
- package/dist/esm/ui/MediaAndEmbedsToolbar/index.js +10 -11
- package/dist/esm/ui/Resizer/index.js +1 -1
- package/dist/esm/ui/WidthEmitter/index.js +10 -4
- package/dist/esm/utils/clipboard.js +16 -10
- package/dist/esm/utils/performance/instrumented-plugin.js +14 -2
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/actions/index.d.ts +1 -1
- package/dist/types/create-editor/get-plugins.d.ts +2 -0
- package/dist/types/i18n/en_ZZ.d.ts +2 -28
- package/dist/types/index.d.ts +0 -1
- package/dist/types/plugins/breakout/index.d.ts +4 -0
- package/dist/types/plugins/breakout/ui/LayoutButton.d.ts +1 -1
- package/dist/types/plugins/card/index.d.ts +2 -2
- package/dist/types/plugins/collab-edit/actions.d.ts +3 -2
- package/dist/types/plugins/collab-edit/events/handlers.d.ts +3 -3
- package/dist/types/plugins/collab-edit/events/initialize.d.ts +1 -1
- package/dist/types/plugins/collab-edit/events/send-transaction.d.ts +1 -1
- package/dist/types/plugins/collab-edit/index.d.ts +0 -1
- package/dist/types/plugins/collab-edit/native-collab-provider-plugin.d.ts +2 -2
- package/dist/types/plugins/collab-edit/participants.d.ts +1 -1
- package/dist/types/plugins/collab-edit/plugin.d.ts +0 -2
- package/dist/types/plugins/collab-edit/types.d.ts +1 -3
- package/dist/types/plugins/collab-edit/ui/to-avatar.d.ts +1 -1
- package/dist/types/plugins/collab-edit/utils.d.ts +2 -1
- package/dist/types/plugins/extension/index.d.ts +2 -1
- package/dist/types/plugins/extension/nodeviews/extension.d.ts +4 -1
- package/dist/types/plugins/extension/pm-plugins/main.d.ts +3 -1
- package/dist/types/plugins/extension/ui/Extension/Extension/index.d.ts +6 -0
- package/dist/types/plugins/extension/ui/Extension/ExtensionComponent.d.ts +3 -0
- package/dist/types/plugins/extension/ui/Extension/index.d.ts +3 -0
- package/dist/types/plugins/help-dialog/index.d.ts +3 -1
- package/dist/types/plugins/index.d.ts +0 -3
- package/dist/types/plugins/media/index.d.ts +12 -2
- package/dist/types/plugins/media/nodeviews/mediaNodeView/index.d.ts +4 -2
- package/dist/types/plugins/media/nodeviews/mediaSingle.d.ts +1 -1
- package/dist/types/plugins/media/nodeviews/types.d.ts +2 -1
- package/dist/types/plugins/media/toolbar/index.d.ts +3 -1
- package/dist/types/plugins/media/ui/ResizableMediaSingle/types.d.ts +2 -2
- package/dist/types/test-utils.d.ts +3 -1
- package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types/ui/ColorPickerButton/index.d.ts +1 -1
- package/dist/types/ui/ContextPanel/index.d.ts +3 -4
- package/dist/types/ui/MediaAndEmbedsToolbar/index.d.ts +3 -1
- package/dist/types/ui/PluginSlot/index.d.ts +1 -1
- package/dist/types/ui/Resizer/types.d.ts +2 -2
- package/dist/types/utils/clipboard.d.ts +1 -0
- package/dist/types-ts4.5/actions/index.d.ts +1 -1
- package/dist/types-ts4.5/create-editor/get-plugins.d.ts +2 -0
- package/dist/types-ts4.5/i18n/en_ZZ.d.ts +2 -28
- package/dist/types-ts4.5/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/breakout/index.d.ts +6 -0
- package/dist/types-ts4.5/plugins/breakout/ui/LayoutButton.d.ts +1 -1
- package/dist/types-ts4.5/plugins/card/index.d.ts +2 -2
- package/dist/types-ts4.5/plugins/collab-edit/actions.d.ts +3 -2
- package/dist/types-ts4.5/plugins/collab-edit/events/handlers.d.ts +3 -3
- package/dist/types-ts4.5/plugins/collab-edit/events/initialize.d.ts +1 -1
- package/dist/types-ts4.5/plugins/collab-edit/events/send-transaction.d.ts +1 -1
- package/dist/types-ts4.5/plugins/collab-edit/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/collab-edit/native-collab-provider-plugin.d.ts +2 -2
- package/dist/types-ts4.5/plugins/collab-edit/participants.d.ts +1 -1
- package/dist/types-ts4.5/plugins/collab-edit/plugin.d.ts +0 -2
- package/dist/types-ts4.5/plugins/collab-edit/types.d.ts +1 -3
- package/dist/types-ts4.5/plugins/collab-edit/ui/to-avatar.d.ts +1 -1
- package/dist/types-ts4.5/plugins/collab-edit/utils.d.ts +2 -1
- package/dist/types-ts4.5/plugins/extension/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/extension/nodeviews/extension.d.ts +4 -1
- package/dist/types-ts4.5/plugins/extension/pm-plugins/main.d.ts +3 -1
- package/dist/types-ts4.5/plugins/extension/ui/Extension/Extension/index.d.ts +6 -0
- package/dist/types-ts4.5/plugins/extension/ui/Extension/ExtensionComponent.d.ts +3 -0
- package/dist/types-ts4.5/plugins/extension/ui/Extension/index.d.ts +3 -0
- package/dist/types-ts4.5/plugins/help-dialog/index.d.ts +5 -1
- package/dist/types-ts4.5/plugins/index.d.ts +0 -3
- package/dist/types-ts4.5/plugins/media/index.d.ts +9 -2
- package/dist/types-ts4.5/plugins/media/nodeviews/mediaNodeView/index.d.ts +4 -2
- package/dist/types-ts4.5/plugins/media/nodeviews/mediaSingle.d.ts +1 -1
- package/dist/types-ts4.5/plugins/media/nodeviews/types.d.ts +2 -1
- package/dist/types-ts4.5/plugins/media/toolbar/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/types.d.ts +2 -2
- package/dist/types-ts4.5/test-utils.d.ts +3 -1
- package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types-ts4.5/ui/ColorPickerButton/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/ContextPanel/index.d.ts +3 -4
- package/dist/types-ts4.5/ui/MediaAndEmbedsToolbar/index.d.ts +3 -1
- package/dist/types-ts4.5/ui/PluginSlot/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/Resizer/types.d.ts +2 -2
- package/dist/types-ts4.5/utils/clipboard.d.ts +1 -0
- package/package.json +20 -18
- package/report.api.md +15 -63
- package/dist/cjs/plugins/collab-edit/provider/index.js +0 -5
- package/dist/cjs/plugins/collab-edit/provider/types.js +0 -5
- package/dist/cjs/plugins/grid/index.js +0 -207
- package/dist/cjs/plugins/grid/styles.js +0 -16
- package/dist/cjs/plugins/grid/types.js +0 -5
- package/dist/cjs/plugins/width/index.js +0 -88
- package/dist/cjs/ui/ContextPanel/context.js +0 -89
- package/dist/es2019/plugins/collab-edit/provider/index.js +0 -1
- package/dist/es2019/plugins/collab-edit/provider/types.js +0 -1
- package/dist/es2019/plugins/grid/index.js +0 -168
- package/dist/es2019/plugins/grid/styles.js +0 -36
- package/dist/es2019/plugins/grid/types.js +0 -1
- package/dist/es2019/plugins/width/index.js +0 -72
- package/dist/es2019/ui/ContextPanel/context.js +0 -65
- package/dist/esm/plugins/collab-edit/provider/index.js +0 -1
- package/dist/esm/plugins/collab-edit/provider/types.js +0 -1
- package/dist/esm/plugins/grid/index.js +0 -191
- package/dist/esm/plugins/grid/styles.js +0 -7
- package/dist/esm/plugins/grid/types.js +0 -1
- package/dist/esm/plugins/width/index.js +0 -78
- package/dist/esm/ui/ContextPanel/context.js +0 -79
- package/dist/types/plugins/collab-edit/provider/index.d.ts +0 -1
- package/dist/types/plugins/collab-edit/provider/types.d.ts +0 -1
- package/dist/types/plugins/grid/index.d.ts +0 -25
- package/dist/types/plugins/grid/styles.d.ts +0 -2
- package/dist/types/plugins/grid/types.d.ts +0 -7
- package/dist/types/plugins/width/index.d.ts +0 -18
- package/dist/types/ui/ContextPanel/context.d.ts +0 -24
- package/dist/types-ts4.5/plugins/collab-edit/provider/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/collab-edit/provider/types.d.ts +0 -1
- package/dist/types-ts4.5/plugins/grid/index.d.ts +0 -27
- package/dist/types-ts4.5/plugins/grid/styles.d.ts +0 -2
- package/dist/types-ts4.5/plugins/grid/types.d.ts +0 -7
- package/dist/types-ts4.5/plugins/width/index.d.ts +0 -18
- package/dist/types-ts4.5/ui/ContextPanel/context.d.ts +0 -24
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import classnames from 'classnames';
|
|
3
|
-
import { withTheme } from '@emotion/react';
|
|
4
|
-
import { PluginKey } from 'prosemirror-state';
|
|
5
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
6
|
-
import { breakoutWideScaleRatio, akEditorFullPageMaxWidth, akEditorBreakoutPadding } from '@atlaskit/editor-shared-styles';
|
|
7
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
8
|
-
export const GRID_SIZE = 12;
|
|
9
|
-
const key = new PluginKey('gridPlugin');
|
|
10
|
-
const createDisplayGrid = view => props => {
|
|
11
|
-
const {
|
|
12
|
-
dispatch,
|
|
13
|
-
state
|
|
14
|
-
} = view;
|
|
15
|
-
const tr = state.tr.setMeta(key, props);
|
|
16
|
-
dispatch(tr);
|
|
17
|
-
return true;
|
|
18
|
-
};
|
|
19
|
-
export const gridTypeForLayout = layout => layout === 'wrap-left' || layout === 'wrap-right' ? 'wrapped' : 'full';
|
|
20
|
-
const sides = ['left', 'right'];
|
|
21
|
-
const overflowHighlight = (highlights, side, start, size) => {
|
|
22
|
-
if (!highlights.length) {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
const minHighlight = highlights.reduce((prev, cur) => Math.min(prev, cur));
|
|
26
|
-
const maxHighlight = highlights.reduce((prev, cur) => Math.max(prev, cur));
|
|
27
|
-
if (side === 'left') {
|
|
28
|
-
return minHighlight < 0 && minHighlight <= -start && (typeof size === 'number' ? minHighlight >= -(start + size) : true);
|
|
29
|
-
} else {
|
|
30
|
-
return maxHighlight > GRID_SIZE && maxHighlight >= GRID_SIZE + start && (typeof size === 'number' ? maxHighlight <= GRID_SIZE + size : true);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
const gutterGridLines = (editorMaxWidth, editorWidth, highlights, shouldCalcBreakoutGridLines) => {
|
|
34
|
-
const gridLines = [];
|
|
35
|
-
if (!shouldCalcBreakoutGridLines) {
|
|
36
|
-
return gridLines;
|
|
37
|
-
}
|
|
38
|
-
const wideSpacing = (editorMaxWidth * breakoutWideScaleRatio - editorMaxWidth) / 2;
|
|
39
|
-
sides.forEach(side => {
|
|
40
|
-
gridLines.push( /*#__PURE__*/React.createElement("div", {
|
|
41
|
-
key: side,
|
|
42
|
-
className: classnames('gridLine', overflowHighlight(highlights, side, 0, 4) ? 'highlight' : ''),
|
|
43
|
-
style: {
|
|
44
|
-
position: 'absolute',
|
|
45
|
-
[side]: `-${wideSpacing}px`
|
|
46
|
-
}
|
|
47
|
-
}));
|
|
48
|
-
gridLines.push( /*#__PURE__*/React.createElement("div", {
|
|
49
|
-
key: side + '-bk',
|
|
50
|
-
className: classnames('gridLine', highlights.indexOf('full-width') > -1 ? 'highlight' : ''),
|
|
51
|
-
style: {
|
|
52
|
-
position: 'absolute',
|
|
53
|
-
[side]: `-${(editorWidth - editorMaxWidth - akEditorBreakoutPadding) / 2}px`
|
|
54
|
-
}
|
|
55
|
-
}));
|
|
56
|
-
});
|
|
57
|
-
return gridLines;
|
|
58
|
-
};
|
|
59
|
-
const lineLengthGridLines = highlights => {
|
|
60
|
-
const gridLines = [];
|
|
61
|
-
const gridSpacing = 100 / GRID_SIZE;
|
|
62
|
-
for (let i = 0; i <= GRID_SIZE; i++) {
|
|
63
|
-
const style = {
|
|
64
|
-
paddingLeft: `${gridSpacing}%`
|
|
65
|
-
};
|
|
66
|
-
gridLines.push( /*#__PURE__*/React.createElement("div", {
|
|
67
|
-
key: i,
|
|
68
|
-
className: classnames('gridLine', highlights.indexOf(i) > -1 ? 'highlight' : ''),
|
|
69
|
-
style: i < GRID_SIZE ? style : undefined
|
|
70
|
-
}));
|
|
71
|
-
}
|
|
72
|
-
return gridLines;
|
|
73
|
-
};
|
|
74
|
-
class Grid extends React.Component {
|
|
75
|
-
render() {
|
|
76
|
-
const {
|
|
77
|
-
highlight,
|
|
78
|
-
shouldCalcBreakoutGridLines,
|
|
79
|
-
theme,
|
|
80
|
-
containerElement,
|
|
81
|
-
editorWidth,
|
|
82
|
-
gridType,
|
|
83
|
-
visible
|
|
84
|
-
} = this.props;
|
|
85
|
-
const editorMaxWidth = theme.layoutMaxWidth;
|
|
86
|
-
let gridLines = [...lineLengthGridLines(highlight), ...gutterGridLines(editorMaxWidth, editorWidth, highlight, shouldCalcBreakoutGridLines)];
|
|
87
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
88
|
-
className: "gridParent"
|
|
89
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
90
|
-
className: classnames('gridContainer', gridType),
|
|
91
|
-
style: {
|
|
92
|
-
height: `${containerElement.scrollHeight}px`,
|
|
93
|
-
display: visible ? 'block' : 'none'
|
|
94
|
-
}
|
|
95
|
-
}, gridLines));
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
const ThemedGrid = withTheme(Grid);
|
|
99
|
-
const ContentComponent = ({
|
|
100
|
-
api,
|
|
101
|
-
editorView,
|
|
102
|
-
options
|
|
103
|
-
}) => {
|
|
104
|
-
var _widthState$width, _gridState$gridType;
|
|
105
|
-
const {
|
|
106
|
-
widthState,
|
|
107
|
-
gridState
|
|
108
|
-
} = useSharedPluginState(api, ['width', 'grid']);
|
|
109
|
-
if (!gridState) {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
return /*#__PURE__*/React.createElement(ThemedGrid, {
|
|
113
|
-
shouldCalcBreakoutGridLines: options && options.shouldCalcBreakoutGridLines,
|
|
114
|
-
editorWidth: (_widthState$width = widthState === null || widthState === void 0 ? void 0 : widthState.width) !== null && _widthState$width !== void 0 ? _widthState$width : akEditorFullPageMaxWidth,
|
|
115
|
-
containerElement: editorView.dom,
|
|
116
|
-
visible: gridState.visible,
|
|
117
|
-
gridType: (_gridState$gridType = gridState.gridType) !== null && _gridState$gridType !== void 0 ? _gridState$gridType : 'full',
|
|
118
|
-
highlight: gridState.highlight
|
|
119
|
-
});
|
|
120
|
-
};
|
|
121
|
-
const EMPTY_STATE = {
|
|
122
|
-
visible: false,
|
|
123
|
-
highlight: []
|
|
124
|
-
};
|
|
125
|
-
const gridPMPlugin = new SafePlugin({
|
|
126
|
-
key,
|
|
127
|
-
state: {
|
|
128
|
-
init() {
|
|
129
|
-
return EMPTY_STATE;
|
|
130
|
-
},
|
|
131
|
-
apply(tr, currentPluginState) {
|
|
132
|
-
const nextPluginState = tr.getMeta(key);
|
|
133
|
-
if (nextPluginState) {
|
|
134
|
-
return nextPluginState;
|
|
135
|
-
}
|
|
136
|
-
return currentPluginState;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
const gridPlugin = (options, api) => {
|
|
141
|
-
return {
|
|
142
|
-
name: 'grid',
|
|
143
|
-
getSharedState(editorState) {
|
|
144
|
-
if (!editorState) {
|
|
145
|
-
return null;
|
|
146
|
-
}
|
|
147
|
-
return key.getState(editorState);
|
|
148
|
-
},
|
|
149
|
-
actions: {
|
|
150
|
-
displayGrid: createDisplayGrid
|
|
151
|
-
},
|
|
152
|
-
pmPlugins() {
|
|
153
|
-
return [{
|
|
154
|
-
name: 'grid',
|
|
155
|
-
plugin: () => gridPMPlugin
|
|
156
|
-
}];
|
|
157
|
-
},
|
|
158
|
-
contentComponent: ({
|
|
159
|
-
editorView
|
|
160
|
-
}) => /*#__PURE__*/React.createElement(ContentComponent, {
|
|
161
|
-
editorView: editorView,
|
|
162
|
-
options: options,
|
|
163
|
-
api: api
|
|
164
|
-
})
|
|
165
|
-
};
|
|
166
|
-
};
|
|
167
|
-
export default gridPlugin;
|
|
168
|
-
export { GRID_GUTTER } from './styles';
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { css } from '@emotion/react';
|
|
2
|
-
import { N30A, B200 } from '@atlaskit/theme/colors';
|
|
3
|
-
import { akEditorGridLineZIndex } from '@atlaskit/editor-shared-styles';
|
|
4
|
-
export const GRID_GUTTER = 12;
|
|
5
|
-
export const gridStyles = css`
|
|
6
|
-
.gridParent {
|
|
7
|
-
width: calc(100% + ${GRID_GUTTER * 2}px);
|
|
8
|
-
margin-left: -${GRID_GUTTER}px;
|
|
9
|
-
margin-right: -${GRID_GUTTER}px;
|
|
10
|
-
transform: scale(1);
|
|
11
|
-
z-index: ${akEditorGridLineZIndex};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.gridContainer {
|
|
15
|
-
position: fixed;
|
|
16
|
-
height: 100vh;
|
|
17
|
-
width: 100%;
|
|
18
|
-
pointer-events: none;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// TODO: https://product-fabric.atlassian.net/browse/DSP-4352
|
|
22
|
-
.gridLine {
|
|
23
|
-
border-left: 1px solid ${`var(--ds-border, ${N30A})`};
|
|
24
|
-
display: inline-block;
|
|
25
|
-
box-sizing: border-box;
|
|
26
|
-
height: 100%;
|
|
27
|
-
margin-left: -1px;
|
|
28
|
-
|
|
29
|
-
transition: border-color 0.15s linear;
|
|
30
|
-
z-index: 0;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.highlight {
|
|
34
|
-
border-left: 1px solid ${`var(--ds-border-focused, ${B200})`};
|
|
35
|
-
}
|
|
36
|
-
`;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { PluginKey } from 'prosemirror-state';
|
|
3
|
-
/**
|
|
4
|
-
* @private
|
|
5
|
-
* @deprecated
|
|
6
|
-
*
|
|
7
|
-
* Do not use this plugin key directly. Please use the `sharedState` of this plugin instead.
|
|
8
|
-
*/
|
|
9
|
-
export const pluginKey = new PluginKey('widthPlugin');
|
|
10
|
-
export function createPlugin(dispatch) {
|
|
11
|
-
return new SafePlugin({
|
|
12
|
-
key: pluginKey,
|
|
13
|
-
state: {
|
|
14
|
-
init: () => ({
|
|
15
|
-
width: document.body.offsetWidth,
|
|
16
|
-
containerWidth: document.body.offsetWidth
|
|
17
|
-
}),
|
|
18
|
-
apply(tr, pluginState) {
|
|
19
|
-
const meta = tr.getMeta(pluginKey);
|
|
20
|
-
if (!meta) {
|
|
21
|
-
return pluginState;
|
|
22
|
-
}
|
|
23
|
-
const newPluginState = {
|
|
24
|
-
...pluginState,
|
|
25
|
-
...meta
|
|
26
|
-
};
|
|
27
|
-
if (newPluginState && (pluginState.width !== newPluginState.width || pluginState.lineLength !== newPluginState.lineLength) || pluginState.containerWidth !== newPluginState.containerWidth) {
|
|
28
|
-
dispatch(pluginKey, newPluginState);
|
|
29
|
-
return newPluginState;
|
|
30
|
-
}
|
|
31
|
-
return pluginState;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
const widthPlugin = () => ({
|
|
37
|
-
name: 'width',
|
|
38
|
-
pmPlugins: () => [{
|
|
39
|
-
name: 'width',
|
|
40
|
-
plugin: ({
|
|
41
|
-
dispatch
|
|
42
|
-
}) => createPlugin(dispatch)
|
|
43
|
-
}],
|
|
44
|
-
getSharedState: editorState => {
|
|
45
|
-
if (!editorState) {
|
|
46
|
-
return undefined;
|
|
47
|
-
}
|
|
48
|
-
return pluginKey.getState(editorState);
|
|
49
|
-
},
|
|
50
|
-
// do this early here, otherwise we have to wait for WidthEmitter to debounce
|
|
51
|
-
// which causes anything dependent on lineLength to jump around
|
|
52
|
-
contentComponent({
|
|
53
|
-
editorView,
|
|
54
|
-
containerElement
|
|
55
|
-
}) {
|
|
56
|
-
const newState = {
|
|
57
|
-
lineLength: editorView.dom.clientWidth
|
|
58
|
-
};
|
|
59
|
-
if (containerElement) {
|
|
60
|
-
var _containerElement$par;
|
|
61
|
-
newState.width = containerElement.offsetWidth;
|
|
62
|
-
|
|
63
|
-
// wrapper width is used by context panel to determine whether there is
|
|
64
|
-
// enough space to open without overlapping the editor
|
|
65
|
-
newState.containerWidth = (_containerElement$par = containerElement.parentElement) === null || _containerElement$par === void 0 ? void 0 : _containerElement$par.offsetWidth;
|
|
66
|
-
}
|
|
67
|
-
const tr = editorView.state.tr.setMeta(pluginKey, newState);
|
|
68
|
-
editorView.dispatch(tr);
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
export default widthPlugin;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
// React context to communicate the active context panel width up and down the tree.
|
|
5
|
-
//
|
|
6
|
-
// We need the width prop from the ContextPanel component.
|
|
7
|
-
//
|
|
8
|
-
// However, the actual <ContextPanel /> component might be deeply nested inside the contextPanel.
|
|
9
|
-
// For example, in the template context panel storybook, we wrap it in 2 higher order components.
|
|
10
|
-
//
|
|
11
|
-
// Changing the max-width on the main editor container happens above where the <ContextPanel /> gets rendered.
|
|
12
|
-
//
|
|
13
|
-
// To subtract the context panel width from the available real estate, we use the Provider and Consumer.
|
|
14
|
-
//
|
|
15
|
-
// positionedOverEditor is used to determine whether the context panel is positioned over the Editor so we are
|
|
16
|
-
// able to position and add margins to handle certain elements like inline comment dialogues overlapping the context
|
|
17
|
-
// panel
|
|
18
|
-
export const ContextPanel = /*#__PURE__*/React.createContext({
|
|
19
|
-
width: 0,
|
|
20
|
-
positionedOverEditor: false,
|
|
21
|
-
broadcastWidth: () => {},
|
|
22
|
-
broadcastPosition: () => {}
|
|
23
|
-
});
|
|
24
|
-
export class ContextPanelWidthProvider extends React.Component {
|
|
25
|
-
constructor(props) {
|
|
26
|
-
super(props);
|
|
27
|
-
_defineProperty(this, "state", {
|
|
28
|
-
width: 0,
|
|
29
|
-
positionedOverEditor: false
|
|
30
|
-
});
|
|
31
|
-
_defineProperty(this, "broadcastSidebarWidth", width => {
|
|
32
|
-
if (width !== this.state.width) {
|
|
33
|
-
this.setState({
|
|
34
|
-
width
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
_defineProperty(this, "broadcastPosition", positionedOverEditor => {
|
|
39
|
-
if (positionedOverEditor !== this.state.positionedOverEditor) {
|
|
40
|
-
this.setState({
|
|
41
|
-
positionedOverEditor
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
render() {
|
|
47
|
-
const {
|
|
48
|
-
width,
|
|
49
|
-
positionedOverEditor
|
|
50
|
-
} = this.state;
|
|
51
|
-
return /*#__PURE__*/React.createElement(Provider, {
|
|
52
|
-
value: {
|
|
53
|
-
width,
|
|
54
|
-
positionedOverEditor,
|
|
55
|
-
broadcastWidth: this.broadcastSidebarWidth,
|
|
56
|
-
broadcastPosition: this.broadcastPosition
|
|
57
|
-
}
|
|
58
|
-
}, this.props.children);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
const {
|
|
62
|
-
Provider,
|
|
63
|
-
Consumer
|
|
64
|
-
} = ContextPanel;
|
|
65
|
-
export { Provider as ContextPanelProvider, Consumer as ContextPanelConsumer };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
9
|
-
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; } }
|
|
10
|
-
import React from 'react';
|
|
11
|
-
import classnames from 'classnames';
|
|
12
|
-
import { withTheme } from '@emotion/react';
|
|
13
|
-
import { PluginKey } from 'prosemirror-state';
|
|
14
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
15
|
-
import { breakoutWideScaleRatio, akEditorFullPageMaxWidth, akEditorBreakoutPadding } from '@atlaskit/editor-shared-styles';
|
|
16
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
17
|
-
export var GRID_SIZE = 12;
|
|
18
|
-
var key = new PluginKey('gridPlugin');
|
|
19
|
-
var createDisplayGrid = function createDisplayGrid(view) {
|
|
20
|
-
return function (props) {
|
|
21
|
-
var dispatch = view.dispatch,
|
|
22
|
-
state = view.state;
|
|
23
|
-
var tr = state.tr.setMeta(key, props);
|
|
24
|
-
dispatch(tr);
|
|
25
|
-
return true;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
export var gridTypeForLayout = function gridTypeForLayout(layout) {
|
|
29
|
-
return layout === 'wrap-left' || layout === 'wrap-right' ? 'wrapped' : 'full';
|
|
30
|
-
};
|
|
31
|
-
var sides = ['left', 'right'];
|
|
32
|
-
var overflowHighlight = function overflowHighlight(highlights, side, start, size) {
|
|
33
|
-
if (!highlights.length) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
var minHighlight = highlights.reduce(function (prev, cur) {
|
|
37
|
-
return Math.min(prev, cur);
|
|
38
|
-
});
|
|
39
|
-
var maxHighlight = highlights.reduce(function (prev, cur) {
|
|
40
|
-
return Math.max(prev, cur);
|
|
41
|
-
});
|
|
42
|
-
if (side === 'left') {
|
|
43
|
-
return minHighlight < 0 && minHighlight <= -start && (typeof size === 'number' ? minHighlight >= -(start + size) : true);
|
|
44
|
-
} else {
|
|
45
|
-
return maxHighlight > GRID_SIZE && maxHighlight >= GRID_SIZE + start && (typeof size === 'number' ? maxHighlight <= GRID_SIZE + size : true);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
var gutterGridLines = function gutterGridLines(editorMaxWidth, editorWidth, highlights, shouldCalcBreakoutGridLines) {
|
|
49
|
-
var gridLines = [];
|
|
50
|
-
if (!shouldCalcBreakoutGridLines) {
|
|
51
|
-
return gridLines;
|
|
52
|
-
}
|
|
53
|
-
var wideSpacing = (editorMaxWidth * breakoutWideScaleRatio - editorMaxWidth) / 2;
|
|
54
|
-
sides.forEach(function (side) {
|
|
55
|
-
gridLines.push( /*#__PURE__*/React.createElement("div", {
|
|
56
|
-
key: side,
|
|
57
|
-
className: classnames('gridLine', overflowHighlight(highlights, side, 0, 4) ? 'highlight' : ''),
|
|
58
|
-
style: _defineProperty({
|
|
59
|
-
position: 'absolute'
|
|
60
|
-
}, side, "-".concat(wideSpacing, "px"))
|
|
61
|
-
}));
|
|
62
|
-
gridLines.push( /*#__PURE__*/React.createElement("div", {
|
|
63
|
-
key: side + '-bk',
|
|
64
|
-
className: classnames('gridLine', highlights.indexOf('full-width') > -1 ? 'highlight' : ''),
|
|
65
|
-
style: _defineProperty({
|
|
66
|
-
position: 'absolute'
|
|
67
|
-
}, side, "-".concat((editorWidth - editorMaxWidth - akEditorBreakoutPadding) / 2, "px"))
|
|
68
|
-
}));
|
|
69
|
-
});
|
|
70
|
-
return gridLines;
|
|
71
|
-
};
|
|
72
|
-
var lineLengthGridLines = function lineLengthGridLines(highlights) {
|
|
73
|
-
var gridLines = [];
|
|
74
|
-
var gridSpacing = 100 / GRID_SIZE;
|
|
75
|
-
for (var i = 0; i <= GRID_SIZE; i++) {
|
|
76
|
-
var style = {
|
|
77
|
-
paddingLeft: "".concat(gridSpacing, "%")
|
|
78
|
-
};
|
|
79
|
-
gridLines.push( /*#__PURE__*/React.createElement("div", {
|
|
80
|
-
key: i,
|
|
81
|
-
className: classnames('gridLine', highlights.indexOf(i) > -1 ? 'highlight' : ''),
|
|
82
|
-
style: i < GRID_SIZE ? style : undefined
|
|
83
|
-
}));
|
|
84
|
-
}
|
|
85
|
-
return gridLines;
|
|
86
|
-
};
|
|
87
|
-
var Grid = /*#__PURE__*/function (_React$Component) {
|
|
88
|
-
_inherits(Grid, _React$Component);
|
|
89
|
-
var _super = _createSuper(Grid);
|
|
90
|
-
function Grid() {
|
|
91
|
-
_classCallCheck(this, Grid);
|
|
92
|
-
return _super.apply(this, arguments);
|
|
93
|
-
}
|
|
94
|
-
_createClass(Grid, [{
|
|
95
|
-
key: "render",
|
|
96
|
-
value: function render() {
|
|
97
|
-
var _this$props = this.props,
|
|
98
|
-
highlight = _this$props.highlight,
|
|
99
|
-
shouldCalcBreakoutGridLines = _this$props.shouldCalcBreakoutGridLines,
|
|
100
|
-
theme = _this$props.theme,
|
|
101
|
-
containerElement = _this$props.containerElement,
|
|
102
|
-
editorWidth = _this$props.editorWidth,
|
|
103
|
-
gridType = _this$props.gridType,
|
|
104
|
-
visible = _this$props.visible;
|
|
105
|
-
var editorMaxWidth = theme.layoutMaxWidth;
|
|
106
|
-
var gridLines = [].concat(_toConsumableArray(lineLengthGridLines(highlight)), _toConsumableArray(gutterGridLines(editorMaxWidth, editorWidth, highlight, shouldCalcBreakoutGridLines)));
|
|
107
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
108
|
-
className: "gridParent"
|
|
109
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
110
|
-
className: classnames('gridContainer', gridType),
|
|
111
|
-
style: {
|
|
112
|
-
height: "".concat(containerElement.scrollHeight, "px"),
|
|
113
|
-
display: visible ? 'block' : 'none'
|
|
114
|
-
}
|
|
115
|
-
}, gridLines));
|
|
116
|
-
}
|
|
117
|
-
}]);
|
|
118
|
-
return Grid;
|
|
119
|
-
}(React.Component);
|
|
120
|
-
var ThemedGrid = withTheme(Grid);
|
|
121
|
-
var ContentComponent = function ContentComponent(_ref3) {
|
|
122
|
-
var _widthState$width, _gridState$gridType;
|
|
123
|
-
var api = _ref3.api,
|
|
124
|
-
editorView = _ref3.editorView,
|
|
125
|
-
options = _ref3.options;
|
|
126
|
-
var _useSharedPluginState = useSharedPluginState(api, ['width', 'grid']),
|
|
127
|
-
widthState = _useSharedPluginState.widthState,
|
|
128
|
-
gridState = _useSharedPluginState.gridState;
|
|
129
|
-
if (!gridState) {
|
|
130
|
-
return null;
|
|
131
|
-
}
|
|
132
|
-
return /*#__PURE__*/React.createElement(ThemedGrid, {
|
|
133
|
-
shouldCalcBreakoutGridLines: options && options.shouldCalcBreakoutGridLines,
|
|
134
|
-
editorWidth: (_widthState$width = widthState === null || widthState === void 0 ? void 0 : widthState.width) !== null && _widthState$width !== void 0 ? _widthState$width : akEditorFullPageMaxWidth,
|
|
135
|
-
containerElement: editorView.dom,
|
|
136
|
-
visible: gridState.visible,
|
|
137
|
-
gridType: (_gridState$gridType = gridState.gridType) !== null && _gridState$gridType !== void 0 ? _gridState$gridType : 'full',
|
|
138
|
-
highlight: gridState.highlight
|
|
139
|
-
});
|
|
140
|
-
};
|
|
141
|
-
var EMPTY_STATE = {
|
|
142
|
-
visible: false,
|
|
143
|
-
highlight: []
|
|
144
|
-
};
|
|
145
|
-
var gridPMPlugin = new SafePlugin({
|
|
146
|
-
key: key,
|
|
147
|
-
state: {
|
|
148
|
-
init: function init() {
|
|
149
|
-
return EMPTY_STATE;
|
|
150
|
-
},
|
|
151
|
-
apply: function apply(tr, currentPluginState) {
|
|
152
|
-
var nextPluginState = tr.getMeta(key);
|
|
153
|
-
if (nextPluginState) {
|
|
154
|
-
return nextPluginState;
|
|
155
|
-
}
|
|
156
|
-
return currentPluginState;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
var gridPlugin = function gridPlugin(options, api) {
|
|
161
|
-
return {
|
|
162
|
-
name: 'grid',
|
|
163
|
-
getSharedState: function getSharedState(editorState) {
|
|
164
|
-
if (!editorState) {
|
|
165
|
-
return null;
|
|
166
|
-
}
|
|
167
|
-
return key.getState(editorState);
|
|
168
|
-
},
|
|
169
|
-
actions: {
|
|
170
|
-
displayGrid: createDisplayGrid
|
|
171
|
-
},
|
|
172
|
-
pmPlugins: function pmPlugins() {
|
|
173
|
-
return [{
|
|
174
|
-
name: 'grid',
|
|
175
|
-
plugin: function plugin() {
|
|
176
|
-
return gridPMPlugin;
|
|
177
|
-
}
|
|
178
|
-
}];
|
|
179
|
-
},
|
|
180
|
-
contentComponent: function contentComponent(_ref4) {
|
|
181
|
-
var editorView = _ref4.editorView;
|
|
182
|
-
return /*#__PURE__*/React.createElement(ContentComponent, {
|
|
183
|
-
editorView: editorView,
|
|
184
|
-
options: options,
|
|
185
|
-
api: api
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
};
|
|
190
|
-
export default gridPlugin;
|
|
191
|
-
export { GRID_GUTTER } from './styles';
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
-
var _templateObject;
|
|
3
|
-
import { css } from '@emotion/react';
|
|
4
|
-
import { N30A, B200 } from '@atlaskit/theme/colors';
|
|
5
|
-
import { akEditorGridLineZIndex } from '@atlaskit/editor-shared-styles';
|
|
6
|
-
export var GRID_GUTTER = 12;
|
|
7
|
-
export var gridStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .gridParent {\n width: calc(100% + ", "px);\n margin-left: -", "px;\n margin-right: -", "px;\n transform: scale(1);\n z-index: ", ";\n }\n\n .gridContainer {\n position: fixed;\n height: 100vh;\n width: 100%;\n pointer-events: none;\n }\n\n // TODO: https://product-fabric.atlassian.net/browse/DSP-4352\n .gridLine {\n border-left: 1px solid ", ";\n display: inline-block;\n box-sizing: border-box;\n height: 100%;\n margin-left: -1px;\n\n transition: border-color 0.15s linear;\n z-index: 0;\n }\n\n .highlight {\n border-left: 1px solid ", ";\n }\n"])), GRID_GUTTER * 2, GRID_GUTTER, GRID_GUTTER, akEditorGridLineZIndex, "var(--ds-border, ".concat(N30A, ")"), "var(--ds-border-focused, ".concat(B200, ")"));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
|
-
import { PluginKey } from 'prosemirror-state';
|
|
6
|
-
/**
|
|
7
|
-
* @private
|
|
8
|
-
* @deprecated
|
|
9
|
-
*
|
|
10
|
-
* Do not use this plugin key directly. Please use the `sharedState` of this plugin instead.
|
|
11
|
-
*/
|
|
12
|
-
export var pluginKey = new PluginKey('widthPlugin');
|
|
13
|
-
export function createPlugin(dispatch) {
|
|
14
|
-
return new SafePlugin({
|
|
15
|
-
key: pluginKey,
|
|
16
|
-
state: {
|
|
17
|
-
init: function init() {
|
|
18
|
-
return {
|
|
19
|
-
width: document.body.offsetWidth,
|
|
20
|
-
containerWidth: document.body.offsetWidth
|
|
21
|
-
};
|
|
22
|
-
},
|
|
23
|
-
apply: function apply(tr, pluginState) {
|
|
24
|
-
var meta = tr.getMeta(pluginKey);
|
|
25
|
-
if (!meta) {
|
|
26
|
-
return pluginState;
|
|
27
|
-
}
|
|
28
|
-
var newPluginState = _objectSpread(_objectSpread({}, pluginState), meta);
|
|
29
|
-
if (newPluginState && (pluginState.width !== newPluginState.width || pluginState.lineLength !== newPluginState.lineLength) || pluginState.containerWidth !== newPluginState.containerWidth) {
|
|
30
|
-
dispatch(pluginKey, newPluginState);
|
|
31
|
-
return newPluginState;
|
|
32
|
-
}
|
|
33
|
-
return pluginState;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
var widthPlugin = function widthPlugin() {
|
|
39
|
-
return {
|
|
40
|
-
name: 'width',
|
|
41
|
-
pmPlugins: function pmPlugins() {
|
|
42
|
-
return [{
|
|
43
|
-
name: 'width',
|
|
44
|
-
plugin: function plugin(_ref) {
|
|
45
|
-
var dispatch = _ref.dispatch;
|
|
46
|
-
return createPlugin(dispatch);
|
|
47
|
-
}
|
|
48
|
-
}];
|
|
49
|
-
},
|
|
50
|
-
getSharedState: function getSharedState(editorState) {
|
|
51
|
-
if (!editorState) {
|
|
52
|
-
return undefined;
|
|
53
|
-
}
|
|
54
|
-
return pluginKey.getState(editorState);
|
|
55
|
-
},
|
|
56
|
-
// do this early here, otherwise we have to wait for WidthEmitter to debounce
|
|
57
|
-
// which causes anything dependent on lineLength to jump around
|
|
58
|
-
contentComponent: function contentComponent(_ref2) {
|
|
59
|
-
var editorView = _ref2.editorView,
|
|
60
|
-
containerElement = _ref2.containerElement;
|
|
61
|
-
var newState = {
|
|
62
|
-
lineLength: editorView.dom.clientWidth
|
|
63
|
-
};
|
|
64
|
-
if (containerElement) {
|
|
65
|
-
var _containerElement$par;
|
|
66
|
-
newState.width = containerElement.offsetWidth;
|
|
67
|
-
|
|
68
|
-
// wrapper width is used by context panel to determine whether there is
|
|
69
|
-
// enough space to open without overlapping the editor
|
|
70
|
-
newState.containerWidth = (_containerElement$par = containerElement.parentElement) === null || _containerElement$par === void 0 ? void 0 : _containerElement$par.offsetWidth;
|
|
71
|
-
}
|
|
72
|
-
var tr = editorView.state.tr.setMeta(pluginKey, newState);
|
|
73
|
-
editorView.dispatch(tr);
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
export default widthPlugin;
|