Skip to content
Snippets Groups Projects
Commit ad280c36 authored by chris's avatar chris Committed by john
Browse files

notes importer/exporter expiremental

parent e7c1c5d6
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,7 @@ class CommentComponent extends AnnotationComponent {
const { node } = this.props
const active = node.active
var el = $$('comment')
var el = $$('span')
.attr('data-id', this.props.node.id)
.addClass(this.getClassNames())
......
......@@ -3,7 +3,7 @@ export default {
tagName: 'isolated-note',
import: function (el, node, converter) {
console.log('imported nodes', node)
node.content = converter.annotatedText(el, [node.id, 'content'])
node.parentNoteId = el.attr('parent-id')
}
}
......@@ -33,17 +33,9 @@ class TrackChangeComponent extends AnnotationComponent {
container.addClass('sc-accept-reject-container-hide')
}
// roles, status,username,user-id only exist because
// on the second editor we do not have an exporter but everything is pushed to
// the note-content property of the callout. So cause we use olny the importer
// those attr did not exist
let el = $$('track-change')
let el = $$('span')
.attr('data-id', id)
.attr('title', user.username)
.attr('roles', user.roles[0])
.attr('status', status)
.attr('username', user.username)
.attr('user-id', user.id)
.addClass(this.getClassNames())
.append(this.props.children)
......
......@@ -3,6 +3,7 @@ import { Component, EditorSession,
import MiniEditor from '../../miniEditor/miniEditor'
import config from '../../miniEditor/config'
import Importer from '../../miniEditor/MiniEditorImporter'
import SimpleExporter from '../../SimpleEditorExporter'
import {forEach} from 'lodash'
class Notes extends Component {
......@@ -67,7 +68,6 @@ class Notes extends Component {
_initMiniEditor () {
const configurator = new Configurator().import(config)
configurator.addImporter('html', Importer)
const importer = configurator.createImporter('html')
const provider = this.getProvider()
......@@ -97,13 +97,19 @@ class Notes extends Component {
// so we rerender the Surface
surface.rerender()
const notes = provider.computeEntries()
const configurator = new Configurator().import(config)
const exporter = new SimpleExporter(configurator.config)
forEach(notes.main, function (mainNote) {
forEach(notes.mini, function (miniNote) {
if (miniNote.parentNoteId === mainNote.id) {
console.log(exporter.createElement(miniNote))
// console.log(exportedNode)
// const exportedNode = exporter.convertNode(miniNote)
// console.log('sdlkfjslfkjsfdlkj', exporter.annotatedText(exportedNode.getTextPath()))
this.context.editorSession.transaction(function (tx, args) {
const path = [mainNote.id, 'note-content']
tx.set(path, miniNote.content)
tx.set(path, 'exportedNode.outerHTML')
})
}
}.bind(this))
......
......@@ -69,14 +69,15 @@ class NotesProvider extends TOCProvider {
let rootEl = this.config.miniEditorContext.editor.el
notes = _.map(notes, function (note) {
console.log('noteeee', note)
const element = Component.unwrap(rootEl.find('p[data-path="' + note.id + '.content"]'))
// removes a <br> insterted at the end by inline node
const text = element.innerHTML.slice(0, -4)
let noteContent = '<isolated-note data-id="' + note.id + '" parent-id="' + note.parentNoteId + '" data-type="isolated-note">' + text + '</isolated-note>'
// const text = element.innerHTML.slice(0, -4)
// let noteContent = '<isolated-note data-id="' + note.id + '" parent-id="' + note.parentNoteId + '" data-type="isolated-note">' + text + '</isolated-note>'
return {
id: note.id,
content: noteContent,
content: element.innerHTML,
parentNoteId: note.parentNoteId
}
})
......
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