コード例 #1
0
 /**
  * Creates a new editor attached to an existing document. {@link Editor#reset() Resetting} this
  * editor will preserve the document to which it is attached.
  *
  * @return New Editor instance
  */
 public static Editor attachTo(ContentDocument doc) {
   Element e = doc.getFullContentView().getDocumentElement().getImplNodelet();
   Preconditions.checkArgument(e != null);
   e = e.getParentElement();
   Preconditions.checkArgument(e != null);
   EditorImpl editor =
       UserAgent.isMobileWebkit()
           ? new EditorImplWebkitMobile(false, e)
           : new EditorImpl(false, e);
   editor.setContent(doc);
   return editor;
 }
コード例 #2
0
  @Override
  protected void setUp() {
    EditorTestingUtil.setupTestEnvironment();

    ContentDocElement.register(ROOT_HANDLER_REGISTRY, ContentDocElement.DEFAULT_TAGNAME);
    Paragraph.register(ROOT_HANDLER_REGISTRY);
    LineRendering.registerLines(ROOT_HANDLER_REGISTRY);

    LineRendering.registerParagraphRenderer(
        Editor.ROOT_HANDLER_REGISTRY, new Renderer(renderer, renumberer, runner));

    renumberer.updateHtmlEvenWhenNullImplNodelet = true;

    DocInitializationBuilder builder = new DocInitializationBuilder();
    builder.elementStart("body", Attributes.EMPTY_MAP);
    for (int i = 0; i < SIZE; i++) {
      builder.elementStart("line", Attributes.EMPTY_MAP).elementEnd();
    }
    builder.elementEnd();

    content1 = new ContentDocument(ConversationSchemas.BLIP_SCHEMA_CONSTRAINTS);
    content1.setRegistries(Editor.ROOT_REGISTRIES);
    content1.consume(builder.build());
    doc1 = content1.getMutableDoc();

    content2 = new ContentDocument(ConversationSchemas.BLIP_SCHEMA_CONSTRAINTS);
    content2.setRegistries(Editor.ROOT_REGISTRIES);
    content2.consume(builder.build());
    doc2 = content2.getMutableDoc();

    doc = doc1;

    runTask();
  }