Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚠️ 📖 DRAFT: <text-editor> #115

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open

⚠️ 📖 DRAFT: <text-editor> #115

wants to merge 25 commits into from

Conversation

snuggs
Copy link
Member

@snuggs snuggs commented Jul 21, 2017

@snuggs
Copy link
Member Author

snuggs commented Jul 23, 2017

@pachonk VERY interesting feature in the platform /cc @brandondees https://developer.mozilla.org/en/docs/Web/API/Document/execCommand

@snuggs
Copy link
Member Author

snuggs commented Jul 23, 2017

@pachonk are we interested in "medium style" editing?
image

@brandondees
Copy link
Collaborator

I don't love it, but then again I'm a vim user and I prefer markdown.... maybe it's progress, I don't know. The A11y treatment is key for stuff like this.

@brandondees
Copy link
Collaborator

that's very interesting to see there's a whole set of features for supporting this. how feasible is it to effectively polyfill those instead of creating yet another api?

@snuggs
Copy link
Member Author

snuggs commented Jul 23, 2017

@brandondees i mean do we care that much about Android browsers? Even Android users don't use the default browser for the most part. Usually use Chrome.

capture d ecran 2017-07-23 a 14 09 58

@grepsedawk
Copy link
Collaborator

grepsedawk commented Jul 23, 2017 via email

@snuggs
Copy link
Member Author

snuggs commented Jul 23, 2017

Exactly @pachonk. Great input

@brandondees
Copy link
Collaborator

d'oh, i was looking at MDN which says it's FF only. they really gotta figure out a better way to keep that info up to date...

so, no polyfill needed. let's do it.

@snuggs
Copy link
Member Author

snuggs commented Jul 23, 2017

@brandondees @pachonk @mrbernnz @janz93 @kurtcagle @dcchuck @halorium @tmornini comparison table for our <text-editor> WYSIWYG (Actually 400Bytes brotli compressed but that would be showing off :-) ):
capture d ecran 2017-07-23 a 19 10 57

@snuggs
Copy link
Member Author

snuggs commented Jul 23, 2017

<text-editor>
  <menu onclick=execute>
    <template name=actions>
      <button name={name} icon={icon} title={title}>{title}</button>
    </template>
  </menu>

  <article contenteditable>This is default text for article</article>
</text-editor>

<script defer>

Element `text-editor`

(class extends HTMLElement {

  execute (event, button = event.target, action = this.find (button.name)) {
    (HTMLButtonElement === button.constructor)
      && document.execCommand (action.command, false, action.value)
  }

  find (name) {
    for (var i = 0; i < this.actions.length; i++)
      if (name === this.actions [i].name)
          return this.actions [i]
  }

  get actions () {
    return [
      { icon: '¶', name: 'bold', title: 'Bold Text', command: 'bold' }
    , { icon: '¶', name: 'italic', title: 'Italicize Text', command: 'italic' }
    , { icon: '¶', name: 'underline', title: 'Underline Text', command: 'underline' }
    , { icon: '¶', name: 'left', title: 'Left Justify Text', command: 'justifyLeft' }
    , { icon: '¶', name: 'center', title: 'Center Justify Text', command: 'justifyCenter' }
    , { icon: '¶', name: 'right', title: 'Right Justify Text', command: 'justifyRight' }
    , { icon: '¶', name: 'strikethrough', title: 'Strikethrough Text', command: 'strikeThrough' }
    , { icon: '¶', name: 'paragraph', title: 'Convert Text to Paragraph', command: 'insertParagraph' }
    , { icon: '¶', name: 'ulist', title: 'Convert to Unordered List', command: 'insertUnorderedist' }
    , { icon: '¶', name: 'olist', title: 'Convert to Ordered List', command: 'insertOrderedist' }
    , { icon: '¶', name: 'line', title: 'Insert Horizontal Rule', command: 'insertHorizontalRule' }
    , { icon: '¶', name: 'link', title: 'Create URL Link', command: 'createLink' }
    , { icon: '¶', name: 'header', title: 'Create Header', command: 'formatBlock', value: '<h1>' }
    , { icon: '¶', name: 'subheader', title: 'Create Sub-Header', command: 'formatBlock', value: '<h2>' }
    ]
  }
})
</script>

@grepsedawk
Copy link
Collaborator

/bump
Hey, any [life] updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants