當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript DomFactory.fromHtml方法代碼示例

本文整理匯總了TypeScript中@ephox/alloy.DomFactory.fromHtml方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript DomFactory.fromHtml方法的具體用法?TypeScript DomFactory.fromHtml怎麽用?TypeScript DomFactory.fromHtml使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@ephox/alloy.DomFactory的用法示例。


在下文中一共展示了DomFactory.fromHtml方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: if

  const getDom = () => {
    const common = ItemClasses.colorClass;
    const icon = iconSvg.getOr('');
    const title = itemText.map((text) => ` title="${providerBackstage.translate(text)}"`).getOr('');

    if (itemValue === colorPickerCommand) {
      return DomFactory.fromHtml(`<button class="${common} tox-swatches__picker-btn"${title}>${icon}</button>`);
    } else if (itemValue === removeColorCommand) {
      return DomFactory.fromHtml(`<div class="${common} tox-swatch--remove"${title}>${icon}</div>`);
    } else {
      return DomFactory.fromHtml(`<div class="${common}" style="background-color: ${itemValue}" data-mce-color="${itemValue}"${title}></div>`);
    }
  };
開發者ID:tinymce,項目名稱:tinymce,代碼行數:13,代碼來源:ItemStructure.ts

示例2:

const renderSpinner = (providerBackstage: UiFactoryBackstageProviders): AlloySpec => {
  return {
    dom: {
      tag: 'div',
      attributes: {
        'aria-label': providerBackstage.translate('Loading...')
      },
      classes: [ 'tox-throbber__busy-spinner' ]
    },
    components: [
      {
        dom: DomFactory.fromHtml(`<div class="tox-spinner"><div></div><div></div><div></div></div>`)
      }
    ],
    behaviours: Behaviour.derive([
      // Trap the "Tab" key and don't let it escape.
      Keying.config({
        mode: 'special',
        onTab: () => Option.some(true),
        onShiftTab: () => Option.some(true)
      }),
      Focusing.config({ })
    ])
  };
};
開發者ID:tinymce,項目名稱:tinymce,代碼行數:25,代碼來源:Throbber.ts

示例3: lookup

const renderFooter = (initFoo: WindowFooterFoo, providersBackstage: UiFactoryBackstageProviders) => {
  const updateState = (_comp, data: WindowFooterFoo) => {
    const footerButtons: DialogMemButton[] = Arr.map(data.buttons, (button) => {
      const memButton = Memento.record(makeButton(button, providersBackstage));
      return {
        name: button.name,
        align: button.align,
        memento: memButton
      };
    });

    const lookupByName = (
      compInSystem: AlloyComponent,
      buttonName: string
    ) => lookup(compInSystem, footerButtons, buttonName);

    return Option.some({
      lookupByName,
      footerButtons
    });
  };

  return {
    dom: DomFactory.fromHtml(`<div class="tox-dialog__footer"></div>`),
    components: [ ],
    behaviours: Behaviour.derive([
      Reflecting.config({
        channel: footerChannel,
        initialData: initFoo,
        updateState,
        renderComponents
      })
    ])
  };
};
開發者ID:tinymce,項目名稱:tinymce,代碼行數:35,代碼來源:SilverDialogFooter.ts

示例4: renderTitle

const renderModalHeader = (foo: WindowHeaderFoo, providersBackstage: UiFactoryBackstageProviders): AlloySpec => {
  const pTitle = ModalDialog.parts().title(
    renderTitle(foo, Option.none(), providersBackstage)
  );

  const pHandle = ModalDialog.parts().draghandle({
    dom: DomFactory.fromHtml('<div class="tox-dialog__draghandle"></div>')
  });

  const pClose = ModalDialog.parts().close(
    renderClose(providersBackstage)
  );

  const components = [ pTitle ].concat(foo.draggable ? [ pHandle ] : []).concat([ pClose ]);
  return Container.sketch({
    dom: DomFactory.fromHtml('<div class="tox-dialog__header"></div>'),
    components
  });
};
開發者ID:tinymce,項目名稱:tinymce,代碼行數:19,代碼來源:SilverDialogHeader.ts

示例5:

const pBodyMessage = (message: string, providersBackstage: UiFactoryBackstageProviders) => ModalDialog.parts().body({
  dom: {
    tag: 'div',
    classes: [ 'tox-dialog__body', 'todo-tox-fit' ]
  },
  components: [
    {
      dom: DomFactory.fromHtml(`<p>${providersBackstage.translate(message)}</p>`)
    }
  ]
});
開發者ID:tinymce,項目名稱:tinymce,代碼行數:11,代碼來源:Dialogs.ts

示例6:

 const display = (label: string, spec: SimpleSpec) => {
   return {
     dom: {
       tag: 'div',
       styles: { border: '1px solid #aaa', margin: '1em', padding: '1em' }
     },
     components: [
       { dom: DomFactory.fromHtml('<h3>' + label + '</h3>') },
       { dom: { tag: 'hr' } },
       spec
     ]
   };
 };
開發者ID:tinymce,項目名稱:tinymce,代碼行數:13,代碼來源:DialogComponentsDemo.ts

示例7: default

export default () => {

  const oldSink = document.querySelectorAll('.mce-silver-sink');
  if (oldSink.length > 0) {
    throw Error('old sinks found, a previous test did not call helpers.destroy() leaving artifacts, found: ' + oldSink.length);
  }

  const sink = GuiFactory.build({
    dom: DomFactory.fromHtml('<div class="mce-silver-sink"></div>'),
    behaviours: Behaviour.derive([
      Positioning.config({
        useFixed: true
      })
    ])
  });

  const uiMothership = Gui.create();
  Class.add(uiMothership.element(), 'tox');

  const backstage = TestBackstage(sink);

  const mockEditor = {
    setContent: (content) => {},
    insertContent: (content: string, args?: any) => {},
    execCommand: (cmd: string, ui?: boolean, value?: any) => {}
  } as Editor;

  const extras = {
    editor: mockEditor,
    backstage
  };

  uiMothership.add(sink);
  Attachment.attachSystem(Body.body(), uiMothership);

  const destroy = () => {
    uiMothership.remove(sink);
    uiMothership.destroy();
  };

  return {
    backstage,
    shared: backstage.shared,
    extras,
    destroy,
    uiMothership,
    mockEditor
  };
};
開發者ID:tinymce,項目名稱:tinymce,代碼行數:49,代碼來源:TestExtras.ts

示例8:

 ModalDialog.setBusy(lazyDialog(), (d, bs) => {
   return {
     dom: {
       tag: 'div',
       classes: [ 'tox-dialog__busy-spinner' ],
       attributes: {
         'aria-label': blockEvent.message()
       },
       styles: {
         left: '0px',
         right: '0px',
         bottom: '0px',
         top: '0px',
         position: 'absolute'
       }
     },
     behaviours: bs,
     components: [
       {
         dom: DomFactory.fromHtml(`<div class="tox-spinner"><div></div><div></div><div></div></div>`)
       }
     ]
   };
 });
開發者ID:tinymce,項目名稱:tinymce,代碼行數:24,代碼來源:SilverDialogCommon.ts


注:本文中的@ephox/alloy.DomFactory.fromHtml方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。