Skip to content
Snippets Groups Projects
Commit a1bcce92 authored by chris's avatar chris
Browse files

move lib files

parent b9d17ce5
No related branches found
No related tags found
1 merge request!416fix feedback insert
......@@ -2,4 +2,10 @@ export { default as Service } from './src/Service';
export { WaxContext, useInjection } from './src/WaxContext';
export { PortalContext } from './src/PortalContext';
export { default as ComponentPlugin } from './src/ComponentPlugin';
/* UTILITIES */
export { default as Middleware } from './src/utilities/lib/Middleware';
// export { default as ToolGroup } from './src/utilities/lib/ToolGroup';
// export { default as Tools } from './src/utilities/lib/Tools';
export { default as Wax } from './src/Wax';
......@@ -2,14 +2,14 @@ export default class Middleware {
constructor() {
// Array prototype last
if (!Array.prototype.last) {
Array.prototype.last = function() {
Array.prototype.last = function () {
return this[this.length - 1];
};
}
// Array prototype reduceOneRight
if (!Array.prototype.reduceOneRight) {
Array.prototype.reduceOneRight = function() {
Array.prototype.reduceOneRight = function () {
return this.slice(0, -1);
};
}
......@@ -21,7 +21,7 @@ export default class Middleware {
let _next = args.last();
fn.apply(this, [
...args.reduceOneRight(),
_next.bind.apply(_next, [null, ...args.reduceOneRight()])
_next.bind.apply(_next, [null, ...args.reduceOneRight()]),
]);
}))(this.go);
}
......
/* eslint-disable no-underscore-dangle */
import React, { useMemo } from 'react';
import { injectable, inject } from 'inversify';
import { ToolGroupComponent, ToolGroups } from 'wax-prosemirror-components';
import { v4 as uuidv4 } from 'uuid';
import { isEmpty } from 'lodash';
class ToolGroup {
_config = {};
title = '';
_tools = [];
_toolGroups = [];
setGroupConfig(config) {
this._config = config;
}
set toolGroups(groups) {
this._toolGroups = groups;
}
excludeIncludeTools() {
const { exclude = [], include = [] } = this._config;
if (include.length > 0) {
this._tools.map(tool => {
if (include.includes(tool.name)) {
tool.displayTool();
} else {
tool.hideTool();
}
return true;
});
} else {
this._tools.map(tool => {
if (exclude.includes(tool.name)) {
tool.hideTool();
}
});
}
}
addToolIntoMore() {
const { more = [] } = this._config;
if (more.length > 0) {
this._tools.map(tool => {
if (more.includes(tool.name)) {
tool.hideInToolGroup();
} else {
tool.displayInToolGroup();
}
});
}
}
set tools(tools) {
this._tools = tools;
}
renderTools(view) {
if (isEmpty(view)) return null;
const { name } = this.constructor;
if (this._toolGroups > 0) {
return <ToolGroups toolGroups={this._toolGroups} view={view} />;
}
const MemorizedToolGroupComponent = useMemo(
() => (
<ToolGroupComponent
key={uuidv4()}
name={name}
title={this.title}
tools={this._tools}
view={view}
/>
),
[],
);
return MemorizedToolGroupComponent;
}
}
export default ToolGroup;
/* eslint-disable */
import React from 'react';
import { v4 as uuidv4 } from 'uuid';
import { isEmpty } from 'lodash';
import { injectable, inject } from 'inversify';
import { Button } from 'wax-prosemirror-components';
@injectable()
class Tools {
title = 'title';
_isDisplayed = true;
_isHiddenInToolGroup = false;
config = {};
pmplugins = {};
name = 'name';
constructor(@inject('Config') config, @inject('PmPlugins') pmplugins) {
this.config = config;
this.pmplugins = pmplugins;
}
static get id() {
return this.name;
}
get run() {
return true;
}
get enable() {
return () => true;
}
select() {
return () => true;
}
get active() {
return () => false;
}
toJSON() {
return {
title: this.title,
icon: this.icon,
label: this.label,
active: this.active,
run: this.run,
enable: this.enable,
select: this.select,
id: this.id,
};
}
renderTool(view) {
if (isEmpty(view)) return null;
return this._isDisplayed ? (
<Button key={uuidv4()} item={this.toJSON()} view={view} />
) : null;
}
displayTool() {
this._isDisplayed = true;
}
hideTool() {
this._isDisplayed = false;
}
isDisplayed() {
return this._isDisplayed;
}
displayInToolGroup() {
this._isHiddenInToolGroup = false;
}
hideInToolGroup() {
this._isHiddenInToolGroup = true;
}
isIntoMoreSection() {
return this._isHiddenInToolGroup;
}
}
export default Tools;
/* Base Services move to core */
export { default as LayoutService } from './src/LayoutService/LayoutService';
export { default as PortalService } from './src/PortalService/PortalService';
export { default as MenuService } from './src/MenuService/MenuService';
export { default as OverlayService } from './src/OverlayService/OverlayService';
export { default as ImageService } from './src/ImageService/ImageService';
export { default as RulesService } from './src/RulesService/RulesService';
export { default as SchemaService } from './src/SchemaService/SchemaService';
export { default as ShortCutsService } from './src/ShortCutsService/ShortCutsService';
export { default as AbstractNodeView } from './src/PortalService/AbstractNodeView';
export { default as Tools } from './src/lib/Tools';
export { default as AbstractNodeView } from './src/PortalService/AbstractNodeView';
export { default as ToolGroup } from './src/lib/ToolGroup';
/*
All Elements services
*/
export { default as BaseService } from './src/BaseService/BaseService';
export { default as ImageService } from './src/ImageService/ImageService';
export { default as InlineAnnotationsService } from './src/InlineAnnotations/InlineAnnotationsService';
export { default as ListsService } from './src/ListsService/ListsService';
export { default as TablesService } from './src/TablesService/TablesService';
......
/* eslint-disable no-underscore-dangle */
import { Middleware } from 'wax-prosemirror-core';
import { isPlainObject } from 'lodash';
import ParseRule from './ParseRule';
import Middleware from '../lib/Middleware';
export default class Mark {
name = '';
......
/* eslint-disable no-underscore-dangle */
import { Middleware } from 'wax-prosemirror-core';
import { isPlainObject } from 'lodash';
import ParseRule from './ParseRule';
import Middleware from '../lib/Middleware';
export default class Node {
name = '';
......
import { omit } from "lodash";
import Middleware from "../lib/Middleware";
import { Middleware } from 'wax-prosemirror-core';
import { omit } from 'lodash';
export default class ParseRule {
tag = null;
......@@ -44,7 +44,7 @@ export default class ParseRule {
exporter.go({ dom }, hook => {
hooks = hook;
});
return omit(hooks, ["dom"]);
return omit(hooks, ['dom']);
};
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment