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

new services files

parent 9f1d2c66
No related branches found
No related tags found
No related merge requests found
Showing with 116 additions and 5 deletions
...@@ -113,6 +113,7 @@ export default { ...@@ -113,6 +113,7 @@ export default {
'HighlightToolGroup', 'HighlightToolGroup',
'TransformToolGroup', 'TransformToolGroup',
'CustomTagInline', 'CustomTagInline',
'CustomTagBlock',
'Notes', 'Notes',
'Lists', 'Lists',
'Images', 'Images',
......
import { Service } from 'wax-prosemirror-core';
import customBlockNode from '../CustomTagBlockService/schema/customBlockNode';
import CustomTagBlockNewTool from './CustomTagBlockNewTool';
class CustomTagBlockNewService extends Service {
register() {
this.container.bind('CustomTagBlockNewTool').to(CustomTagBlockNewTool);
const createNode = this.container.get('CreateNode');
createNode(
{
customTagBlock: customBlockNode,
},
{ toWaxSchema: true },
);
}
}
export default CustomTagBlockNewService;
import React from 'react';
import { isEmpty } from 'lodash';
import { Commands, Tools } from 'wax-prosemirror-core';
import CustomBlockDropDownComponent from '../components/CustomBlockDropDownComponent';
class CustomTagBlockNewTool extends Tools {
title = 'Custom Tag Block';
name = 'CustomTagBlock';
get run() {
return (state, dispatch, val) => {
Commands.setBlockType(state.config.schema.nodes.customTagBlock, {
class: val.replace(/ /g, '-').toLowerCase(),
})(state, dispatch);
};
}
get active() {
return (state, activeViewId, className, allTags) => {
const isActive = Commands.customTagBlockActive(
state.config.schema.nodes.customTagBlock,
{ class: className },
)(state);
const blockTags = allTags.filter(tag => {
return tag.tagType === 'block';
});
const tagsActive = {};
blockTags.forEach(tag => {
if (
isActive &&
className === tag.label.replace(/ /g, '-').toLowerCase()
) {
tagsActive[tag.label] = true;
} else {
tagsActive[tag.label] = false;
}
});
return tagsActive;
};
}
select = (state, activeViewId) => {
if (activeViewId !== 'main') return false;
return true;
};
renderTool(view) {
if (isEmpty(view)) return null;
return this.isDisplayed() ? (
<CustomBlockDropDownComponent
item={this.toJSON()}
key="Save"
view={view}
/>
) : null;
}
}
export default CustomTagBlockNewTool;
import { injectable, inject } from 'inversify';
import { ToolGroup } from 'wax-prosemirror-core';
@injectable()
class CustomTagBlockToolGroup extends ToolGroup {
tools = [];
title = 'Custom Block';
constructor(@inject('CustomTagBlockNewTool') customTagBlockNewTool) {
super();
this.tools = [customTagBlockNewTool];
}
}
export default CustomTagBlockToolGroup;
import { Service } from 'wax-prosemirror-core';
import CustomTagBlockNewToolGroup from './CustomTagBlockNewToolGroup';
class CustomTagBlockNewToolGroupService extends Service {
register() {
this.container.bind('CustomTagBlock').to(CustomTagBlockNewToolGroup);
}
}
export default CustomTagBlockNewToolGroupService;
import React from 'react';
const CustomBlockDropDownComponent = ({ view, tools }) => {
return <span>hi</span>;
};
export default CustomBlockDropDownComponent;
import CustomTagBlockService from './CustomTagBlockService/CustomTagBlockService'; import CustomTagBlockService from './CustomTagBlockService/CustomTagBlockService';
import CustomTagBlockNewService from './CustomTagBlockNewService/CustomTagBlockNewService';
import CustomTagInlineService from './CustomTagInlineService/CustomTagInlineService'; import CustomTagInlineService from './CustomTagInlineService/CustomTagInlineService';
import CustomTagBlockToolGroupService from './CustomTagToolGroupService/CustomTagBlockToolGroupService/CustomTagBlockToolGroupService'; import CustomTagBlockToolGroupService from './CustomTagToolGroupService/CustomTagBlockToolGroupService/CustomTagBlockToolGroupService';
import CustomTagInlineToolGroupService from './CustomTagToolGroupService/CustomTagInlineToolGroupService/CustomTagInlineToolGroupService'; import CustomTagInlineToolGroupService from './CustomTagToolGroupService/CustomTagInlineToolGroupService/CustomTagInlineToolGroupService';
import CustomTagBlockNewToolGroupService from './CustomTagToolGroupService/CustomTagBlockNewToolGroupService/CustomTagBlockNewToolGroupService';
export default [ export default [
new CustomTagBlockNewService(),
new CustomTagBlockService(), new CustomTagBlockService(),
new CustomTagInlineService(), new CustomTagInlineService(),
new CustomTagBlockToolGroupService(), new CustomTagBlockToolGroupService(),
new CustomTagInlineToolGroupService(), new CustomTagInlineToolGroupService(),
new CustomTagBlockNewToolGroupService(),
]; ];
...@@ -110,11 +110,6 @@ const BlockDropDownComponent = ({ view, tools }) => { ...@@ -110,11 +110,6 @@ const BlockDropDownComponent = ({ view, tools }) => {
value: '8', value: '8',
item: tools[8], item: tools[8],
}, },
// {
// label: translatedLabel(`Wax.BlockLevel.Block Quote`, 'Block Quote'),
// value: '13',
// item: tools[13],
// },
]; ];
const { app } = useContext(ApplicationContext); const { app } = useContext(ApplicationContext);
......
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