Skip to content

Commit

Permalink
Merge pull request #3306 from grebaldi/task/3118/remove-plow-js
Browse files Browse the repository at this point in the history
!!!TASK: Remove plow-js
  • Loading branch information
mhsdesign authored Nov 9, 2023
2 parents 1545777 + f34f62c commit 66889e3
Show file tree
Hide file tree
Showing 148 changed files with 1,224 additions and 1,115 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions Tests/IntegrationTests/TestDistribution/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
"cweagans/composer-patches": true
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"neos/flow-development-collection": "9.0.x-dev as 9.0",

"neos/neos-development-collection": "9.0.x-dev as 9.0",
"neos/eventstore": "dev-main",
"neos/eventstore-doctrineadapter": "dev-main",

"neos/neos-ui": "9.0.x-dev as 9.0",
"neos/neos-ui-compiled": "9.0.x-dev as 9.0",
Expand Down
3 changes: 1 addition & 2 deletions packages/neos-ui-backend-connector/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
},
"dependencies": {
"@neos-project/neos-ts-interfaces": "workspace:*",
"@neos-project/utils-helpers": "workspace:*",
"plow-js": "3.0.0"
"@neos-project/utils-helpers": "workspace:*"
},
"license": "GNU GPLv3",
"stableVersion": "8.3.4"
Expand Down
8 changes: 4 additions & 4 deletions packages/neos-ui-backend-connector/src/FlowQuery/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as operations from './Operations/index';
import {$get} from 'plow-js';

import fetchWithErrorHandling from '../FetchWithErrorHandling/index';
import {Node, NodeContextPath, ContextProperties} from '@neos-project/neos-ts-interfaces';
import {Routes} from '../Endpoints';
Expand Down Expand Up @@ -33,7 +33,7 @@ export const createNodeEnvelope = (node: NodeEnvelope | NodeContextPath) => {
let contextPath = '';

if (typeof node === 'object') {
contextPath = $get(['contextPath'], node) || $get(['$node'], node);
contextPath = node?.contextPath || node?.$node;
} else if (typeof node === 'string') {
contextPath = node;
}
Expand Down Expand Up @@ -103,8 +103,8 @@ export default (routes: Routes) => {
//
const q = (context: ContextProperties | string, ignoreMiddleware: boolean = false) => {
let finalContext: NodeContextPath[];
if (typeof context === 'object' && typeof $get(['contextPath'], context) === 'string') {
finalContext = [$get(['contextPath'], context) as string];
if (typeof context === 'object' && typeof context?.contextPath === 'string') {
finalContext = [context?.contextPath as string];
} else if (typeof context === 'string') {
finalContext = [context];
} else if (Array.isArray(context)) {
Expand Down
3 changes: 1 addition & 2 deletions packages/neos-ui-ckeditor5-bindings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
"@neos-project/utils-helpers": "workspace:*",
"classnames": "^2.2.3",
"lodash.debounce": "^4.0.8",
"lodash.omit": "^4.5.0",
"plow-js": "3.0.0"
"lodash.omit": "^4.5.0"
},
"peerDependencies": {
"prop-types": "^15.5.10",
Expand Down
20 changes: 10 additions & 10 deletions packages/neos-ui-ckeditor5-bindings/src/EditorToolbar/LinkButton.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';
import {connect} from 'react-redux';
import {$get, $transform} from 'plow-js';

import LinkInput from '@neos-project/neos-ui-editors/src/Library/LinkInput';

import {IconButton} from '@neos-project/react-ui-components';
Expand All @@ -10,8 +10,8 @@ import {selectors, actions} from '@neos-project/neos-ui-redux-store';

import style from './LinkButton.module.css';

@connect($transform({
isOpen: selectors.UI.ContentCanvas.isLinkEditorOpen
@connect(state => ({
isOpen: selectors.UI.ContentCanvas.isLinkEditorOpen(state)
}), {
toggle: actions.UI.ContentCanvas.toggleLinkEditor
})
Expand All @@ -35,7 +35,7 @@ export default class LinkButton extends PureComponent {

handleLinkButtonClick = () => {
if (this.props.isOpen) {
if ($get('link', this.props.formattingUnderCursor) !== undefined) {
if (this.props.formattingUnderCursor?.link !== undefined) {
// We need to remove all attributes before unsetting the link
this.props.executeCommand('linkTitle', false, false);
this.props.executeCommand('linkRelNofollow', false, false);
Expand Down Expand Up @@ -87,7 +87,7 @@ export default class LinkButton extends PureComponent {
{isOpen ? (
<div className={style.linkButton__flyout}>
<LinkInput
linkingOptions={$get('linking', inlineEditorOptions)}
linkingOptions={inlineEditorOptions?.linking}
linkValue={this.getLinkValue()}
linkTitleValue={this.getLinkTitleValue()}
linkRelNofollowValue={this.getLinkRelValue()}
Expand All @@ -107,22 +107,22 @@ export default class LinkButton extends PureComponent {
}

getLinkValue() {
return $get('link', this.props.formattingUnderCursor) || '';
return this.props.formattingUnderCursor?.link || '';
}

getLinkTitleValue() {
return $get('linkTitle', this.props.formattingUnderCursor) || '';
return this.props.formattingUnderCursor?.linkTitle || '';
}

getLinkRelValue() {
return $get('linkRelNofollow', this.props.formattingUnderCursor) || false;
return this.props.formattingUnderCursor?.linkRelNofollow || false;
}

getLinkTargetValue() {
return $get('linkTargetBlank', this.props.formattingUnderCursor) || false;
return this.props.formattingUnderCursor?.linkTargetBlank || false;
}

getLinkDownloadValue() {
return $get('linkDownload', this.props.formattingUnderCursor) || false;
return this.props.formattingUnderCursor?.linkDownload || false;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {DropDown, CheckBox, Button} from '@neos-project/react-ui-components';
import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';
import {$get} from 'plow-js';

import {neos} from '@neos-project/neos-ui-decorators';
import ckeIcons from './icons';
Expand Down Expand Up @@ -54,7 +53,7 @@ export default class TableDropDownButton extends PureComponent {
className={style.checkBox}
onClick={() => this.handleClick(item.commandName)}
>
<CheckBox isChecked={$get(item.commandName, this.props.formattingUnderCursor)} />
<CheckBox isChecked={this.props.formattingUnderCursor?.[item.commandName]} />
{this.props.i18nRegistry.translate(item.label)}
</label>
) : <Button
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';
import {connect} from 'react-redux';
import {$transform} from 'plow-js';

import {neos} from '@neos-project/neos-ui-decorators';
import {selectors} from '@neos-project/neos-ui-redux-store';
Expand All @@ -11,10 +10,10 @@ import EditorToolbar from './EditorToolbar';

export {EditorToolbar};

@connect($transform({
focusedNodeType: selectors.CR.Nodes.focusedNodeTypeSelector,
currentlyEditedPropertyName: selectors.UI.ContentCanvas.currentlyEditedPropertyName,
formattingUnderCursor: selectors.UI.ContentCanvas.formattingUnderCursor
@connect(state => ({
focusedNodeType: selectors.CR.Nodes.focusedNodeTypeSelector(state),
currentlyEditedPropertyName: selectors.UI.ContentCanvas.currentlyEditedPropertyName(state),
formattingUnderCursor: selectors.UI.ContentCanvas.formattingUnderCursor(state)
}))
@neos(globalRegistry => ({
nodeTypesRegistry: globalRegistry.get('@neos-project/neos-ui-contentrepository')
Expand Down
74 changes: 39 additions & 35 deletions packages/neos-ui-ckeditor5-bindings/src/manifest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import CkEditorConfigRegistry from './registry/CkEditorConfigRegistry';
import {$add, $get, $or} from 'plow-js';
import {stripTags} from '@neos-project/utils-helpers';

import DisabledAutoparagraphMode from './plugins/disabledAutoparagraphMode';
Expand All @@ -25,10 +24,15 @@ import InsideTable from './plugins/insideTable';
import RemoveFormat from '@ckeditor/ckeditor5-remove-format/src/removeformat';

const addPlugin = (Plugin, isEnabled) => (ckEditorConfiguration, options) => {
// we duplicate editorOptions here so it would be possible to write smth like `$get('formatting.sup')`
// LEGACY: we duplicate editorOptions here so it would be possible to write smth like `$get('formatting.sup')`
if (!isEnabled || isEnabled(options.editorOptions, options)) {
ckEditorConfiguration.plugins = ckEditorConfiguration.plugins || [];
return $add('plugins', Plugin, ckEditorConfiguration);
return {
...ckEditorConfiguration,
plugins: [
...(ckEditorConfiguration.plugins ?? []),
Plugin
]
};
}
return ckEditorConfiguration;
};
Expand Down Expand Up @@ -71,7 +75,7 @@ export default ckEditorRegistry => {
Thus, to e.g. only adjust the CKEditor config if a certain formatting option is enabled, you can do the following:
config.set('doSmthWithConfig', (ckeConfig, {editorOptions}) => {
if ($get(['formatting', 'myCustomField'], editorOptions)) {
if (editorOptions?.formatting.?myCustomField) {
ckeConfig.mySetting = true;
}
return ckeConfig;
Expand Down Expand Up @@ -103,42 +107,42 @@ export default ckEditorRegistry => {
config.set('essentials', addPlugin(Essentials));
config.set('paragraph', addPlugin(Paragraph));
config.set('disabledAutoparagraphMode', addPlugin(DisabledAutoparagraphMode, disableAutoparagraph));
config.set('sub', addPlugin(Sub, $get('formatting.sub')));
config.set('sup', addPlugin(Sup, $get('formatting.sup')));
config.set('bold', addPlugin(Bold, $get('formatting.strong')));
config.set('italic', addPlugin(Italic, $get('formatting.em')));
config.set('underline', addPlugin(Underline, $get('formatting.underline')));
config.set('strikethrough', addPlugin(Strikethrough, $get('formatting.strikethrough')));
config.set('link', addPlugin(Link, $get('formatting.a')));
config.set('linkTargetBlank', addPlugin(LinkTargetBlank, $get('formatting.a')));
config.set('linkRelNofollow', addPlugin(LinkRelNofollow, $get('formatting.a')));
config.set('linkDownload', addPlugin(LinkDownload, $get('formatting.a')));
config.set('linkTitle', addPlugin(LinkTitle, $get('formatting.a')));
config.set('table', addPlugin(Table, i => $get('formatting.table', i)));
config.set('insideTable', addPlugin(InsideTable, i => $get('formatting.table', i)));
config.set('removeFormat', addPlugin(RemoveFormat, $get('formatting.removeFormat')));
config.set('list', addPlugin(List, $or(
$get('formatting.ul'),
$get('formatting.ol')
config.set('sub', addPlugin(Sub, editorOptions => editorOptions?.formatting?.sub));
config.set('sup', addPlugin(Sup, editorOptions => editorOptions?.formatting?.sup));
config.set('bold', addPlugin(Bold, editorOptions => editorOptions?.formatting?.strong));
config.set('italic', addPlugin(Italic, editorOptions => editorOptions?.formatting?.em));
config.set('underline', addPlugin(Underline, editorOptions => editorOptions?.formatting?.underline));
config.set('strikethrough', addPlugin(Strikethrough, editorOptions => editorOptions?.formatting?.strikethrough));
config.set('link', addPlugin(Link, editorOptions => editorOptions?.formatting?.a));
config.set('linkTargetBlank', addPlugin(LinkTargetBlank, editorOptions => editorOptions?.formatting?.a));
config.set('linkRelNofollow', addPlugin(LinkRelNofollow, editorOptions => editorOptions?.formatting?.a));
config.set('linkDownload', addPlugin(LinkDownload, editorOptions => editorOptions?.formatting?.a));
config.set('linkTitle', addPlugin(LinkTitle, editorOptions => editorOptions?.formatting?.a));
config.set('table', addPlugin(Table, editorOptions => editorOptions?.formatting?.table));
config.set('insideTable', addPlugin(InsideTable, editorOptions => editorOptions?.formatting?.table));
config.set('removeFormat', addPlugin(RemoveFormat, editorOptions => editorOptions?.formatting?.removeFormat));
config.set('list', addPlugin(List, editorOptions => (
editorOptions?.formatting?.ul
|| editorOptions?.formatting?.ol
)));
config.set('alignment', addPlugin(Alignment, $or(
$get('formatting.left'),
$get('formatting.center'),
$get('formatting.right'),
$get('formatting.justify')
config.set('alignment', addPlugin(Alignment, editorOptions => (
editorOptions?.formatting?.left
|| editorOptions?.formatting?.center
|| editorOptions?.formatting?.right
|| editorOptions?.formatting?.justify
)));
config.set('heading', addPlugin(Heading, $or(
$get('formatting.h1'),
$get('formatting.h2'),
$get('formatting.h3'),
$get('formatting.h4'),
$get('formatting.h5'),
$get('formatting.h6')
config.set('heading', addPlugin(Heading, editorOptions => (
editorOptions?.formatting?.h1
|| editorOptions?.formatting?.h2
|| editorOptions?.formatting?.h3
|| editorOptions?.formatting?.h4
|| editorOptions?.formatting?.h5
|| editorOptions?.formatting?.h6
)));

// Custom Plugin that automatically converts <i> to <em> for italics
// @fixes https://github.com/neos/neos-ui/issues/2906
config.set('italicWithEm', addPlugin(ItalicWithEm, $get('formatting.em')));
config.set('italicWithEm', addPlugin(ItalicWithEm, editorOptions => editorOptions?.formatting?.em));

//
// @see https://docs.ckeditor.com/ckeditor5/latest/features/headings.html#configuring-heading-levels
Expand Down
Loading

0 comments on commit 66889e3

Please sign in to comment.