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

disable sublist creation from config

parent 785c3c07
No related branches found
No related tags found
1 merge request!353disable sublist creation from config
Showing
with 76 additions and 31 deletions
......@@ -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],
......
......@@ -70,7 +70,7 @@ const Editors = () => {
case 'ncbi':
return <NCBI />;
default:
return <HHMI />;
return <Editoria />;
}
};
......
......@@ -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() {
......
......@@ -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(
{
......
......@@ -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;
};
}
}
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);
});
}
}
......
......@@ -2,6 +2,7 @@ import Service from '../Service';
import ListsServices from './index';
class ListsService extends Service {
name = 'ListsService';
dependencies = ListsServices;
}
......
......@@ -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() {
......
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 },
);
}
}
......
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(),
];
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