Any ideas for a simple blog/post editor for Meteor? I’d like to be able to generate simple HTML posts to store into the DB that contain for instance <p], <b], <blockquote] but will be suitable for someone that does not have any experience programming.
Is there a meteor package for blog posts similar to the wordpress or blogger one? Something that would allow a user to edit the text like a word document and then store the HTML into the database.
You might want to consider more modern editors that store the rich-text as object. For example the new version of ckeditor, Draft.js / Slate (if you use React) or Quill.js.
import { Template } from 'meteor/templating';
import ClassicEditor from '@ckeditor/ckeditor5-build-classic'
import './main.html';
Template.Blog.onRendered(async function () {
const editor = await ClassicEditor.create( document.querySelector( '#mytextarea' ) );
console.log(editor);
});
I tried a dynamic template (albeit with a hardcoded template name) and it worked fine.
The “usual” problem with relying on the onRendered is that it doesn’t automatically take care of reactivity. That means that the presence of reactive elements may mean that the onRendered runs (because all static elements can be rendered), but not all the DOM elements in that template may exist at that moment (reactive elements have not been created, because data is not available for them yet).
The template you provided doesn’t appear to have any reactive elements, so I don’t think that will be an issue here.
I don’t think I’ve imported my code any differently to yours, although you haven’t shown where you do your import - it should be in the file(s) where it’s used.
Did you do the import in a different file? That’s the only reason I can think of for needing to attach it to the global Window object. I’m using Meteor 1.8, but that shouldn’t make a difference here.