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

temp

parent e8c33832
No related branches found
No related tags found
No related merge requests found
...@@ -44,9 +44,9 @@ const Oen = () => { ...@@ -44,9 +44,9 @@ const Oen = () => {
value={val} value={val}
// readonly // readonly
layout={OenLayout} layout={OenLayout}
// onChange={debounce(source => { onChange={debounce(source => {
// console.log(JSON.stringify(source)); console.log(JSON.stringify(source));
// }, 200)} }, 200)}
user={user} user={user}
/> />
); );
......
...@@ -73,9 +73,9 @@ const OENToolGroup = ({ item }) => { ...@@ -73,9 +73,9 @@ const OENToolGroup = ({ item }) => {
activeView.dispatch, activeView.dispatch,
tool.className, tool.className,
); );
setTimeout(() => { // setTimeout(() => {
main.focus(); // main.focus();
}); // });
}} }}
title={tool.displayName} title={tool.displayName}
/> />
......
import { injectable } from 'inversify'; import { injectable } from 'inversify';
import { wrapIn } from 'prosemirror-commands'; import { wrapIn } from 'prosemirror-commands';
import { Commands } from 'wax-prosemirror-utilities'; import { NodeSelection } from 'prosemirror-state';
import { Mapping, RemoveMarkStep, ReplaceStep } from 'prosemirror-transform';
import Tools from '../lib/Tools'; import Tools from '../lib/Tools';
@injectable() @injectable()
...@@ -11,27 +12,50 @@ export default class OENContainersTool extends Tools { ...@@ -11,27 +12,50 @@ export default class OENContainersTool extends Tools {
get run() { get run() {
return (state, dispatch, className) => { return (state, dispatch, className) => {
console.log(state.selection); const { from, to } = state.selection;
const node = className === 'section' ? 'oen_section' : 'oen_container'; let isInOenContainer = false;
let OENContainer = '';
let position = 0;
state.doc.nodesBetween(from, to, (node, pos) => {
if (node.type.name === 'oen_container') {
isInOenContainer = true;
OENContainer = node;
position = pos;
console.log(pos);
}
});
wrapIn(state.config.schema.nodes[node], { class: className })( if (isInOenContainer) {
state, const map = new Mapping();
dispatch, const newNode = JSON.parse(JSON.stringify(OENContainer));
); OENContainer.attrs.class = className;
console.log('replace', OENContainer);
newNode.attrs = {
...newNode.attrs,
class: className,
};
console.log(newNode);
state.tr.setSelection(NodeSelection.create(state.doc, position));
state.tr.replaceSelectionWith(OENContainer);
// state.tr.setNodeMarkup(map.map(position), null, {
// ...OENContainer.attrs,
// class: className,
// });
dispatch(state.tr);
} else {
const node = className === 'section' ? 'oen_section' : 'oen_container';
console.log(className); wrapIn(state.config.schema.nodes[node], { class: className })(
state,
dispatch,
);
}
}; };
} }
select = (state, activeViewId) => { select = (state, activeViewId) => {
const { from, to } = state.selection; if (activeViewId !== 'main') return false;
let status = true; return true;
state.doc.nodesBetween(from, to, (node, pos) => {
if (node.type.name === 'oen_container') {
status = false;
}
});
return status;
}; };
get enable() { get enable() {
......
...@@ -11,14 +11,14 @@ div[data-type="content_structure_element"]::before { ...@@ -11,14 +11,14 @@ div[data-type="content_structure_element"]::before {
display: block; display: block;
} }
.section { section {
position: relative; position: relative;
padding: 10px 10px 0 10px; padding: 10px 10px 0 10px;
margin-top: 20px; margin-top: 20px;
border: 3px solid #E2EBFF; border: 3px solid #E2EBFF;
} }
.section::before { section::before {
content: 'Section'; content: 'Section';
color: #c7d8fc; color: #c7d8fc;
font-weight: bold; font-weight: bold;
...@@ -29,11 +29,11 @@ div[data-type="content_structure_element"]::before { ...@@ -29,11 +29,11 @@ div[data-type="content_structure_element"]::before {
left: -3px; left: -3px;
} }
.ProseMirror>section.section:nth-of-type(1) { .ProseMirror>section:nth-of-type(1) {
margin-top: 0px; margin-top: 0px;
} }
.section>div:nth-of-type(1) { section>div:nth-of-type(1) {
padding-top: 0; padding-top: 0;
} }
...@@ -73,10 +73,6 @@ content: 'Learning Objectives Section'; ...@@ -73,10 +73,6 @@ content: 'Learning Objectives Section';
content: 'References Section'; content: 'References Section';
} }
.main-content::before {
content: 'Main Content Section';
}
.bibliography::before { .bibliography::before {
content: 'Bibliography Section'; content: 'Bibliography Section';
} }
......
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