diff --git a/editors/demo/src/Editoria/config/config.js b/editors/demo/src/Editoria/config/config.js index eef89f707935c87230453d1ffd3a51bccdb0d1f4..cdf2dec711ca584f0eb9797096a32596ff1c923c 100644 --- a/editors/demo/src/Editoria/config/config.js +++ b/editors/demo/src/Editoria/config/config.js @@ -115,6 +115,9 @@ export default { ], // CommentsService: { readOnly: true }, + // OrderedListService: { subList: false }, + // BulletListService: { subList: false }, + // JoinUpService: { subList: false }, SchemaService: DefaultSchema, TitleService: { updateTitle }, RulesService: [emDash, ellipsis], diff --git a/editors/demo/src/Editors.js b/editors/demo/src/Editors.js index d19991a2ed8613a7f85ed0fed95a7dc6ef294736..abd0628fb70695fdd171c22a2956784070ef3345 100644 --- a/editors/demo/src/Editors.js +++ b/editors/demo/src/Editors.js @@ -70,7 +70,7 @@ const Editors = () => { case 'ncbi': return <NCBI />; default: - return <HHMI />; + return <Editoria />; } }; diff --git a/wax-prosemirror-services/src/ListsService/BulletListService/BulletList.js b/wax-prosemirror-services/src/ListsService/BulletListService/BulletList.js index 5f10e03ba50500f2ccc6af55791990e7f89ace77..d9a6a485907dfc872e0b878b8bf9b7410ffd601f 100644 --- a/wax-prosemirror-services/src/ListsService/BulletListService/BulletList.js +++ b/wax-prosemirror-services/src/ListsService/BulletListService/BulletList.js @@ -26,12 +26,20 @@ class BulletList extends Tools { select = (state, activeViewId, activeView) => { const { - selection: { from }, + selection: { from, to }, } = state; + let status = true; + + if ('subList' in this.config && !this.config.subList) { + state.doc.nodesBetween(from, to, node => { + if (node.type.name === 'list_item') status = false; + }); + } + if (from === null) return false; const { disallowedTools } = activeView.props; - if (disallowedTools.includes('Lists')) return false; - return true; + if (disallowedTools.includes('Lists')) status = false; + return status; }; get active() { diff --git a/wax-prosemirror-services/src/ListsService/BulletListService/BulletListService.js b/wax-prosemirror-services/src/ListsService/BulletListService/BulletListService.js index 0c0193e730c2c404458e5d89a44a84bee7cea5f2..be0192010ee5415109ea4661eed55c7f2157ab02 100644 --- a/wax-prosemirror-services/src/ListsService/BulletListService/BulletListService.js +++ b/wax-prosemirror-services/src/ListsService/BulletListService/BulletListService.js @@ -4,6 +4,7 @@ import Service from '../../Service'; import BulletList from './BulletList'; class BulletListService extends Service { + name = 'BulletListService'; boot() { const shortCuts = this.container.get('ShortCuts'); // shortCuts.addShortCut({ @@ -12,7 +13,9 @@ class BulletListService extends Service { } register() { - this.container.bind('BulletList').to(BulletList); + this.container.bind('BulletList').toDynamicValue(() => { + return new BulletList(this.config); + }); const createNode = this.container.get('CreateNode'); createNode( { diff --git a/wax-prosemirror-services/src/ListsService/JoinUpService/JoinUp.js b/wax-prosemirror-services/src/ListsService/JoinUpService/JoinUp.js index f02acabf2b087ba465a6fc43f5337226a9b4d4cd..8760213b5a8d96d949856d82d87590508db88283 100644 --- a/wax-prosemirror-services/src/ListsService/JoinUpService/JoinUp.js +++ b/wax-prosemirror-services/src/ListsService/JoinUpService/JoinUp.js @@ -13,11 +13,28 @@ class JoinUp extends Tools { return joinUp; } - select(state) { - return joinUp(state); - } + select = (state, activeViewId, activeView) => { + const { + selection: { from, to }, + } = state; + let status = joinUp(state); + + if ('subList' in this.config && !this.config.subList) { + state.doc.nodesBetween(from, to, node => { + if (node.type.name === 'list_item') status = false; + }); + } + + return status; + }; get enable() { return joinUp; } + + get active() { + return state => { + return false; + }; + } } diff --git a/wax-prosemirror-services/src/ListsService/JoinUpService/JoinUpService.js b/wax-prosemirror-services/src/ListsService/JoinUpService/JoinUpService.js index 32e83e84094400f89242e99060c707982fd2da13..2d46d45bf06c87ecd6a55133873cbf280dc16099 100644 --- a/wax-prosemirror-services/src/ListsService/JoinUpService/JoinUpService.js +++ b/wax-prosemirror-services/src/ListsService/JoinUpService/JoinUpService.js @@ -1,11 +1,13 @@ -import Service from "../../Service"; -import JoinUp from "./JoinUp"; +import Service from '../../Service'; +import JoinUp from './JoinUp'; class JoinUpService extends Service { - boot() {} - + name = 'JoinUpService'; register() { - this.container.bind("JoinUp").to(JoinUp); + // this.container.bind('JoinUp').to(JoinUp); + this.container.bind('JoinUp').toDynamicValue(() => { + return new JoinUp(this.config); + }); } } diff --git a/wax-prosemirror-services/src/ListsService/ListsService.js b/wax-prosemirror-services/src/ListsService/ListsService.js index 4a87bf91042c542062e13331daddb0afa6458797..516a19d9f9efe4df2d8fcb6256f8e576c3b57dc2 100644 --- a/wax-prosemirror-services/src/ListsService/ListsService.js +++ b/wax-prosemirror-services/src/ListsService/ListsService.js @@ -2,6 +2,7 @@ import Service from '../Service'; import ListsServices from './index'; class ListsService extends Service { + name = 'ListsService'; dependencies = ListsServices; } diff --git a/wax-prosemirror-services/src/ListsService/OrderedListService/OrderedList.js b/wax-prosemirror-services/src/ListsService/OrderedListService/OrderedList.js index 564d67f0466715bbda7e6ab716f7a7f7e0200504..313d24de38cbb4a75da73f9ebd85cf05bf4af219 100644 --- a/wax-prosemirror-services/src/ListsService/OrderedListService/OrderedList.js +++ b/wax-prosemirror-services/src/ListsService/OrderedListService/OrderedList.js @@ -24,12 +24,20 @@ class OrderedList extends Tools { select = (state, activeViewId, activeView) => { const { - selection: { from }, + selection: { from, to }, } = state; + let status = true; + + if ('subList' in this.config && !this.config.subList) { + state.doc.nodesBetween(from, to, node => { + if (node.type.name === 'list_item') status = false; + }); + } + if (from === null) return false; const { disallowedTools } = activeView.props; - if (disallowedTools.includes('Lists')) return false; - return true; + if (disallowedTools.includes('Lists')) status = false; + return status; }; get active() { diff --git a/wax-prosemirror-services/src/ListsService/OrderedListService/OrderedListService.js b/wax-prosemirror-services/src/ListsService/OrderedListService/OrderedListService.js index 23aad6d5fd82d212f664ff8c59ab0a5383bb9ed8..9c73e4410eb9fcd45dfb4b25b56e21fcbb6eb6d5 100644 --- a/wax-prosemirror-services/src/ListsService/OrderedListService/OrderedListService.js +++ b/wax-prosemirror-services/src/ListsService/OrderedListService/OrderedListService.js @@ -1,24 +1,27 @@ -import Service from "../../Service"; -import { wrapInList } from "prosemirror-schema-list"; -import { orderedListNode } from "wax-prosemirror-schema"; -import OrderedList from "./OrderedList"; +import Service from '../../Service'; +import { wrapInList } from 'prosemirror-schema-list'; +import { orderedListNode } from 'wax-prosemirror-schema'; +import OrderedList from './OrderedList'; class OrderedListService extends Service { + name = 'OrderedListService'; boot() { - const shortCuts = this.container.get("ShortCuts"); + const shortCuts = this.container.get('ShortCuts'); // shortCuts.addShortCut({ // "Shift-Ctrl-9": wrapInList(this.schema.nodes.orderedlist) // }); } register() { - this.container.bind("OrderedList").to(OrderedList); - const createNode = this.container.get("CreateNode"); + this.container.bind('OrderedList').toDynamicValue(() => { + return new OrderedList(this.config); + }); + const createNode = this.container.get('CreateNode'); createNode( { - orderedlist: orderedListNode + orderedlist: orderedListNode, }, - { toWaxSchema: true } + { toWaxSchema: true }, ); } } diff --git a/wax-prosemirror-services/src/ListsService/index.js b/wax-prosemirror-services/src/ListsService/index.js index 628800e85c94764016a8c4bfb82c09d7b1177f0a..c35db0480d8863f3150c3da09779b4409c43c0b8 100644 --- a/wax-prosemirror-services/src/ListsService/index.js +++ b/wax-prosemirror-services/src/ListsService/index.js @@ -1,13 +1,13 @@ -import BulletListService from "./BulletListService/BulletListService"; -import OrderedListService from "./OrderedListService/OrderedListService"; -import JoinUpService from "./JoinUpService/JoinUpService"; -import LiftService from "./LiftService/LiftService"; -import ListItemService from "./ListItemService/ListItemService"; +import BulletListService from './BulletListService/BulletListService'; +import OrderedListService from './OrderedListService/OrderedListService'; +import JoinUpService from './JoinUpService/JoinUpService'; +import LiftService from './LiftService/LiftService'; +import ListItemService from './ListItemService/ListItemService'; export default [ new BulletListService(), new OrderedListService(), new JoinUpService(), new LiftService(), - new ListItemService() + new ListItemService(), ];