diff --git a/editors/editoria/src/config/config.js b/editors/editoria/src/config/config.js index 270394a226e40d8848b22b577d094e7252eadb63..b8fa8b71178f94afc7d8fda5f6330a35b65eb655 100644 --- a/editors/editoria/src/config/config.js +++ b/editors/editoria/src/config/config.js @@ -42,8 +42,8 @@ import { TrackCommentOptionsToolGroupService, CustomTagInlineService, CustomTagInlineToolGroupService, - CustomTagBlockService, CustomTagBlockToolGroupService, + CustomTagService, } from 'wax-prosemirror-services'; import { DefaultSchema } from 'wax-prosemirror-utilities'; @@ -172,9 +172,8 @@ export default { new TransformToolGroupService(), new TrackOptionsToolGroupService(), new TrackCommentOptionsToolGroupService(), + new CustomTagService(), new CustomTagInlineToolGroupService(), - new CustomTagInlineService(), - new CustomTagBlockService(), new CustomTagBlockToolGroupService(), ], }; diff --git a/editors/editoria/src/config/configMobile.js b/editors/editoria/src/config/configMobile.js index f5431237be83262028182f1ef01a108d48cb1e84..ae449efe9adae16c0ffc65c6b1d0c67f3ab4a4d1 100644 --- a/editors/editoria/src/config/configMobile.js +++ b/editors/editoria/src/config/configMobile.js @@ -31,10 +31,9 @@ import { BottomInfoService, TransformService, TransformToolGroupService, - CustomTagInlineService, CustomTagInlineToolGroupService, - CustomTagBlockService, CustomTagBlockToolGroupService, + CustomTagService, } from 'wax-prosemirror-services'; import { WaxSelectionPlugin } from 'wax-prosemirror-plugins'; @@ -124,9 +123,8 @@ export default { new BottomInfoService(), new TransformService(), new TransformToolGroupService(), + new CustomTagService(), new CustomTagInlineToolGroupService(), - new CustomTagInlineService(), - new CustomTagBlockService(), new CustomTagBlockToolGroupService(), ], }; diff --git a/wax-prosemirror-components/src/components/customtag/CustomTagBlockComponent.js b/wax-prosemirror-components/src/components/customtag/CustomTagBlockComponent.js index 305dc49986140564d287130c78e42928d31c6d38..79b5a2bee2854235440cf347e215011a81f97630 100644 --- a/wax-prosemirror-components/src/components/customtag/CustomTagBlockComponent.js +++ b/wax-prosemirror-components/src/components/customtag/CustomTagBlockComponent.js @@ -1,9 +1,7 @@ import React, { useContext, useMemo, useRef, useState } from 'react'; import styled from 'styled-components'; import { WaxContext } from 'wax-prosemirror-core'; -import { DocumentHelpers } from 'wax-prosemirror-utilities'; -import { selectParentNode } from 'prosemirror-commands'; -import { node } from 'prop-types'; +import { Commands } from 'wax-prosemirror-utilities'; const Wrapper = styled.div``; @@ -82,22 +80,10 @@ const CustomTagBlockComponent = (isIconClicked) => { } const onSelectTag = (e, item) => { - - const $pos = main.state.tr.doc.resolve($from.pos); - const $topos = main.state.tr.doc.resolve($to.pos); - const startPos = $pos.start(); - const endPos = $topos.end(); - - dispatch( - state.tr.addMark( - startPos, - endPos, - state.schema.marks.customTagBlock.create({ - tagName: item, - class: 'custom-tag-block', - }), - ), - ); + item = item.replace(/ /g, "-"); + Commands.setBlockType(state.config.schema.nodes.customTagBlock, { + class: 'custom-tag-block ' + item + })(state, dispatch); } return useMemo( diff --git a/wax-prosemirror-components/src/ui/tabs/BlockElement.js b/wax-prosemirror-components/src/ui/tabs/BlockElement.js index 544c20c5ddb8c7232467870e91d0710de1f095df..c1029edea06e56178d0b2dba4c3d6671dbd27dae 100644 --- a/wax-prosemirror-components/src/ui/tabs/BlockElement.js +++ b/wax-prosemirror-components/src/ui/tabs/BlockElement.js @@ -27,7 +27,6 @@ const Box = styled.div` const BlockElement = props => { const { item, onClick, view } = props; -console.log('item : ', item); return ( <Wrapper onClick={onClick}> <Box /> diff --git a/wax-prosemirror-schema/index.js b/wax-prosemirror-schema/index.js index 6cdb69a8ce3ad81e35908ff14fd067b78990e53b..30b965c426c43930e2172e545a4fcd02b8357334 100644 --- a/wax-prosemirror-schema/index.js +++ b/wax-prosemirror-schema/index.js @@ -16,7 +16,6 @@ export { default as mathSelectMark } from './src/marks/mathSelectMark'; export { default as highlightMark } from './src/marks/highlightMark'; export { default as transformMark } from './src/marks/transformMark'; export { default as customtagInlineMark } from './src/marks/customTagInlineMark'; -export { default as customtagBlockMark } from './src/marks/customTagBlockMark'; /* LIST OF TRACK CHANGES MARKS */ @@ -46,6 +45,7 @@ export { default as footNoteNode } from './src/nodes/footNoteNode'; export { default as codeBlockNode } from './src/nodes/codeBlockNode'; export { default as mathInlineNode } from './src/nodes/mathInlineNode'; export { default as mathDisplayNode } from './src/nodes/mathDisplayNode'; +export { default as customBlockNode } from './src/nodes/customBlockNode'; /* LIST OF TRACK CHANGES NODES */ diff --git a/wax-prosemirror-schema/src/nodes/customBlockNode.js b/wax-prosemirror-schema/src/nodes/customBlockNode.js new file mode 100644 index 0000000000000000000000000000000000000000..5af53d2995b8b2f6cafc6012eac7fe750850ff9e --- /dev/null +++ b/wax-prosemirror-schema/src/nodes/customBlockNode.js @@ -0,0 +1,26 @@ +const customBlockNode = { + content: "inline*", + group: "block", + priority: 0, + defining: true, + attrs: { + class: { default: "custom-tag-block" } + }, + parseDOM: [ + { + tag: "custom-tag-block", + getAttrs(hook, next) { + Object.assign(hook, { + class: hook.dom.getAttribute("class") + }); + next(); + } + } + ], + toDOM(hook, next) { + const attrs = { class: hook.attrs.class }; + return hook.value = ["custom-tag-block", attrs, 0]; + } +}; + +export default customBlockNode; diff --git a/wax-prosemirror-services/index.js b/wax-prosemirror-services/index.js index 601f348b3f727535bb23afcf8ca85a0fb1bb0eca..cd0a2a7a146dc9907932ba6bb040185be5e9de89 100644 --- a/wax-prosemirror-services/index.js +++ b/wax-prosemirror-services/index.js @@ -38,6 +38,7 @@ export { default as EditingSuggestingService } from './src/EditingSuggestingServ export { default as TrackOptionsService } from './src/TrackOptionsService/TrackOptionsService'; export { default as CustomTagInlineService } from './src/CustomTagService/CustomTagInlineService/CustomTagInlineService'; export { default as CustomTagBlockService } from './src/CustomTagService/CustomTagBlockService/CustomTagBlockService'; +export { default as CustomTagService } from './src/CustomTagService/CustomTagService'; /* ToolGroups diff --git a/wax-prosemirror-services/src/CustomTagService/CustomTagBlockService/CustomTagBlockService.js b/wax-prosemirror-services/src/CustomTagService/CustomTagBlockService/CustomTagBlockService.js index 2ac86d8d87e06b22ae09d391c3cf2fbb4e7cef6d..821b5bb82daca0b845518b3c25457ea569e11f0f 100644 --- a/wax-prosemirror-services/src/CustomTagService/CustomTagBlockService/CustomTagBlockService.js +++ b/wax-prosemirror-services/src/CustomTagService/CustomTagBlockService/CustomTagBlockService.js @@ -1,17 +1,20 @@ import CustomTagBlockTool from './CustomTagBlockTool'; import Service from '../../Service'; -import { customtagBlockMark } from 'wax-prosemirror-schema'; +import { customBlockNode } from 'wax-prosemirror-schema'; + + +class CustomTagBlockService extends Service { -export default class CustomTagBlockService extends Service { - register() { this.container.bind('CustomTagBlockTool').to(CustomTagBlockTool); - const createMark = this.container.get('CreateMark'); - createMark( + const createNode = this.container.get('CreateNode'); + createNode( { - customTagBlock: customtagBlockMark, - }, - { toWaxSchema: true }, + customTagBlock: customBlockNode, + } ); } -} \ No newline at end of file + +} + +export default CustomTagBlockService; \ No newline at end of file diff --git a/wax-prosemirror-services/src/CustomTagService/CustomTagInlineService/CustomTagInlineService.js b/wax-prosemirror-services/src/CustomTagService/CustomTagInlineService/CustomTagInlineService.js index 1e913ce5f8cfa7f0fd2ef3692c3bae7a42347274..b6b2c2376e30ab8de182134489688b8baf7f34a4 100644 --- a/wax-prosemirror-services/src/CustomTagService/CustomTagInlineService/CustomTagInlineService.js +++ b/wax-prosemirror-services/src/CustomTagService/CustomTagInlineService/CustomTagInlineService.js @@ -2,9 +2,8 @@ import CustomTagInlineTool from './CustomTagInlineTool'; import Service from '../../Service'; import { CustomTagInlineOverlayComponent } from 'wax-prosemirror-components'; import { customtagInlineMark } from 'wax-prosemirror-schema'; -import { WaxContext } from 'wax-prosemirror-core'; -export default class CustomTagInlineService extends Service { +class CustomTagInlineService extends Service { boot() { const createOverlay = this.container.get('CreateOverlay'); @@ -19,7 +18,7 @@ export default class CustomTagInlineService extends Service { ); } - + register() { this.container.bind('CustomTagInlineTool').to(CustomTagInlineTool); const createMark = this.container.get('CreateMark'); @@ -30,4 +29,7 @@ export default class CustomTagInlineService extends Service { { toWaxSchema: true }, ); } -} \ No newline at end of file +} + + +export default CustomTagInlineService; \ No newline at end of file diff --git a/wax-prosemirror-services/src/CustomTagService/CustomTagService.js b/wax-prosemirror-services/src/CustomTagService/CustomTagService.js new file mode 100644 index 0000000000000000000000000000000000000000..4f0f7bd298ab2367d78078776161840f3e0a9d0e --- /dev/null +++ b/wax-prosemirror-services/src/CustomTagService/CustomTagService.js @@ -0,0 +1,8 @@ +import Service from '../Service'; +import CustomService from './index'; + +class CustomTagService extends Service { + dependencies = CustomService; +} + +export default CustomTagService; \ No newline at end of file diff --git a/wax-prosemirror-services/src/CustomTagService/index.js b/wax-prosemirror-services/src/CustomTagService/index.js new file mode 100644 index 0000000000000000000000000000000000000000..3f2a55179d50faad63730caf2476024bc50eeb36 --- /dev/null +++ b/wax-prosemirror-services/src/CustomTagService/index.js @@ -0,0 +1,8 @@ +import CustomTagBlockService from "./CustomTagBlockService/CustomTagBlockService"; +import CustomTagInlineService from "./CustomTagInlineService/CustomTagInlineService"; + + +export default [ + new CustomTagBlockService(), + new CustomTagInlineService() +]; \ No newline at end of file