当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript katamari.Cell类代码示例

本文整理汇总了TypeScript中@ephox/katamari.Cell的典型用法代码示例。如果您正苦于以下问题:TypeScript Cell类的具体用法?TypeScript Cell怎么用?TypeScript Cell使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Cell类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: ModernTheme

UnitTest.asynctest('browser.tinymce.core.annotate.AnnotationChangedTest', (success, failure) => {

  ModernTheme();

  const changes: Cell<Array<{state: boolean, name: string, uid: string}>> = Cell([ ]);

  const sAssertChanges = (message: string, expected: Array<{uid: string, state: boolean, name: string}>) => Logger.t(
    message,
    // Use a chain so that changes.get() can be evaluated at run-time.
    Chain.asStep({ }, [
      Chain.mapper((_) => {
        return changes.get();
      }),
      Chain.op((cs: Array<{uid: string, name: string}>) => {
        Assertions.assertEq('Checking changes', expected, cs);
      })
    ])
  );

  const sClearChanges = Step.sync(() => {
    changes.set([ ]);
  });

  TinyLoader.setup(function (editor: Editor, onSuccess, onFailure) {
    const tinyApis = TinyApis(editor);

    const sTestAnnotationEvents = (label: string, start: number[], soffset: number, expected: Array<{ uid: string, name: string, state: boolean}>): any => {
      return GeneralSteps.sequence([
        tinyApis.sSetSelection(start, soffset, start, soffset),
        Waiter.sTryUntil(
          label,
          sAssertChanges('sTestAnnotationEvents.sAssertChanges', expected),
          10,
          1000
        ),
      ]);
    };

    const sTestChanges = GeneralSteps.sequence([
      // '<p>This |is the first paragraph</p><p>This is the second.</p><p>This is| the third.</p><p>Spanning |multiple</p><p>par||ag||raphs| now</p>'
      tinyApis.sSetContent([
        '<p>This is the first paragraph</p>',
        '<p>This is the second.</p>',
        '<p>This is the third.</p>',
        '<p>Spanning multiple</p>',
        '<p>paragraphs now</p>'
      ].join('')),
      tinyApis.sSetSelection([ 0, 0 ], 'This '.length, [ 0, 0 ], 'This is'.length),
      sAnnotate(editor, 'alpha', 'id-one', { anything: 'comment-1' }),

      tinyApis.sSetSelection([ 1, 0 ], 'T'.length, [ 1, 0 ], 'This is'.length),
      sAnnotate(editor, 'alpha', 'id-two', { anything: 'comment-two' }),

      tinyApis.sSetSelection([ 2, 0 ], 'This is the th'.length, [ 2, 0 ], 'This is the thir'.length),
      sAnnotate(editor, 'beta', 'id-three', { something: 'comment-three' }),

      tinyApis.sSetSelection([ 3, 0 ], 'Spanning '.length, [ 4, 0 ], 'paragraphs'.length),
      sAnnotate(editor, 'gamma', 'id-four', { something: 'comment-four' }),

      tinyApis.sSetSelection([ 4, 0, 0 ], 'par'.length, [ 4, 0, 0 ], 'parag'.length ),
      sAnnotate(editor, 'delta', 'id-five', { something: 'comment-five' }),

      Step.wait(1000),
      sClearChanges,

      sAssertHtmlContent(tinyApis, [
        `<p>This <span data-mce-annotation="alpha" data-test-anything="comment-1" data-mce-annotation-uid="id-one" class="mce-annotation">is</span> the first paragraph</p>`,

        `<p>T<span data-mce-annotation="alpha" data-test-anything="comment-two" data-mce-annotation-uid="id-two" class="mce-annotation">his is</span> the second.</p>`,

        `<p>This is the th<span data-mce-annotation="beta" data-test-something="comment-three" data-mce-annotation-uid="id-three" class="mce-annotation">ir</span>d.</p>`,

        `<p>Spanning <span data-mce-annotation="gamma" data-test-something="comment-four" data-mce-annotation-uid="id-four" class="mce-annotation">multiple</span></p>`,

        `<p><span data-mce-annotation="gamma" data-test-something="comment-four" data-mce-annotation-uid="id-four" class="mce-annotation">par` +
          `<span data-mce-annotation="delta" data-test-something="comment-five" data-mce-annotation-uid="id-five" class="mce-annotation delta-test">ag</span>` +
          `raphs</span> now</p>`
      ]),

      // Outside: p(0) > text(0) > "Th".length
      // Inside: p(0) > span(1) > text(0) > 'i'.length
      // Inside: p(1) > span(1) > text(0), 'hi'.length
      // Outside: p(1) > text(2) > ' the '.length

      Waiter.sTryUntil(
        'Waiting for no changes',
        sAssertChanges('Should be no changes', [ ]),
        10,
        1000
      ),

      sTestAnnotationEvents(
        'No annotation at cursor',
        [ 0, 0 ], 'Th'.length,
        [
          { state: false, name: 'delta', uid: null },
          { state: false, name: 'gamma', uid: null }
        ]
      ),

//.........这里部分代码省略.........
开发者ID:danielpunkass,项目名称:tinymce,代码行数:101,代码来源:AnnotationChangedTest.ts

示例2: return

const toggleActiveState = (editor: Editor, enabledState: Cell<boolean>) => (api) => {
  api.setActive(enabledState.get());
  const editorEventCallback = (e) => api.setActive(e.state);
  editor.on('VisualBlocks', editorEventCallback);
  return () => editor.off('VisualBlocks', editorEventCallback);
};
开发者ID:tinymce,项目名称:tinymce,代码行数:6,代码来源:Buttons.ts

示例3: function

const open = function (editor: Editor, headState: Cell<string>) {
  const data = Parser.htmlToData(editor, headState.get());

  const defaultData = {
    title: '',
    keywords: '',
    description: '',
    robots: '',
    author: '',
    docencoding: ''
  };

  const initialData = Merger.merge(defaultData, data);

  editor.windowManager.open({
    title: 'Metadata and Document Properties',
    size: 'normal',
    body: {
      type: 'panel',
      items: [
        {
          name: 'title',
          type: 'input',
          label: 'Title'
        },
        {
          name: 'keywords',
          type: 'input',
          label: 'Keywords'
        },
        {
          name: 'description',
          type: 'input',
          label: 'Description'
        },
        {
          name: 'robots',
          type: 'input',
          label: 'Robots'
        },
        {
          name: 'author',
          type: 'input',
          label: 'Author'
        },
        {
          name: 'docencoding',
          type: 'input',
          label: 'Encoding'
        },
      ]
    },
    buttons: [
      {
        type: 'cancel',
        name: 'cancel',
        text: 'Cancel'
      },
      {
        type: 'submit',
        name: 'save',
        text: 'Save',
        primary: true
      }
    ],
    initialData,
    onSubmit: (api) => {
      const nuData = api.getData();

      const headHtml = Parser.dataToHtml(editor, Tools.extend(data, nuData), headState.get());

      headState.set(headHtml);

      api.close();
    }
  });
};
开发者ID:tinymce,项目名称:tinymce,代码行数:77,代码来源:Dialog.ts

示例4: function

 editor.on('SpellcheckStart SpellcheckEnd', function () {
   self.active(startedState.get());
 });
开发者ID:danielpunkass,项目名称:tinymce,代码行数:3,代码来源:Buttons.ts

示例5:

 onItemAction: (splitButtonApi, value) => {
   currentLanguageState.set(value);
 }
开发者ID:tinymce,项目名称:tinymce,代码行数:3,代码来源:Buttons.ts

示例6:

 const setPatterns = (newPatterns: Pattern[]) => {
   patternsState.set(createPatternSet(newPatterns));
 };
开发者ID:danielpunkass,项目名称:tinymce,代码行数:3,代码来源:Api.ts

示例7: applyColour

 onAction: (splitButtonApi) => {
   // do something with last colour
   if (lastColor.get() !== null) {
     applyColour(editor, format, lastColor.get(), () => { });
   }
 },
开发者ID:tinymce,项目名称:tinymce,代码行数:6,代码来源:ColorSwatch.ts

示例8:

 const updateSelectionState = (itemRange: ItemRange) => itemSelection.each((selection) => {
   if (Compare.eq(itemRange === ItemRange.Start ? selection.start : selection.end, item)) {
     selectionState.set(itemRange === ItemRange.Start);
   }
 });
开发者ID:mdgbayly,项目名称:tinymce,代码行数:5,代码来源:ParseLists.ts

示例9: function

 const getTextMatcher = function () {
   return textMatcherState.get();
 };
开发者ID:tinymce,项目名称:tinymce,代码行数:3,代码来源:Api.ts


注:本文中的@ephox/katamari.Cell类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。